วันพุธที่ 25 มิถุนายน พ.ศ. 2557

คำสั่งที่ใช้บ่อยใน FreeBSD/UNIX

hostname           Name of computer
uname -a           Shows operating system info
env                Shows current environment variables, including user & path
df -h              D_isk F_ree space
uptime             Server UpTime stats & operation
egrep 'ad[0-9]' /var/run/dmesg.boot   List hard drives
egrep 'cd[0-9]' /var/run/dmesg.boot   List CDROM drives

pwd                Present Working Directory
w                  W_ho is logged on & server info
who                WHO is logged on and IP address
last               LAST users logged on and statuses
ac                 ACcounting of total time logged on
top                TOP processes currently executing listed per CPU time
ps aux
ps ax

set
netstat
trafshow
cd                 Change the Directory that you are working in
man                Show the MANual pages for a program
tail -300 maillog  Show the TAILend of the 'maillog' file -- last 300 lines
kill -9 PID        KILLs a specific process # (PID), non-catchable, non-ignorable (-9)
shutdown -r now    ShutDown the computer, then reboot, immediately
id

vmstat -w 5
vmstat boot
more               Display a file, showing a page at a time. Show MORE by hitting 'space'.
head
tail
ls -lt             LiSt (-l with L_ots of info) (-t sort by time)
ls -laTFWi         LisT all info

                   FIND (starting in root dir) "nameoffile" or anything begining with that
find / -name "nameoffile*"  
                   
           FIND files modified within last day:
find / -mtime -1 -print
                   FIND files modified over 5 days ago:
find / -mtime +5 -print

users              Shows which users are logged on using shell / command line

                   Backs up a file, preserving date/time stamp:
                   
mv   hosts.allow                  hosts.allow-2005-Apr-16
cp   hosts.allow-2005-Apr-16      hosts.allow                   

                   Compress a log file, then mail as an attachment
gzip -c access_log.processed -v > access_log.processed.gz; ls -lt          
uuencode access_log.processed.gz DOMAIN.com.log.gz | mail -s "DOMAIN.com Log File" SomeEmail@xyz.com           
Or inline:
mail -s "Some Text File" email@domain.com < file.log

ls -laTFWiR        LiSt files with all info R = recurse subdirs.  Takes 3 hours!
chown userowner somedirectory
                   Change the owner to 'userowner' of directory 'somedirectory'
/usr/local/psa/qmail/bin/qmail-qstat
                   Show brief statistics about qmail
/usr/local/psa/qmail/bin/qmail-qread                   
                   Show the summary info for EACH email in qmail queue
pkg_info           List the packages installed                   
pkg_add            Add a package
ftp ftp.gnu.org    connects to ftp site ftp.gnu.org
                   'get' gets a file
                   'cd' changes a directory
Ctrl-C             Cancel operation
Ctrl-S             PauSe operation
Alt-F1             Alternate to the 1st terminal window when using 'shell'
Alt-F2             Alternate to the 2nd terminal window when using 'shell'

อ้างอิง : http://www.us-webmasters.com/FreeBSD/Unix-FreeBSD-Commands-Cheat-Sheet/Commands.txt