1.磁碟資訊[wang@localhost 案頭]$
du -sh ./mm392K ./mm[wang@localhost 案頭]$
du -ak ./mm376 ./mm/boot_nontrust.bin4 ./mm/bt.sh0 ./mm/check.md54 ./mm/rtk8723_bt_config4 ./mm/startup.x392 ./mm[wang@localhost 案頭]$
du -ah ./mm376K ./mm/boot_nontrust.bin4.0K ./mm/bt.sh0 ./mm/check.md54.0K ./mm/rtk8723_bt_config4.0K ./mm/startup.x392K ./mm[wang@localhost 案頭]$
du -ac ./mm376 ./mm/boot_nontrust.bin4 ./mm/bt.sh0 ./mm/check.md54 ./mm/rtk8723_bt_config4 ./mm/startup.x392 ./mm392 總計[wang@localhost 案頭]$
du -m ./mm1 ./mm-a 所有檔案情況;-s 合計資料;-h 友好輸出;-c 總和;-b -k -m -B 位元組 Kb Mb 塊。[wang@localhost 案頭]$
df -h檔案系統 容量 已用 可用 已用% 掛載點/dev/mapper/vg_localhost-lv_root 28G 12G 15G 46% //dev/sda1 194M 14M 171M 8% /boottmpfs 502M 15M 488M 3% /dev/shm.host:/ 139G 35G 105G 25% /mnt/hgfs 2.命令執行時間 [wang@localhost 案頭]$
time ls a.txt b.txt b.txt.orig c.patch mm mm~ PC1 shell.sh test1.sh real
0m0.025s //從開始到結束的時間 user
0m0.001s //使用者模式CPU的時間 sys
0m0.001s //核心模式CPU的時間 [wang@localhost 案頭]$ time -o out.o ls bash: -o: command not found real
0m0.004s user
0m0.000s sys
0m0.000s [wang@localhost 案頭]$
/usr/bin/time -o out.o ls //使用time的其他功能就要用/usr/bin/time a.txt b.txt b.txt.orig c.patch mm mm~ out.o PC1
shell.sh test1.sh
[wang@localhost 案頭]$
/usr/bin/time -f "Pagesize: %Z bytes" ls> /dev/null Pagesize: 4096 bytes
[wang@localhost 案頭]$ /usr/bin/time -f "Pagesize: %Z bytes" -o out.o ls> /dev/null 3.使用者資訊 [wang@localhost 案頭]$
who wang tty1 2013-03-05 14:44 (:0) wang pts/0 2013-03-05 14:44 (:0.0) wang pts/1 2013-03-25 17:02 (:0.0) wang pts/2 2013-03-11 10:10 (:0.0) wang pts/3 2013-03-12 10:19 (:0.0) [wang@localhost 案頭]$
w 10:10:03 up 5 days, 21:54, 5 users, load average: 0.21, 0.06, 0.02 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT wang tty1 :0 05Mar13 21days 9:48 0.03s pam: gdm-passwo wang pts/0 :0.0 05Mar13 12days 0.46s 50.76s gnome-terminal wang pts/1 :0.0 Mon17 1.00s 0.27s 0.12s w wang pts/2 :0.0 11Mar13 22:56m 0.21s 0.21s bash wang pts/3 :0.0 12Mar13 6days 0.18s 50.76s gnome-terminal
[wang@localhost 案頭]$
users wang wang wang wang wang
[wang@localhost 案頭]$
last //登入工作階段資訊 wang pts/1 :0.0 Mon Mar 25 17:02 still logged in wang pts/4 :0.0 Fri Mar 22 17:09 - 17:02 (2+23:52)
…… [wang@localhost 案頭]$
last reboot //擷取重啟會話資訊 reboot system boot 2.6.29.4-167.fc1 Wed Mar 6 14:43 (21+19:31) reboot system boot 2.6.29.4-167.fc1 Sun Jan 27 09:07 (60+01:07) reboot system boot 2.6.29.4-167.fc1 Sat Jan 26 18:13 (60+16:02) reboot system boot 2.6.29.4-167.fc1 Sat Jan 26 18:08 (60+16:06) reboot system boot 2.6.29.4-167.fc1 Thu Jan 10 20:50 (76+13:24) reboot system boot 2.6.29.4-167.fc1 Thu Jan 10 04:31 (77+05:44) wtmp begins Thu Jan 10 04:31:04 2013 [wang@localhost 案頭]$
last USER //獲得單個使用者登入工作階段資訊 wtmp begins Thu Jan 10 04:31:04 2013 [wang@localhost 案頭]$
lastb //列出登入系統失敗的使用者相關資訊 lastb: /var/log/btmp: Permission denied [wang@localhost 案頭]$ su 密碼: [root@localhost 案頭]#
lastb wang tty1 :0 Tue Mar 5 14:44 - 14:44 (00:00) btmp begins Tue Mar 5 14:44:04 2013
4.進程資訊 [wang@localhost 案頭]$ ps PID TTY TIME CMD 7128 pts/1 00:00:00 bash 7943 pts/1 00:00:00 bash
32625 pts/1 00:00:00 bash 32651 pts/1 00:00:00 ps
[wang@localhost 案頭]$
ps -f UID PID PPID C STIME TTY TIME CMD wang 7128 3023 0 Mar28 pts/1 00:00:00 bash wang 7943 7942 0 Mar28 pts/1 00:00:00 bash wang 32625 32623 0 13:08 pts/1 00:00:00 bash wang 32654 32625 0 13:08 pts/1 00:00:00 ps -f
[wang@localhost 案頭]$
ps -eo comm,pcpu | head //comm表示命令名,pupc表示cpu使用率 ,還有其他參數 COMMAND %CPU init 0.0 kthreadd 0.0 migration/0 0.0 ksoftirqd/0 0.0 watchdog/0 0.0 cpuset 0.0 events/0 0.0 work_on_cpu/0 0.0 khelper 0.0
參數列表: pcpu cpu佔用率 pid 進程ID ppid 父進程ID pmem 記憶體使用量率 comm 可執行檔 cmd 簡單命令 user 啟動進程的使用者 nice 優先順序 time 累計的cpu時間 etime 進程啟動後度過的時間 tty 所關聯的TTY裝置 euid 有效使用者ID stat 進程狀態 [wang@localhost 案頭]$
ps -eo comm,pcpu --sort -pcpu | head //按pcpu降序排列 COMMAND %CPU Xorg 0.1 gedit 0.0 ata/0 0.0 pulseaudio 0.0 nautilus 0.0 python 0.0 vmtoolsd 0.0 gnome-terminal 0.0 ibus-daemon 0.0
[wang@localhost 案頭]$
ps -C bash PID TTY TIME CMD 3025 pts/0 00:00:00 bash 3123 pts/0 00:00:00 bash ……
[wang@localhost 案頭]$
pgrep bash 3025 3123 ……
[wang@localhost 案頭]$
ps -eo pid,cmd e | tail -n 3 //顯示進程的環境變數 [wang@localhost 案頭]$ kill 進程號 [wang@localhost 案頭]$ kill -9 進程號 //強制殺死進程 [wang@localhost 案頭]$ killall 進程名字 [wang@localhost 案頭]$ killall -9 進程名字
[wang@localhost 案頭]$ kill %進程號 //殺死後台運行進程 [wang@localhost 案頭]$
top //動態查看cpu使用率 [wang@localhost 案頭]$
watch -n 1 -d 'ps' //每1秒更新一次 -d 會顯示出前後的差異 5.日誌資訊 /var/log/boot.log 系統啟動資訊 /var/log/httpd Apache Web伺服器日誌 /var/log/messages 發布核心啟動資訊 /var/log/auth.log 使用者認證日誌 /var/log/dmesg 系統開機記錄 var/log/mail.log 郵件伺服器日誌 var/log/Xorg.0.log X伺服器日誌 var/log/wtmp 使用者登入工作階段記錄 [wang@localhost 案頭]$
logger This is a test [wang@localhost 案頭]$ tail -n -1 /var/log/messages tail: 無法開啟 “/var/log/messages” 讀取資料: 許可權不夠 [wang@localhost 案頭]$ su 密碼: [root@localhost 案頭]# tail -n -1 /var/log/messages Mar 29 09:39:47 localhost dhclient: bound to 192.168.126.148 -- renewal in 890 seconds. [root@localhost 案頭]# logger This is a test [root@localhost 案頭]# tail -n -1 /var/log/messages Mar 29 09:40:11 localhost wang: This is a test
[wang@localhost 案頭]$
cat a.txt | wall //向所有當前登入使用者的終端寫入訊息 Broadcast message from wang (Fri Mar 29 13:48:43 2013): a b c d e f g
6.系統資訊 [wang@localhost 案頭]$
hostname //當前系統主機名稱 localhost.wang [wang@localhost 案頭]$
uname -n //linux核心版本和硬體架構資訊 localhost.wang [wang@localhost 案頭]$
uname -a //核心發布版本 Linux localhost.wang 2.6.29.4-167.fc11.i686.PAE #1 SMP Wed May 27 17:28:22 EDT 2009 i686 athlon i386 GNU/Linux [wang@localhost 案頭]$
uname -m //主控件類型 i686 [wang@localhost 案頭]$
cat /proc/cpuinfo //處理器資訊
[wang@localhost 案頭]$
cat /proc/meminfo //記憶體資訊 [wang@localhost 案頭]$
cat /proc/partitions //系統磁碟分割資訊 7.檔案查詢 [wang@localhost 案頭]$
which ls //查看可執行檔的位置 alias ls='ls --color=auto' /bin/ls [wang@localhost 案頭]$
whereis ls //查看檔案的位置 ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz -b : 只找二進位檔案 -m: 只找在說明檔案manual路徑下的檔案 -s : 只找source源檔案 -u : 沒有說明文檔的檔案
[wang@localhost 案頭]$
locate passwd //是在資料庫裡尋找,資料庫大至每天更新一次 locate: can not stat () `/var/lib/mlocate/mlocate.db': 沒有那個檔案或目錄
locate 是在資料庫裡尋找,資料庫大至每天更新一次 [wang@localhost 案頭]$
whatis ls ls [] (1) - list directory contents ls [] (1p) - list directory contents
[wang@localhost 案頭]$
uptime 13:43:00 up 6 days, 5:25, 5 users, load average: 0.00, 0.00, 0.00