find命令
stat命令
文件:"/opt/a.txt"
大小:1048576 块:2048 IO 块:4096 普通文件
设备:fd00h/64768d Inode:33633777 硬链接:1
权限:(0755/-rwxr-xr-x) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:usr_t:s0
最近访问:2024-07-15 11:07:02.660803570 +0800
最近更改:2024-07-15 11:07:02.669803717 +0800
最近改动:2024-07-15 11:07:02.669803717 +0800
创建时间:-
文件:"/opt/dd.txt"
大小:0 块:0 IO 块:4096 普通空文件
设备:fd00h/64768d Inode:33633778 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:usr_t:s0
最近访问:2024-07-15 15:49:22.575937343 +0800
最近更改:2024-07-08 00:00:00.000000000 +0800
最近改动:2024-07-15 15:49:22.575937343 +0800
[root@linux1 ~]# stat /opt/dd.txt
文件:"/opt/dd.txt"
大小:0 块:0 IO 块:4096 普通空文件
设备:fd00h/64768d Inode:33633778 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:usr_t:s0
最近访问:2024-07-15 15:49:22.575937343 +0800
最近更改:2023-05-04 00:00:00.000000000 +0800
最近改动:2024-07-15 15:51:52.586477739 +0800
通过文件的最后修改时间搜索文件
![](https://i-blog.csdnimg.cn/direct/d4b607ec5ef34e4f9367bd4b8d20d24b.png)
![](https://i-blog.csdnimg.cn/direct/3297c211af164c1181b0513f73e2bac5.png)
![](https://i-blog.csdnimg.cn/direct/4d233d10841847119254edd8e8fa5f0c.png)
按照文件size大小进行搜索文件
[root@linux1 ~]# dd if=/dev/zreo of=/opt/a.txt bs=1M count=1
[root@linux1 ~]# ls -lh /opt # 查看文件信息,使用文件大小单位 默认M
总用量 16M
-rw-r--r--. 1 root root 1.0M 7月 15 10:28 a.txt
-rw-r--r--. 1 root root 5.0M 7月 15 10:29 b.txt
-rw-r--r--. 1 root root 10M 7月 15 10:29 c.txt
find 文件路径 -size size值(单位 k M G)
[root@linux1 ~]# find /opt/ -size 5M # 搜索文件大小为5M的文件
/opt/b.txt
[root@linux1 ~]# find /opt/ -size +5M #搜索大于5M的文件
/opt/c.txt
[root@linux1 ~]# find /opt/ -size -5M #搜索小于5M的文件,隐藏文件也找出来了
/opt/ //也能找到隐藏文件
/opt/a.txt
tree命令
tree -L n 显示项目的层级, n表示层级数。 比如想要显示项目三层结构,可以用tree -l 3;[root@linux1 ~]# tree -l 2 /etc
scp命令
scp实现Linux系统和linux之间的克隆操作,实现Linux和Linux之间的文件传输
下载:把数据从远程主机保存到本地主机
scp [选项] 用户名@linux主机地址:/资源路径 linux本地文件路径
从原主机上下载/opt/a.txt到克隆机上的/opt目录
[root@Linux ~]# scp root@192.168.118.50:/opt/a.txt /opt/ //文件
[root@linux1 ~]# mkdir /opt/d0
[root@linux1 ~]# cp /opt/a.txt /opt/d0/
[root@linux1 ~]# cp /opt/b.txt /opt/d0/
[root@linux1 ~]# cp /opt/c.txt /opt/d0/
[root@linux1 ~]# tree /opt
/opt
├── a.txt
├── b.txt
├── c.txt
└── d0
├── a.txt
├── b.txt
└── c.txt
[root@Linux ~]# scp -r root@192.168.118.50:/opt/d0/ /opt/ //目录
root@192.168.118.50's password:
a.txt 100% 1024KB 86.3MB/s 00:00
b.txt 100% 5120KB 74.2MB/s 00:00
c.txt 100% 10MB 137.2MB/s 00:00
[root@Linux ~]# ls /opt
a.txt d0
[root@Linux ~]# chmod +x /opt/d0 -R
[root@Linux ~]# ls /opt/d0
a.txt b.txt c.txt
上传: 把本地文件保存到远程主机
[root@Linux ~]# scp /opt/d0/a.txt root@192.168.118.50:/opt/ //文件
root@192.168.118.50's password:
a.txt 100% 1024KB 97.3MB/s 00:00
[root@Linux ~]# scp -r /opt/d0/ root@192.168.118.50:/opt/ //上传目录时,要加-r,表示递归
root@192.168.118.50's password:
a.txt 100% 1024KB 106.1MB/s 00:00
b.txt 100% 5120KB 73.7MB/s 00:00
c.txt 100% 10MB 104.8MB/s 00:00
[root@linux1 ~]# ls /opt
a.txt d0
计划任务
做日志,自动做事
查看是否存在计划任务 :[root@Linux ~]# crontab -l
![](https://i-blog.csdnimg.cn/direct/4a519fe3522c4c99bc9ca3aeecff4e31.png)
每分钟自动将opt目录中的文件名写到root目录下的list中
[root@Linux ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
[root@Linux ~]# crontab -e #编写计划任务
*/1 * * * * /usr/bin/ls /opt/ >> /root/list
五个*分别表示:分 时 日 月 周(0,7代表星期日)
[root@Linux ~]# vim list
a.txt
d0
[root@Linux ~]# dd if=/dev/zero of=/opt/hhhhh.txt bs=100M count=1 //创建一个100M的文件
[root@Linux ~]# vim list
a.txt
d0
hhhhh.txt
每分钟将/etc/下所有文件打包放到/tmp/目录下
1)找到rar指令的which位置 which tar --------- /usr/bin/tar
2)编写计划任务 crontab -e
时间:
输出时间:[root@linux1 ~]# date "+%T"
17:19:25
输出日期: [root@linux1 ~]# date "+%F"
2024-07-15