1. 使⽤ls查看/etc/⽬录下所有的⽂件信息
[root@localhost ~]# ls -l /etc/
总用量 1312
-rw-r--r--. 1 root root 16 7月 12 02:29 adjtime
-rw-r--r--. 1 root root 1518 6月 7 2013 aliases
-rw-r--r--. 1 root root 12288 7月 12 02:42 aliases.db
drwxr-xr-x. 2 root root 4096 7月 11 21:30 alternatives
-rw-------. 1 root root 541 4月 11 2018 anacrontab
-rw-r--r--. 1 root root 55 4月 11 2018 asound.conf
drwxr-x---. 3 root root 43 7月 12 02:27 audisp
drwxr-x---. 3 root root 83 7月 12 02:42 audit
drwxr-xr-x. 2 root root 33 7月 11 20:08 bash_completion.d
…
2. 使⽤ls查看/etc/⽬录下名包含“a”字⺟的⽂件或者⽬录信息
[root@localhost ~]# ls -l /etc/ | grep a
-rw-r--r--. 1 root root 16 7月 12 02:29 adjtime
-rw-r--r--. 1 root root 1518 6月 7 2013 aliases
-rw-r--r--. 1 root root 12288 7月 12 02:42 aliases.db
drwxr-xr-x. 2 root root 4096 7月 11 21:30 alternatives
-rw-------. 1 root root 541 4月 11 2018 anacrontab
-rw-r--r--. 1 root root 55 4月 11 2018 asound.conf
drwxr-x---. 3 root root 43 7月 12 02:27 audisp
drwxr-x---. 3 root root 83 7月 12 02:42 audit
drwxr-xr-x. 2 root root 33 7月 11 20:08 bash_completion.d
-rw-r--r--. 1 root root 2853 4月 11 2018 bashrc
-rw-r--r--. 1 root root 38 4月 29 2018 centos-release
-rw-r--r--. 1 root root 51 4月 29 2018 centos-release-upstream
3. 使⽤ls查看/etc/⽬录下以".conf"结尾的⽂件信息
[root@localhost ~]# ls -l /etc/ | grep .conf$
-rw-r--r--. 1 root root 55 4月 11 2018 asound.conf
-rw-r--r--. 1 root root 1108 4月 13 2018 chrony.conf
-rw-r--r--. 1 root root 1285 4月 11 2018 dracut.conf
-rw-r--r--. 1 root root 112 4月 11 2018 e2fsck.conf
-rw-r--r--. 1 root root 38 4月 11 2018 fuse.conf
-rw-r--r--. 1 root root 842 11月 6 2016 GeoIP.conf
-rw-r--r--. 1 root root 9 6月 7 2013 host.conf
-rw-r--r--. 1 root root 7265 7月 12 02:27 kdump.conf
-rw-r--r--. 1 root root 590 4月 11 2018 krb5.conf
-rw-r--r--. 1 root root 28 2月 28 2013 ld.so.conf
-rw-r-----. 1 root root 191 10月 12 2017 libaudit.conf
-rw-r--r--. 1 root root 2391 10月 13 2013 libuser.conf
-rw-r--r--. 1 root root 19 7月 12 02:29 locale.conf
4. 使⽤ls查看/etc/⽬录中以"y"字⺟开头的⽂件信息
[root@localhost ~]# ls -l /etc/ | grep ^y
5. find查找/var/⽬录中以“.log”⽂件
[root@localhost ~]# find /var/ -type f -name '*.log'
/var/log/tuned/tuned.log
/var/log/audit/audit.log
/var/log/anaconda/anaconda.log
/var/log/anaconda/X.log
/var/log/anaconda/program.log
/var/log/anaconda/packaging.log
/var/log/anaconda/storage.log
/var/log/anaconda/ifcfg.log
/var/log/anaconda/ks-script-ua9yku.log
/var/log/anaconda/ks-script-zomTMx.log
/var/log/anaconda/journal.log
/var/log/boot.log
/var/log/vmware-vmsvc.log
/var/log/yum.log
/var/log/mysqld.log
6. 在opt⽬录下创建test⽬录
[root@localhost ~]# mkdir /opt/test
7. 在test⽬录中创建abc.txt,def.txt.ghi.txt,xxx.txt.yyy.txt五个⽂件
[root@localhost ~]# 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@localhost ~]# touch -m -d '2024-7-15 00:00' /opt/test/abc.txt
[root@localhost ~]# touch -m -d '2024-7-14 00:00' /opt/test/def.txt
[root@localhost ~]# touch -m -d '2024-7-13 00:00' /opt/test/ghi.txt
[root@localhost ~]# touch -m -d '2024-7-12 00:00' /opt/test/xxx.txt
[root@localhost ~]# touch -m -d '2024-7-11 00:00' /opt/test/yyy.txt
9. 在test⽬录下创建a⽬录
[root@localhost ~]# mkdir /opt/test/a
10. 将以上5个⽂件复制⼀份到a⽬录中
[root@localhost ~]# cp /opt/test/*.txt /opt/test/a/
[root@localhost ~]# ls /opt/test/a
abc.txt def.txt ghi.txt xxx.txt yyy.txt
11. 将a⽬录⽂件做成bak.tar.gz⽂件保存到家⽬录中
[root@localhost ~]# tar -zcvf bak.tar.gz /opt/test/a
12. 使⽤find删除test⽬录下3天前的⽂件
[root@localhost ~]# find /opt/test/ -mtime +3 -exec rm -rf {} \;
[root@localhost ~]# ls /opt/test/
a abc.txt def.txt ghi.txt xxx.txt
13. find删除opt⽬录下3天内的⽂件
find /opt/ -type f -mtime -3 -exec rm -rf {} \;
14. find删除正好第三天的⽂件
find /opt/ -type f -mtime 3 -exec rm -rf {} \;
15. 将/opt/test/a⽬录中的⽂件复制i⼀份到/opt/test/⽬录下
cp -r /opt/test/a/ /opt/test/
16. 创建⽬录/opt/test0
mkdir /opt/test0
17. 在/opt/test0/⽬录中创建三个⽂件 a.mp4(5M),b.mp4(20M),c.mp4(80M)
[root@kk test0]# dd if=/dev/zero of=/opt/test0/a.mp4 bs=5M count=1
记录了1+0 的读入
记录了1+0 的写出
5242880字节(5.2 MB)已复制,0.00789588 秒,664 MB/秒
[root@kk test0]# dd if=/dev/zero of=/opt/test0/b.mp4 bs=20M count=1
记录了1+0 的读入
记录了1+0 的写出
20971520字节(21 MB)已复制,0.0454609 秒,461 MB/秒
[root@kk test0]# dd if=/dev/zero of=/opt/test0/c.mp4 bs=80M count=1
记录了1+0 的读入
记录了1+0 的写出
83886080字节(84 MB)已复制,0.180239 秒,465 MB/秒
18. 创建⽬录/opt/test0/b/
[root@kk test0]# mkdir /opt/test0/b
19. 将/op t/test0/中的⽂件复制⼀份/opt/test0/b/⽬录中
[root@kk test0]# cp -r /opt/test0/ /var/test0/
[root@kk test0]# cp -r /var/test0 /opt/test0/b/
cp:是否覆盖"/opt/test0/b/test0/a.mp4"? y
cp:是否覆盖"/opt/test0/b/test0/b.mp4"? y
cp:是否覆盖"/opt/test0/b/test0/c.mp4"? y
20. find查询/opt/test0/⽬录中⽂件⼤于20M的,并删除
[root@kk test0]# find /opt/test0/ -type f -size +20M -exec rm -rf {} \;
21. find查询/opt/test0/⽬录中⽂件⼩于20M的⽂件并删除
[root@kk test0]# find /opt/test0/ -type f -size -20M -exec rm -rf {} \;
22. find查找/opt/test0/⽬录中⽂件size为20M的⽂件并删除
[root@kk test0]# find /opt/test0/ -type f -size 20M -exec rm -rf {} \;
23. /opt/test0/b中的⽂件复制⼀份到/opt/test0中
[root@kk test0]# cp -r /opt/test0/b/ /opt/test0/
24. 打开新的虚拟主机
25. 将家⽬录中的bak.tar.gz⽂件上传到新主机的/opt⽬录中
scp /bak.tar.gz root@192.168.2.188:/opt/
26. 将新主机的/e tc/skel/⽬录下载到 当前主机的/opt⽬录中
scp -r root@192.168.2.188:/etc/skel /opt/
27. 设置计划任务,每周3将/e tc/yum.repos.d/⽬录下的.repo⽂件压缩保存到tmp,在⽂件
名中添加时间戳