一、查找文件
1、which
查看可执行文件(即命令)的位置
输入命令
[root@localhost /]# which ls

2、locate
配合数据库查看文件位置
3、find
输入命令
[root@localhost /]# find /tmp -iname "file*"
按文件命查找 (i是不区分大小写的意思)

输入命令
[root@localhost /]# find /etc -size +10M
按文件大小查找

按文件路径深度查找
输入命令
[root@localhost /]# find / -maxdepth 4 -a -name "ifcfg-en*"

按文件属组属主查找
输入命令
[root@localhost /]# find /home -user user1
[root@localhost /]# find /home -group hr


按文件类型查找
输入命令
[root@localhost /]# find /dev -type b

按文件权限查找
输入命令
[root@localhost ~]# find . -perm 644 -ls

查询系统中文件名为ifcfg-ens33的文件,并通过管道拷贝至/tmp目录。
输入命令
[root@localhost ~]# find / -name "ifcfg-ens33" -exec cp {} /tmp \;

二、文件压缩及解压
1.文件打包
1.普通压缩
输入命令
[root@localhost ~]# tar -cf etc.tar /etc

输入命令
[root@localhost ~]# tar -czvf etc.tar-gz /etc
此种方式为显示压缩过程

3.
输入命令
[root@localhost ~]# tar -cJf etc.tar.bz /etc


2.文件解压
输入命令
[root@localhost ~]# tar -xf etc.tar

本文详细介绍Linux系统下使用which、locate和find命令进行高效文件查找的方法,包括按文件名、大小、路径深度、属主、类型和权限查找。同时,讲解如何利用tar命令进行文件打包和解压,涵盖不同压缩格式的使用。
1024

被折叠的 条评论
为什么被折叠?



