1.
使⽤
ls
查看
/etc/
⽬录下所有的⽂件信息
[root@localhost ~]# ls /etc
2.
使⽤
ls
查看
/etc/
⽬录下名包含
“a”
字⺟的⽂件或者⽬录信息
[root@localhost ~]# ls /etc/*a*
3.
使⽤
ls
查看
/etc/
⽬录下以
".conf"
结尾的⽂件信息
[root@localhost ~]# ls /etc/*.conf
4.
使⽤
ls
查看
/etc/
⽬录中以
"y"
字⺟开头的⽂件信息
[root@localhost ~]# ls /etc/y*
5. find
查找
/var/
⽬录中以
“.log”
⽂件
[root@localhost ~]#find /var/ -name "*.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
[root@localhost ~]#touch /opt/test/def.txt
[root@localhost ~]# touch /opt/test/ghi.txt
[root@localhost ~]# touch /opt/test/xxx.txt
[root@localhost ~]#touch /opt/test/yyy.txt
8.
修改以上
5
个⽂件的最后修改时间分别为
15
,
14
,
13
,
12
,
11
,
10
⽇
touch -m -d "2024-7-15 00:00" /opt/test/abc.txt
touch -m -d "2024-7-14 00:00" /opt/test/def.txt
touch -m -d "2024-7-13 00:00" /opt/test/ghi.txt
touch -m -d "2024-7-12 00:00" /opt/test/xxx.txt
touch -m -d "2024-7-11 00:00" /opt/test/yyy.txt
touch -m -d "2024-7-13 00:00" /opt/test/ghi.txt
touch -m -d "2024-7-12 00:00" /opt/test/xxx.txt
touch -m -d "2024-7-11 00:00" /opt/test/yyy.txt
9.
在
test
⽬录下创建
a
⽬录
mkdir /opt/test/a
10.
将以上
5
个⽂件复制⼀份到
a
⽬录中
cp /opt/test/*.txt /opt/test/a/
11.
将
a
⽬录⽂件做成
bak.tar.gz
⽂件保存到家⽬录中
tar -zcvf ~/bak.tar.gz -C /opt/test/a
12.
使⽤
find
删除
test
⽬录下
3
天前的⽂件
13. find
删除
opt
⽬录下
3
天内的⽂件
find /opt/test -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 /opt/test/a/*.txt /opt/test/
16.
创建⽬录
/opt/test0
mdkir /opt/test0
17.
在
/opt/test0/
⽬录中创建三个⽂件
a.mp4(5M),b.mp4(20M),c.mp4(80M)
dd if=/dev/zero of=/opt/test0/a.mp4 bs=5M count=1
dd if=/dev/zero of=/opt/test0/b.mp4 bs=20M count=1
dd if=/dev/zero of =/opt/test0/c.mp4 bs=80M count=1
dd if=/dev/zero of=/opt/test0/b.mp4 bs=20M count=1
dd if=/dev/zero of =/opt/test0/c.mp4 bs=80M count=1
18.
创建⽬录
/opt/test0/b/
mkdir /opt/test0/b
19.
将
/op t/test0/
中的⽂件复制⼀份
/opt/test0/b/
⽬录中
cp /opt/test0/*.mp4 /opt/test0/b/
20. find
查询
/opt/test0/
⽬录中⽂件⼤于
20M
的,并删除
find /opt/test0 -size +20M -exec rm -rf {}\;
21. find
查询
/opt/test0/
⽬录中⽂件⼩于
20M
的⽂件并删除
find /opt/test0 -size -20M -exec rm -rf {}\;
22. find
查找
/opt/test0/
⽬录中⽂件
size
为
20M
的⽂件并删除
find /opt/test0 -size 20M -exec rm-rf {}\;
23. /opt/test0/b
中的⽂件复制⼀份到
/opt/test0
中]
cp /opt/test0/b/*.mp4 /opt/test0/
24.
打开新的虚拟主机
25.
将家⽬录中的
bak.tar.gz
⽂件上传到新主机的
/opt
⽬录中
scp ~/bak.tar.gz root@192.168.10.129:/opt/
26.
将新主机的
/e tc/skel/
⽬录下载到 当前主机的
/opt
⽬录中
scp -r root@192.168.10.128:/etc/skel /opt/
27.
设置计划任务,每周
3
将
/e tc/yum.repos.d/
⽬录下的
.repo
⽂件压缩保存到
tmp
,在⽂件
名中添加时间戳
crontab-e
* * * * */3 /usr/bin/tar -zcvf /etc/yum.repos.d/*.repo/tmp-$(date "+\%Y\%m\%d\%H\%M\%S").tar.gz
* * * * */3 /usr/bin/tar -zcvf /etc/yum.repos.d/*.repo/tmp-$(date "+\%Y\%m\%d\%H\%M\%S").tar.gz