4.1第一次练习作业
1.在root用户的主目录下创建两个目录分别为haha和hehe复制hehe目录到haha目录并重命名为apple。[rootlocalhost ~]# mkdir {haha,hehe} [rootlocalhost ~]# cp -r hehe haha [rootlocalhost ~]# cd haha [rootlocalhost haha]# mv hehe apple2.将hehe目录移动到apple目录下在haha目录下创建一个普通文件为heihei.txt。[rootlocalhost ~]# mv hehe /haha/apple3.在终端中显示当前系统时间时间格式为月日时[rootlocalhost ~]# date %m%d%H 0401194.截取当前日期的年月日显示在文件A.txt 中[rootlocalhost ~]# date %Y%md A.txt[rootlocalhost ~]# cat A.txt 202604015.用户配置/etc/passwd文件将34 字段分别截取出来写入文件UID和文件GID文件[rootlocalhost ~]# cut -d : -f3 /etc/passwd UID.txt [rootlocalhost ~]# cut -d : -f4 /etc/passwd GID.txt6.通过一句话在当前终端显示当前系统一共有多少用户[rootlocalhost ~]# echo 当前系统有 cat /etc/passwd | wc -l个用户 当前系统有 39个用户7、列出/etc/passwd文件中所有用户名:分割开每一行中第一个字段就是用户名[rootlocalhost ~]# cut -d : -f1 /etc/passwd8、将/etc/passwd中内容按照冒号隔开的第三个字符从大到小排序后输出所有内容[rootlocalhost ~]# cut -d : -f3 /etc/passwd | sort -n9、列出/etc/passwd中的第20行-25行内容[rootlocalhost ~]# head -25 /etc/passwd | tail -6 polkitd:x:114:114:User for polkitd:/:/sbin/nologin rtkit:x:172:172:RealtimeKit:/:/sbin/nologin pipewire:x:996:994:PipeWire System Daemon:/run/pipewire:/usr/sbin/nologin geoclue:x:995:993:User for geoclue:/var/lib/geoclue:/sbin/nologin clevis:x:994:992:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin sssd:x:993:991:User for sssd:/run/sssd/:/sbin/nologin10、切割出你的ip地址和mac地址[rootlocalhost ~]# ip a | grep 192 | tr -s | cut -d -f3 192.168.5.128/24[rootlocalhost ~]# ip a | grep ether | tr -s | cut -d -f3 00:0c:29:62:bf:ff11、通过:切割出/etc/passwd中的最后一个字段并进行重复内容的重复次数统计[rootlocalhost ~]# cut -d : -f7 /etc/passwd | uniq -c12、通过df -h显示文件系统使用情况过滤显示/ 系统现在剩余大小在终端提示用户当前/系统的剩余大小为xx [rootlocalhost ~]# df -h | grep -w / /dev/mapper/rhel-root 37G 4.6G 33G 13% /13、查找/var所有的日志文件*.log 备份在自定义的日志目录下/logfile。[rootlocalhost /]#mkdir logfile [rootlocalhost /]# find . /var -type f -name *.log -exec cp {} / logfile \;14、将备份好的所有日志文件进行压缩格式为.gz 包名为all_log_backup.tar.gz。[rootlocalhost ~]# tar -czf all_log_backup.tar.gz /logfile15、将压缩包中的文件解压到/root目录[rootlocalhost ~]# gunzip all_log_backup.tar.gz
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2476983.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!