Linux 管理員 - wc 命令



wc 用於計算檔案中出現的次數。它有助於列印每個檔案的換行、單詞和位元組計數。最有用的是與 grep 結合使用,以便顯示特定模式的匹配。

交換 操作
-c 位元組
-m 字元計數
-l 行計數
-L 最長行的長度

我們可以看到,我們的系統有 5 個使用者,組 ID 為 0。然後進一步檢查後,只有 root 使用者具有 shell 訪問許可權。

[root@centosLocal centos]# cat /etc/passwd | cut -d":" -f4 | grep "^0" |  wc -l 
5 
[root@centosLocal centos]# cat /etc/passwd | cut -d":" -f4,5,6,7 | grep "^0" 
0:root:/root:/bin/bash 
0:sync:/sbin:/bin/sync 
0:shutdown:/sbin:/sbin/shutdown 
0:halt:/sbin:/sbin/halt 
0:operator:/root:/sbin/nologin 
[root@centosLocal centos]#
basic_centos_linux_commands.htm
廣告