1. 使用ls查看/etc/⽬录下所有的⽂件信息
[root@oneday ~]# ls /etc/
2. 使用ls查看/etc/目录下名包含“a”字⺟的⽂件或者⽬录信息
[root@oneday ~]# ls /etc/*a*
3. 使⽤ls查看/etc/⽬录下以".conf"结尾的⽂件信息
[root@oneday ~]# ls /etc/*.conf
4. 使⽤ls查看/etc/⽬录中以"y"字⺟开头的⽂件信息
[root@oneday ~]# ls /etc/y*
5. find查找/var/⽬录中以“.log”⽂件
[root@oneday~]# find /var -name "*.log"
6. 在opt⽬录下创建test⽬录
[root@oneday ~]# mkdir /opt/test
7. 在test⽬录中创建abc.txt,def.txt.ghi.txt,xxx.txt.yyy.txt五个⽂件
[root@oneday ~]# touch /opt/test/abc.txt /opt/test/def.txt /opt/test/ghi.txt /opt/test/xxx.txt /opt/test/yyy.txt
8. 修改以上5个⽂件的最后修改时间分别为15,14,13,12,11,10⽇
[root@oneday ~]# touch /opt/test/abc.txt -m -d "2024-7-15 00:00"
[root@oneday ~]# touch /opt/test/def.txt -m -d "2024-7-14 00:00"
[root@oneday ~]# touch /opt/test/ghi.txt -m -d "2024-7-13 00:00"
[root@oneday ~]# touch /opt/test/xxx.txt -m -d "2024-7-12 00:00"
[root@oneday ~]# touch /opt/test/yyy.txt -m -d "2024-7-11 00:00"
[root@oneday ~]# ls -l /opt/test
总用量 103424
-rw-r--r-- 1 root root 0 7月 15 00:00 abc.txt
-rw-r--r-- 1 root root 0 7月 14 00:00 def.txt
-rw-r--r-- 1 root root 0 7月 13 00:00 ghi.txt
-rw-r--r-- 1 root root 0 7月 12 00:00 xxx.txt
-rw-r--r-- 1 root root 0 7月 11 00:00 yyy.txt
9. 在test⽬录下创建a⽬录
[root@oneday ~]# mkdir /opt/test/a
10. 将以上5个⽂件复制⼀份到a⽬录中
[root@oneday ~]# cp /opt/test/*.txt /opt/test/a
11. 将a⽬录⽂件做成bak.tar.gz⽂件保存到家⽬录中
[root@oneday ~]# tar -czvf ~/bak.tar.gz /opt/test/a
12. 使⽤find删除test⽬录下3天前的⽂件
[root@oneday ~]# find /opt/test -mtime +3 -exec rm -rf {} \;
13. find删除opt⽬录下3天内的⽂件
[root@oneday ~]# find /opt/test -mtime -3 -exec rm -rf {} \;
14. find删除正好第三天的⽂件
[root@oneday ~]# find /opt/test -mtime 3 | xargs rm -rf
15. 将/opt/test/a⽬录中的⽂件复制i⼀份到/opt/test/⽬录下
[root@oneday ~]# cp /opt/test/a /opt/test/
16. 创建⽬录/opt/test0
[root@oneday~]# mkdir /opt/test0
17. 在/opt/test0/⽬录中创建三个⽂件 a.mp4(5M),b.mp4(20M),c.mp4(80M)
[root@oneday ~]# dd if=/dev/zero of=/opt/test0/a.mp4 bs=5M count=1
[root@oneday ~]# dd if=/dev/zero of=/opt/test0/b.mp4 bs=20M count=1
[root@oneday ~]# dd if=/dev/zero of=/opt/test0/c.mp4 bs=80M count=1
[root@oneday ~]# ls -lh /opt/test0/
总用量 105M
-rw-r--r-- 1 root root 5.0M 7月 15 16:23 a.mp4
-rw-r--r-- 1 root root 20M 7月 15 16:23 b.mp4
-rw-r--r-- 1 root root 80M 7月 15 16:24 c.mp4
18. 创建⽬录/opt/test0/b/
[root@oneday ~]# mkdir /opt/test0/b/
19. 将/op t/test0/中的⽂件复制⼀份/opt/test0/b/⽬录中
[root@oneday ~]# cp /opt/test0/*.mp4 /opt/test0/b
20. find查询/opt/test0/⽬录中⽂件⼤于20M的,并删除
[root@oneday ~]# find /opt/test0/ -size +20M -type f -delete
21. find查询/opt/test0/⽬录中⽂件⼩于20M的⽂件并删除
[root@oneday ~]# find /opt/test0/ -size -20M -type f -delete
22. find查找/opt/test0/⽬录中⽂件size为20M的⽂件并删除
[root@oneday ~]# find /opt/test0/ -size 20M -type f -delete
23. /opt/test0/b中的⽂件复制⼀份到/opt/test0中
[root@oneday ~]# cp /opt/test0/b/*.mp4 /opt/test0/
24. 打开新的虚拟主机

25. 将家⽬录中的bak.tar.gz⽂件上传到新主机的/opt⽬录中
[root@oneday ~]# scp /root/*.tar.gz root@192.168.8.141:/opt/
26. 将新主机的/etc/skel/⽬录下载到 当前主机的/opt⽬录中
[root@twoday ~]# scp -r root@192.168.8.136:/etc/skel/ /opt/
27. 设置计划任务,每周3将/etc/yum.repos.d/⽬录下的.repo⽂件压缩保存到tmp,在⽂件名中添加时间戳
[root@oneday ~]# crontab -e
*/1 * * * * /usr/bin/tar -zcvf /tmp/etc-$(date "+\%Y\%m\%d\%H\%M\%S").tar.gz
/etc/yum.repos.d/*.repo