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.html