Linux Admin教程

Linux Admin 基本命令

在学习 CentOS Linux 管理员的工具之前,重要的是要注意 Linux 管理命令行背后的哲学。
Linux 是基于 Unix philo 设计的"链接在一起的小而精确的工具,简化了更大的任务"的秘诀。从根本上说,Linux 在很多时候都没有用于特定用途的大型单一用途应用程序。相反,有数百个基本实用程序组合在一起时可以提供高效完成大任务的强大动力。

Linux例子

例如,如果管理员想要一个系统上所有当前用户的列表,可以使用以下链接命令来获取所有系统用户的列表。执行命令时,系统上的用户按字母顺序列出。
[root@centosLocal centos]# cut /etc/passwd-d":"-f1 | sort 
abrt 
adm 
avahi 
bin 
centos 
chrony 
colord 
daemon 
dbus
使用以下命令可以轻松地将此列表导出到文本文件中。
[root@localhost /]# cut /etc/passwd-d ":"-f1 > system_users.txt        
[root@localhost /]# cat ./system_users.txt | sort | wc –l 
40       
[root@localhost /]#
还可以将用户列表与以后的导出进行比较。
[root@centosLocal centos]#  cut /etc/passwd-d ":"-f1 > system_users002.txt && 
   cat system_users002.txt | sort | wc-l 
41 
[root@centosLocal centos]# diff ./system_users.txt ./system_users002.txt  
evilBackdoor [root@centosLocal centos]#
系统中添加了一个新用户"evilBackdoor"。
使用这种链接小工具来完成更大任务的方法,让脚本执行这些命令比定期自动通过电子邮件发送结果更简单。
每个 Linux 管理员都应该精通的基本命令是-
vim grep more and less tail head wc sort uniq tee cat cut sed tr paste
在 Linux 世界中,管理员每天使用 过滤 命令来解析日志、过滤命令输出并使用交互式 shell 脚本执行操作。如前所述,这些命令的强大之处在于它们能够通过称为 管道的过程相互修改。
以下命令显示了 CentOS 主用户词典中有多少个以字母 a 开头的单词。
[root@centosLocal ~]# egrep '^a.* /usr/share/dict/words | wc-l 
25192 
[root@centosLocal ~]#
/usr/share/dict/words | wc-l 25192 [root@centosLocal ~]#
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4