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
广告
© . All rights reserved.