csa题目

张开发
2026/5/6 4:06:11 15 分钟阅读
csa题目
1.在root用户的主目录下创建两个目录分别为haha和hehe复制hehe目录到haha目录并重命名为apple。 bash [rootlocalhost ~]# mkdir /root/{haha,hehe} [rootlocalhost ~]# cp -r hehe haha [rootlocalhost ~]# mv hehe apple 2.将hehe目录移动到apple目录下在haha目录下创建一个普通文件为heihei.txt。 bash [rootlocalhost ~]# mv hehe haha/apple [rootlocalhost ~]# cd /root/haha [rootlocalhost haha]# touch heihei.txt 3.在终端中显示当前系统时间时间格式为月日时 bash [rootlocalhost ~]# date %m%d%H 4.截取当前日期的年月日显示在文件A.txt 中 bash [rootlocalhost ~]# date | cut -d -f1-4 A.txt [rootlocalhost ~]# cat A.txt 2026年 04月 01日 星期三 5.用户配置/etc/passwd文件将34 字段分别截取出来写入文件UID和文件GID文件 bash [rootlocalhost ~]# cat /etc/passwd | cut -d : -f3-4 UID [rootlocalhost ~]# cat /etc/passwd | cut -d : -f3-4 GID 6.通过一句话在当前终端显示当前系统一共有多少用户 bash [rootlocalhost ~]# echo wc -l /etc/passwd | cut -d : -f 1 7、列出/etc/passwd文件中所有用户名:分割开每一行中第一个字段就是用户名 bash [rootlocalhost ~]# cat /etc/passwd | cut -d : -f1 8、将/etc/passwd中内容按照冒号隔开的第三个字符从大到小排序后输出所有内容 bash [rootlocalhost ~]# sort -t : -k 3 -nr /etc/passwd 9、列出/etc/passwd中的第20行-25行内容 bash [rootlocalhost ~]# more 20 /etc/passwd|head -6 10、切割出你的ip地址和mac地址 bash [rootlocalhost ~]# ip a | grep ens160|grep inet|tr -s |cut -d -f3|cut -d / -f1 192.168.176.129 [rootlocalhost ~]# ip a | grep -w link/ether |cut -d -f6 00:0c:29:68:67:9e 11、通过:切割出/etc/passwd中的最后一个字段并进行重复内容的重复次数统计 bash [rootlocalhost ~]# cut -d : -f7 /etc/passwd | uniq -c 12、通过df -h显示文件系统使用情况过滤显示/ 系统现在剩余大小在终端提示用户当前/系统的剩余大小为xx bash [rootlocalhost ~]# echo 当前/系统的剩余大小为 df -h |grep -w /dev/mapper | tr -s | cut -d -f4 当前/系统的剩余大小为 33G 13、查找/var所有的日志文件*.log备份在自定义的日志目录下/logfile。 bash [rootlocalhost ~]# find /var -name *.log -exec cp {} /logfile \; 14、将备份好的所有日志文件进行压缩格式为.gz 包名为all_log_backup.tar.gz。 bash [rootlocalhost ~]# tar -czf all_log_backup.tar.gz 15、将压缩包中的文件解压到/root目录 bash [rootlocalhost ~]# tar -xvf all_log_backup.tar.gz -C /root

更多文章