Hotkey / Redirection
Basic Admin- Exit X window / Test Hang .......... : Ctrl + Alt + Backslash
Alternate from X window to Terminal .......... : Ctrl + Alt + F2..F6 .. ( Reserse to Xwindow : Ctrl + Alt + F7 )
New Login........... : Ctrl + Alt + F3
Reboot........... : Ctrl + Alt + Del
Memory ........... : Shift + ScrollLock
Prompt ........... : Alt F2
Stop Hang ........... : Alt F2 , Alt F3
Redirect Output ........... : > (such print screen to file $cat > filex )
Redirect Input ........... : <
Redirect Addition to file : ........... : >> - Forget Root Password ( Boot Single )
- At LiLo Prompt / Boot with Floppy , wait for prompt
- Type command ........... : linux single
- --------------------------------------------------------------------------------
- check Server Name / Distribution /Dist Name / Kernel / Prcessor : telnet x.x.x.x (Only name : hostname )
- Date of Installed .......... : uname -a
- Check Resoource :
- Cup / Mem / Swap ..........: top
- Memory only ...........: free
- Disk Space ............: df
- Who Using console ..........: whoami
- Broadcast for user who connected this host ...........: wall 'Server will down in 5 mins ..admin'
- log Reboot / UsrLogin / Ftp /Telnet ...........: last | more
- log size check ..........: du log /var
- File Content ............: cat filename
- File count line ...........: cat filename | wc -l
- file type ..........: file <filename>
- Show some content in file ( head / tail ) ..........: head filename ( show 5 line in head : -n 5 )
- Shell User changing ..........: su
- Shell check ..........: echo $SHELL ( list : chsh - l, change shell : chsh )
- Sort Content in file ..........: sort filename
- Print Manpage ...........: man -t bash > man.ps ( nroff -> postscrip , ps2ascii for postscrip -> txt )
- Text to PDF.......... : software in Mr.Linux
- Restart Inittab ..........: init q or kill -HUP 1
- --------------------------------------------------------------------------------
- search command : keyword <tab>
- Search Description : whatis keyword
- Command Description & Useage : man keyword
- Command Usage : keyword --help
linux Messages show
Create a new user and group by:
#cp /dev/null /root/.bash_history
Type the following command to list top 10 memory eating process Code ................ : ps -auxf | sort -nr -k 4 | head -10
- tail -f /var/log/messages | grep ...
- tail /var/log/messages
- less /var/log/messages
- more -f /var/log/messages
- vi /var/log/messagesOutput:
Common Linux log files name and usage
- /var/log/message: General message and system related stuff
- /var/log/auth.log: Authenication logs
- /var/log/kern.log: Kernel logs
- /var/log/cron.log: Crond logs (cron job)
- /var/log/maillog: Mail server logs
- /var/log/qmail/ : Qmail log directory (more files inside this directory)
- /var/log/httpd/: Apache access and error logs directory
- /var/log/lighttpd: Lighttpd access and error logs directory
- /var/log/boot.log : System boot log
- /var/log/mysqld.log: MySQL database server log file
- /var/log/secure: Authentication log
- /var/log/utmp or /var/log/wtmp : Login records file
- /var/log/yum.log: Yum log files
- --------------------------------------------------------------------------------
- Xwindow need : ntsysv , On xfs Service
- VGA & Resolution Tool : DarkConf
- Show Current Config : Xdrakres
- Vga & Monitor Setup : Xconfigurator
- Exit Xwindow / Test Hang : Ctrl + Alt + Backslash
- Xremote :
- $xhost +
- $export DISPLAY=192.168.20.Client:0.0
- General Set :
- Monitor : Generic / Super VGA 1024 x 768 87 Hz
- monitor2 : Extended super vga , 800 x 600 at 60 Hz
- Resulation : 16 million color (24bit) 800 x 600
- --------------------------------------------------------------------------------
- Check kernel version ........: kernelversion
- Check Distribution Kernal : uname -a , uname -r
- Check Distribution Version : rpm -qa | grep
- Check Server Name ..........: uname -a
- Check Shell .....................: kviewshell -v
- --------------------------------------------------------------------------------
- Check Hardware & another .................................................... : dmesg | more ( from /var/log/dmesg )
- linux cpu type...................................................................... : cat /proc/cpuinfo
- Find the speed of Ethernet card ............................................. : dmesg |grep eth0
- Find the speed of Ethernet card ............................................. : ethtool eth0
List PCI Devices .................................................................. : lspci
- Drop Caches ....................................................................... : echo 1 > /proc/sys/vm/drop_caches
- Drop Caches ....................................................................... : echo 2 > /proc/sys/vm/drop_caches ( To free dentries and inodes )
- Drop Caches ....................................................................... : echo 3 > /proc/sys/vm/drop_caches ( To free pagecache, dentries and inodes )
- --------------------------------------------------------------------------------
date -s "7/12/2009 08:38:05" -- "mm/dd/yyyy hh:mm:ss" rdate -s time-a.nist.gov
- --------------------------------------------------------------------------------
- Check disk performance :
- dmesg | more ( raid 5 )
- hdparm -t -T /dev/hdx ( adjust speed : hdparm -c /dev/sda5 )
- Check free disk ...............................: df
- Check Disk Use ( dir / s ) .................: du | more ( du -h | tail -n 1 )
- Check Bad Block ..............................: e2fsck -c /dev/sda5
- Check & admin IDE ..........................: hdparm -parameter
- Manual Fix .......................................: fsck -y /dev/hda1
- Format Disk .....................................: mke2fs /dev/hdb2
- Mount CD-ROM..................................: mount /dev/cdrom /cdrom or mount -t iso9660 /dev/cdrom/ /mnt/cdrom
- Unmount...........................................: unmount /mnt/cdrom
- Modify Partitiontable ..........................: fdisk
- Add Second IDE :
- fdisk /dev/hdb ... ( not hdb1 )
- press p ............................................... look for exist partition
- press d ............................................... delete the old partition on disk
- press m .............................................. for menu help ( p = look partition , n = create new partition , d = delete partition )
- after clear disk to space press n............. for create new partition
- Select primary partition ........................ ( not extend partition )
- enter for start and end number of cylinder.. ( use default incase one partition )
- press w and then press e .......................... for save and exit
- $mke2fs /dev/hdb1 .................................. format ext2
- $cd / and $mkdir /data............................ create directory support
- $mount -t ext2 /dev/hdb1 /data ................ mount to directory
- edit /etc/fstab add : .................................. : /dev/hdb1 /data ext2 defaults 1 2
- reboot
- --------------------------------------------------------------------------------
- Compare 2 file .....................................................: cmp file1 file2
- Change Dir ..........................................................: cd /etc/usr/local
- Check Current Directory ........................................: pwd
- Check Size of Directory .........................................: du ( unit default = kb , -m for MB )
- Up one Level ........................................................: cd ..
- List ( Dir ) ............................................................: ls -l , ls file* ( show include hidden file : ls -al )
- List include hidden files .........................................: ls -al
- print screen to file .................................................: echo > filename
- Show & print to file ...............................................: <df -h> | tee filenamecd
- File Symbole .........................................................: - regular , d directory , b block special , c character special , p pipe , l link
- File name long ......................................................: 255 char for ext2
- File Create ............................................................: echo > filename
- File Type ...............................................................: cat /etc/filex
- File Delete .............................................................: rm -f filename
- Remove Directory....................................................: rm -r directory
- Remove Directory....................................................: rm -rf directory ( if directory is not empty )
- File Copy ...............................................................: cp filex /newdir
- File Rename ..........................................................: mv file1 file2
- File Move ...............................................................: mv file1 /newdir
- File (rawrite)...........................................................: dd
- File (subst) ............................................................: ln
- ln -s file1 file2 ( Creates a symbolic link to file1 with the name of the file2. )
- File (attrib) ............................................................: chmod
- File (sort) ..............................................................: sort
- File set timestamp ..................................................: touch filex
- File Classify ...........................................................: file filex
- Dir (mkdir) .............................................................: md dirx
- Dir (deltree /Y) .......................................................: rm -rf dirx
- Dir (rmdir) ..............................................................: rd dirx (Delete only empty directory)
- Dir current check .....................................................: pwd
- Dir change .............................................................: cd /etc
- Dir up level ............................................................: cd ..
- --------------------------------------------------------------------------------
- Find text in file .......................................................: find / | xargs grep text -i
- Find name about on machine ....................................: find / | grep filename
- Find file in directory .................................................: ls sample*.*
- Find all machine ......................................................: no commend
- Find Syntax in File all machines .................................: no commend
How to find files in Linux using 'find'
find -name 'mypage.htm'
#In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.find / -name 'mypage.htm'
#In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.find -name 'file*'
#In the above example the system would search for any file beginning with file in the current directory and any subdirectory.find -name '*' -size +1000k
#In the above example the system would search for any file that is larger then 1000k.find . -size +500000 -print
- --------------------------------------------------------------------------------
- Manage User ...........................................................: userconf (user tab)
- Current connect .......................................................: who
- Login User reboot / ftp / telnet ..................................: last | more
- Detail of Current connected user ................................: finger
- Add User.................................................................: add user xxxx
- Change Password ....................................................: passwd
- Backup user account ................................................: /etc/passwd
Create a new user and group by:
# groupadd www-data
# useradd -g www-data www-data
What is the command to list users?
- cat /etc/passwd
- cat /etc/passwd |grep 500*
- cat /etc/passwd | grep /home | cut -d: -f1
- cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]"
- cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]" | grep "/home" | cut -d: -f1
- gawk -F: '{ print $1 }' /etc/passwd
- --------------------------------------------------------------------------------
- Permit All thing ......................................................: chmode 777 file
- Change owner ........................................................: chown newuser file
- Change Groupe .......................................................: chgrp newgrp file
- Change Format .......................................................: chmode usr/grp/owner + rwxst file
- 777 rwx rwx rwx
- 770 rwx rwx ---
- 700 rwx --- ---
- 755 rwx r-x r-x
- 666 rw- rw- rw-
- 660 rw- rw- ---
- 600 rw- --- ---
- 555 r-x r-x r-x
- 400 r-- --- ---
- -------------------------------------------------------------------
- 4 = r--
- 5 = r-x
- 6 = rw-
- 7 = rwx
- --------------------------------------------------------------------------------
- Open New ..........................................................: xterm
- Clear screen .......................................................: clear
- intterupt process ................................................: ^z
- --------------------------------------------------------------------------------
- check path ........................................................... : echo $PATH
- list past command ................................................ : history
#cp /dev/null /root/.bash_history
- run batch file in bash shell ..................................... : ./scriptx
- synchronous / forground mode (sequence statement) ..: netscape
- asynchronous / background mode (not sequence statement) : netscape &
- run level .......................................................................: 0 halt , 1 single , 2 multiuser no NFS , 3 multiuser , 4 nouse , 5 multiuser with X , 6 reboot
- --------------------------------------------------------------------------------
- Process Monitor .............................................................: top
- Detail ..........................................................................: Shift+ScrollLock
- chech free memory .........................................................: free
- Swap command ..............................................................: swapon / swapoff
- process Running .............................................................: pstree , ps
- Process of daemon running ..............................................: ps -aux | grep daemon
Type the following command to list top 10 memory eating process Code ................ : ps -auxf | sort -nr -k 4 | head -10
- Select Auto Service .........................................................:ntsysv
- Restart Inittab ...............................................................: init q or kill -HUP 1
- --------------------------------------------------------------------------------
- RPM - Package
- Unzip .tar.gz ................................................................: tar -xvfz zipfile.tar.gz
- Check Package Name .....................................................: ls /cdrom/RPMS | grep ppp
- Check Package Path .......................................................: rpm -ql package
- Check Package install .....................................................: rpm -qa | grep package (such rpm -qa | grep bind)
- Install Package check dependent .....................................: rpm -ih package
- Install Package no check dependent .................................: rpm -ihV package
- Check version ................................................................: rpm -qa | grep package or rpm -v package
- Uninstall .......................................................................: rpm -e shortname or rpm -e -allmatches --nodeps package
- Uninstall force ...............................................................: rpm -e --nodeps shortname
- rpm -qp vym-1.12.0.i586.rpm --requires ........................... Dependenci check
- --------------------------------------------------------------------------------
- After ...........................................................................: tar -fxvz file.tar.gz
- Check yourself ..............................................................: root priviledge ( no need root login )
- Add this line into /etc/ld.so.conf ......................................: /usr/local/lib ... (and run $ldconfig)
- Open README and read
- Exist Script Install :
- ./install.sh (Change path in file install-sh before)
- ./setup.sh
- install (Change install file before)
- No script Install :
- change path in configure , INSTALL
- Create Makefile Script ( Change path in configure file before ).....................: ./configure
- Change path in ....................................................................................: Makefile
- Compile ..............................................................................................: make
- Install ................................................................................................: make install
- --------------------------------------------------------------------------------
- Copy file to / from archives ...........................................................................: cpio
- Lempel-Ziv program .....................................................................................: compress
- ZIP :
- Zip Directory to gz ..........................................................: tar cvf archivename.tar dir-to-archive/ ..(~Backup)
- Zip Directory to gz ..........................................................: gzip new.tar
- Zip File to gz ................................................................: tar cvf new.tar destinationfile
- Unzip
- Total one .......................................................................: tar -zxvf zipfile.tar.gz
- Only gz ..........................................................................: gunzip new.tar.gz
- Only tar .........................................................................: tar -ixvf zipfile.tar
- Only bz2 ........................................................................: bunzip2 zipfile.tar.bz2
- Use Archiver incase ..........................................................: .tgz
- Option
- z ................................................... : xtrace from gz
- v ................................................... : view filename
- z ................................................... : file target/not tape
- v ................................................... : xtrace from tar
- --------------------------------------------------------------------------------
- Net Nic Config ....................................................................... : netconf , ifconfig , linuxconf , netcfg
- Net Remote Login .................................................................. : rlogin
- Net speed & physical link check ............................................... : ping x.x.x.x
- Ask Nebios Name .................................................................. : nmblookup -A x.x.x.x
- Ask IP-Address :
- Internet ............................. : host www.myweb.com , ping www.myweb.com
- Netbios .............................. : nmblookup -A server_x
- Net connect established ......................................................... : netstat -n | more
- Net Trace ( count router & check name ) ................................... : traceroute x.x.x.x
- Net Route ............................................................................ : route [-param]
- Net Masquerade Monitor ........................................................ : gfcc , netstat -m
- Net Status ........................................................................... : netstat -param
- Net Access ........................................................................... : netstat -m
- Net User .............................................................................. : w , who (port513) , users , ftpwho , wc -l , whois x.x.x.xnet
- Net Log / usrlogin ................................................................. : last | more
- Net lookup DNS .................................................................... : nslookup
- Net look Dhcp Leases ............................................................ : cat /var/dhcpd/dhcpd.leases
- Net look Dhcp / server ........................................................... : tail -f /var/log/messages
- Net look squid log ................................................................. : tail -f /var/log/squid/access.log
- Net Firewall Rule Lookup ........................................................ : ipchaines -L
- Net Clear Firewall Rule ........................................................... : ipchaines -F
- Net Chat .............................................................................. : irc
- --------------------------------------------------------------------------------
- Module :
- List Module ........................... : lsmod
- By webmin ............................ : system>software package>
- for Compiling
- Gcc -o name.cgi name.c
- --------------------------------------------------------------------------------
No comments:
Post a Comment