快速业务通道

LinuxCBT_Deb5x_Edition_Notes

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-03-29

###LinuxCBT Deb5x Edition###
Topology -> Docs directory
Features:
1. Multiple platform support: i386, PowerPC, Sparc, MIPS, S390, AMD64, 英特尔64, IA-64, etc.
2. Obtainable via: HTTP, FTP, JIGDO, BitTorrent, CD/DVD
3. Open Source - freely available
4. Ships with thousands of packages


Tasks:
1. Download the various DVD ISO images:
'' for i in `seq 5`; do wget http://cdimage.debian.org/debian-cd/5.0.4/i386/iso-dvd/debian-504-i386-DVD-$i.iso; done ''

2. Confirm the MD5SUMS of downloaded ISOs
3. Prep the VMWare environment
a. https://192.168.75.50:8333
b. Create Virtual Machine
c. Move Debian ISO images beneath top-level container that VMWare references

4. Install Debian on VMWare - from RedHat Enterprise 5x
a. Installed in full-screen, text mode
b. selected single, non-LVM, non-encrypted partition option:
b1. / - 4GB - (/etc, /usr, /var, /home, /boot (linux kernel is here) ...)
b2. swap - 250MB

5. Upgrade Debian4x -> Debian5x
a. Reclamation of existing VMWare instance, that was not in the inventory

Note: This may become our target instance


6. Install Debian via PXE
a. Download netboot.tar.gz - provides PXE code for network installation
b. ''cd /tftpboot && tar -xzvf netboot.tar.gz''
c. Configure Cisco Router DHCP server to servce ''pxelinux.0'' file to client
Note: You may restrict the ''pxelinux.0'' option to specific hosts and/or groups using DHCP configuration - reservations


!
ip dhcp pool linuxcbtwin1
host 192.168.75.101 255.255.255.0
hardware-address 0011.115b.7053
client-name linuxcbtwin1
!
ip dhcp pool DEFAULT75
import all
network 192.168.75.0 255.255.255.0
bootfile pxelinux.0
next-server 192.168.75.50
dns-server 68.94.156.1 68.94.157.1
option 150 ip 10.1.50.2
default-router 192.168.75.1
lease 30
!

Note: 2 Key options for PXE booting
''bootfile pxelinux.0'' - PXE boot client
''next-server 192.168.75.50'' - TFTPD

Note: TFTPD & DHCPD servers may be the same or different
Note: NetInstall mode eventually attmpts to pull the code for the OS from a valid mirror.
You may configure an internal mirror for your organization and point the installer there.


###Linux Boot Sequence###
Features:
1. Boot process Linux systems take to enter usable mode: 1-5

1. BIOS (indicates bootable hard drive)
2. Grand Unified Boot Loader (GRUB) -> MBR of primary HD
3. INITRD (includes drivers for hardware connected to your system)
4. Kernel (detects hardware) -> mounts ''/'' - root file system
5. INIT (propels your system into a usable state) - RunLevels

RunLevels: 0-6
0 -> halt
1 -> single-user mode, without concern for contending I/O
2(Debian Default) - 5 -> multi-user run-levels - networking
6 -> reboot

###Rescue - Boot Problems###
Problems:
1. GRUB
a. ''/boot/grub/menu.lst'' - changed (hd0,0) to (hd1,0) and (hd0,1), then fixed via runlevel 1

2. INITRD
a. Corrupt the file by breaking dependency - renamed initrd.img*
b. Forced a boot by editing GRUB menu to use new INITRD file name


3. INIT
a. Corrupt: /etc/inittab

4. Rescue Mode - Installation detection facility


###Basic Linux Commands###
Features:
1. Numerous small commands that specialize in discrete functions

Tasks:
1. Explore important commands
a. ''whoami''
b. ''id'' - includes info from: ''whoami'' as well as uid|gid info.
c. ''pwd'' - reveals current working directory based on the maintenance of 2 vars:
c1. ''echo $PWD'' - stores the current directory
c2. ''echo $OLDPWD'' - stores most recently visited directory
d. ''cd'' - changes directory - ''cd $OLDPWD''
d1. ''cd'' - with no options, places us in our $HOME directory
Note: The following directory entries:
''.'' - references the current directory
''..'' - references the parent directory

e. ''ls'' - lists files
e1. ''ls -l'' - lists files in long format
e2. ''ls -li'' - lists files in long format with INODE information
e3. ''ls -al'' - reveals hidden files
Note: Nix-based systems prefix hidden files with a ''.''
e4. ''ls -ld'' - reveals attributes of directory entry

f. ''touch'' - creates file if non-existent, otherwise updates timestamp info.
g. ''stat'' - reveals FS information about a file
h. ''!command'' - invokes the most recent invocation of a command from the command history
i. ''echo'' - prints what you tell it to
j. ''cat'' - catenates content to STDOUT by default
j1. ''cat test.txt'' - dumps file to STDOUT
j2. ''cat test.txt test2.txt'' - catenates test.txt , then, test2.txt to STDOUT

k. ''mkdir'' - creates directories
l. ''rmdir'' - removes directories
m. ''rm -rf'' - removes recursively ANY file entry
n. ''export VAR=value'' - sets and exports for use, a variable
n1. ''export MUSIC=/home/linuxcbt/music''
o. ''history'' - dumps the current SHELL''s history
Note: ''!item_num'' executes the command with the number in the shell''s history
p. ''alias ls=''ls -ali'' '' - allows you to make shortcuts to commands and options

Command Chaining:
''ls ; pwd ; echo "test" '' - commands are independent
''ls && pwd && echo "test" '' - logical ANDing - previous command MUST exit with exit status ''0''
''ls || pwd'' - command 2 executes if command 1 fails
Note: You may combine and and/or ALL of these features in a single command

q. ''more | less'' - 2 common pagers - displays a page full of info.
r. ''which'' - searches the $PATH for the command you are in search of

###Redirection###
Features:
1. Input - STDIN - Standard Input - /dev/fd/0 - keyboard (may also be a file)
2. Output - STDOUT - Standard Output - /dev/fd/1 - screen (may also be a file)
3. Errors - STDERR - Standard Error - /dev/fd/2 - error handling

Tasks:
1. Look at STDIN
a. ''<'' - explicit indication
Note: When typical STDIN is ommitted, the process usually waits on STDIN for input (keyboard)
Note: ''CTRL-D will exit STDIN stream''
Note: STDIN is typically implicitly referenced by most processes
b. ''>'' - explicit indication
Note: Typically routes to a file or the screen (STDOUT)
b1. ''cat test.txt test2.txt > test3.txt'' - clobber mode (auto-clobbers file or creates anew)
c. ''>>'' - append redirection - appends to existing file or creates a new file
c1. ''cat test.txt test2.txt >> test3.txt''

d. ''STDERR'' - ''2> errors.txt''
d1. ''ls -l badfile'' - dumps STDERR on STDOUT
d2. ''ls -l badfile 2> errors.txt'' - clobbers and creates errors.txt
d3. ''ls -l badfile 2>> errors.txt'' - appends errors to errors.txt

s. watch - executes and updates the output display of the process
t. tty - echoes the current TTY
Note: GUI Managers spawn Psuedo-terminals: pts0..n
Note: Each pty has a distinct mapping of: fd0(STDIN), fd1(STDOUT), fd2(STDERR), auto-generated by the environment

u. head (dispalys first n lines of file) & tail (dispalys last n lines)
u1. ''head -n 1'', ''tail -n 1'' - both display first and last lines

v. file - returns a file''s type
v1. ''file filename'' - returns types

w. seq - generates a sequence of numbers
w1. ''seq 1000''

x. for - looping mechanism
x1. '' for i in `seq 10`; do echo "Hello World"; done ''
x2. '' for i in `ls -A`; do file $i; done ''

y. reset - resets the buffer of the terminal so you may keep track of your activities

z. free - reveals memory usage


###Tar, Gzip, Bzip2, Zip###
Features:
1. Archiving
2. Compression

Gzip:
1. '' gzip -c filename > filename.gz ''
a. ''seq 1000000 > 1million.txt && ls -lh 1mil*''
b. ''gzip -c 1million.txt > 1milliong.txt.gz''
b1. ''zcat 1million.txt.gz'' - read the binary gzip format and render ASCII text
c. ''gunzip 1million.txt.gz ''
d. ''gzip -l 1million.txt.gz'' - enumerates stats of file

2. Bzip2
a. ''bzip2 -c 1million.txt > 1million.txt.bz2 '' - creates compressed file
b. ''bunzip2 1million.txt.bz2''
c. ''bzcat 1million.txt.bz2''

3. Zip & Unzip
a. ''zip 1million.txt.zip 1million.txt'' - dest source - creates a zip file
b. ''unzip 1million.txt.zip'' - decompresses
c. ''zip stuff.txt.zip *txt'' - squeezes ALL *txt files in current directory
d. ''unzip -l filename.zip'' - enumerates stats
e. ''zcat filename.zip'' - extract on the fly and dump to STDOUT

Note: ''zcat'' applies to both: zip & gzip

4. Tar - archiver - rolls one or more files (including directories) into one image
a. ''tar -cvf alltxtfiles.tar *txt'' - roll ALL txt files into ''alltxtfiles.tar''
b. ''tar -tvf alltxtfiles.tar'' - enumerates the contents of the tarball
c. ''tar -xvf alltxtfiles.tar'' - extracts the contents of the tarball
d. ''tar -xvf alltxtfiles.tar 1000.txt 100k.txt'' - extracts specific files from the archive
e. ''tar -czvf alltxtfiles.tar.gz *txt'' - rolls a tarball with gzip compression
f. ''tar -cjvf alltxtfiles.tar.bz2 *txt'' - rolls a tarball with bzip2 compression


###GREP###
Features:
1. Line processor

Tasks:
1. Use grep to search for interesting strings
a. ''grep cat animals.txt'' - returns ALL lines containing lowercase ''cat''
b. ''grep -i cat animals.txt'' - returns ALL lines containing either case of ''cat''
c. ''grep 20 animals.txt''
d. ''grep "^20" animals.txt - returns lines that are anchored with the string: ''20''
e. ''grep "20contentquot; animals.txt - returns lines that end with the string: ''20''
f. ''grep "^20contentquot; animals.txt - returns lines beginning and ending with the string: ''20''
g. ''grep "^c.*" animals.txt - returns lines beginning with ''c''
Note: There are 3 default chains in the ''Filter'' table
1. INPUT - traffic sourced from external system destined for your system
2. FORWARD - router - traffic that is sent through your box
3. OUTPUT - Traffic sourced from your system to other systems

Note: There are 3 default tables:
1. NAT
2. Mangle
3. Filter (Default)


2b. Limit inbound traffic to the SMTP server to deny access from Windows server
2b1. ''iptables -A INPUT -p tcp --dport 25 -s 192.168.75.105 -j DROP''

3. Use ''ip6tables''
Note: Syntax is virtually identically to ''iptables*''

4. Write outbound rules
4a. ''iptables -A OUTPUT -d 192.168.75.105 -p tcp --dport 3389 -j DROP''

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号