0
点赞
收藏
分享

微信扫一扫

linux查找和压缩


linux存储管理(下)

linux查找和压缩

文件查找

命令查找
  • which

which 命令

可以查找已知的命令

which ls

  • 自定义命令

alias ui='ls --color=auto -l'

此时在命令行中按下ui就相当于ls

ui

  • whereis
    查找命令的绝对路径

whereis vim

针对文件名查找

find 路径 选项 描述 动作

  • 按文件名称查找

find /etc -name '6789.txt'

find /etc -iname '6789.txt'

find /etc -iname hos*

  • 按照文件的大小去查找

find /etc/ -size +5M

查找/etc/下的大于5M的文件

find /etc/ -szie -5M

查找小于5M的文件

  • 指定查找的目录的深度

find / -maxdepth 3 -a -name 'idcfg-en*'

  • 按文件的属主

find /home -user jack

  • 按文件的属组查找

find /home -group jack

  • 按文件的类型查找
    f表示普通文件

find /dev/ -type f

b代表块状设备文件

find /dev/ -type b

l代表链接文件

find /etc -type l

  • 按文件的权限查找

find . -perm 644

find . -perm 644 -ls

ls是find的动作。

find . -perm 644 -print

find自带print动作

  • 按找到后处理的动作

find . -perm 714 -delete

查找出来之后删除

find /etc/ -name

find /etc/ -name ifcfg* -ok cp -rvf {} /tmp \;

ok表示的是一种连接符,{}代表的find找到的内容,表示的是一种引用。

依赖数据库查找文件

locate 命令

locate ls

这条命令可以找到很多的数据

文件打包和压缩

打包和压缩

文件打包压缩的命令:

tar 选项 压缩包名称 源文件

tar -f 111.tar etc

打包文件

tar -cf etc.tar  etc

打包文件并且压缩

tar -czf etc-gzip.tar.gz etc

压缩后的文件发现变得更小了。
压缩的原理是去重法,优点是文件的体积变小了,缺点是无法直接使用,需要解压。

tar -cjf etc.tar.bz /etc/

tar -cJf etc.tar.xz /etc/

压缩的文件的体积会变小,但是时间会变长。

解压和解包

tar -xf 1.tar

这样一个压缩包就解开了,解压到当前的路径

tar -tf etc.tar

查看压缩包中有哪些文件和文件夹。
linux软件安装


举报

相关推荐

0 条评论