2026.3.31

张开发
2026/5/9 22:34:02 15 分钟阅读
2026.3.31
1.在root用户的主目录下创建两个目录分别为haha和hehe复制hehe目录到haha目录并重命名为apple。[rootlocalhost ~]# mkdir /root/haha /root/hehe [rootlocalhost ~]# cp -r /root/hehe /root/haha/apple2.将hehe目录移动到apple目录下在haha目录下创建一个普通文件为heihei.txt。[rootlocalhost ~]# mv /root/hehe /root/haha/apple/ [rootlocalhost ~]# touch /root/haha/heihei.txt3.在终端中显示当前系统时间时间格式为月日时[rootlocalhost ~]# date %m%d%H4.截取当前日期的年月日显示在文件A.txt 中[rootlocalhost ~]# date %Y%m%d A.txt5.用户配置/etc/passwd文件将34 字段分别截取出来写入文件UID和文件GID文件[rootlocalhost ~]# cut -d -f 3 /etc/passwd UID [rootlocalhost ~]# cut -d -f 4 /etc/passwd GID6.通过一句话在当前终端显示当前系统一共有多少用户[rootlocalhost ~]# echo 当前系统一共有wc -l /etc/passwd | cut -d -f 1个用户7、列出/etc/passwd文件中所有用户名:分割开每一行中第一个字段就是用户名[rootlocalhost ~]# grep -i .* /etc/passwd8、将/etc/passwd中内容按照冒号隔开的第三个字符从大到小排序后输出所有内容[rootlocalhost ~]# sort -t : -k3 -nr /etc/passwd9、列出/etc/passwd中的第20行-25行内容[rootlocalhost ~]# head -n 25 /etc/passwd | tail - n 610、切割出你的ip地址和mac地址[rootlocalhost ~]# ip a | grep link/ether 192.168.231.128 00:0c:29:2d:a6:6f11、通过:切割出/etc/passwd中的最后一个字段并进行重复内容的重复次数统计wc-l | cut -d : -f 7 /etc/passwd | sort^C12、通过df -h显示文件系统使用情况过滤显示/ 系统现在剩余大小在终端提示用户当前/系统的剩余大小为xx [rootlocalhost ~]# echo 当前/系统剩余大小为 df-h | tr -s |cut -d -f 413、查找/var所有的日志文件*.log备份在自定义的日志目录下/logfile。[rootlocalhost ~]# find /var -name *.log -exec cp {}/logfile \:14、将备份好的所有日志文件进行压缩格式为.gz 包名为all_log_backup.tar.gz。[rootlocalhost ~]# tar -czf all_log_backup.tar.gz /logfile15、将压缩包中的文件解压到/root目录[rootlocalhost ~]# tar -xf all_log_backup.tar.gz -C /test

更多文章