打包压缩与搜索命令

打包压缩与搜索命令

  • tar

    tar命令用于对文件进行打包压缩或解压,格式为:tar [选项] [文件]

    参数作用
    -c创建压缩文件
    -x解开压缩文件
    -t查看压缩包内有哪些文件
    -z用Gzip压缩或解压
    -j用bzip2压缩或解压
    -v显示压缩或解压过程
    -f目标问价名
    -p保留原始的权限与属性
    -P使用绝对路径来压缩
    -C指定解压到的目录

    压缩过程:

    [root@zhufanyu ~]# tar -czvf linux_1.tar.gz linux_1.txt
    

    解压过程:

    [root@zhufanyu ~]# tar xzvf linux_1.tar.gz /etc
    
  • grep

    grep 命令用于在文本中执行关键词搜索,并显示匹配结果,格式为:grep [选项] [文件]

    参数作用
    -b将可执行文件(binary)当做文本文件(text)来搜索
    -c仅显示找到的行数
    -i忽略大小写
    -n显示行号
    -v反向选择–仅列出没有“关键词的行”
    [root@zhufanyu ~]# grep /sbin/nologin /etc/passwd
    bin:x:1:1:bin:/bin:/sbin/nologin
    daemon:x:2:2:daemon:/sbin:/sbin/nologin
    adm:x:3:4:adm:/var/adm:/sbin/nologin
    lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
    mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
    
    
  • find

    find 命令用于按照指定条件来查找文件,格式为:find [查找路径] 寻找条件 操作

    参数作用
    -name匹配名称
    -perm匹配权限(mode为完全匹配,-mode为包含即可)
    -user匹配所有者
    -group匹配所有组
    -mtime -n +n匹配修改内容的时间(-n指定n天以内, +n指n天以前)
    -atime -n +n匹配访问文件的时间(-n指n天以内,+n指n天以前)
    -ctime -n +n匹配修改文件权限的时间(-n指n天以内,+n指n天以前)
    -nouser匹配无所有者的文件
    -nogroup匹配无所有组的文件
    -newer f1 !f2匹配比文件f1新但比f2旧的文件
    –type b/d/c/p/l/f匹配文件的类型(后面的字母参数依次表示块设备、目录、字符设备、管道、连接文件、文本文件)
    -size匹配文件的大小(+50KB为查找超过50KB的文件,而-50KB为查找小于50KB的文件)
    -prune忽略某个目录
    -exec ······ {} ;后面可跟用于进一步处理搜索结果的命令
    [root@zhufanyu ~]# find /etc -name "host*" -print
    /etc/host.conf
    /etc/hosts
    /etc/cloud/templates/hosts.redhat.tmpl
    /etc/cloud/templates/hosts.suse.tmpl
    /etc/cloud/templates/hosts.freebsd.tmpl
    /etc/cloud/templates/hosts.debian.tmpl
    /etc/hostname
    
    
    [root@zhufanyu ~]# find / -perm -4000 -print
    find: ‘/proc/17946/task/17946/fd/6’: No such file or directory
    find: ‘/proc/17946/task/17946/fdinfo/6’: No such file or directory
    find: ‘/proc/17946/fd/5’: No such file or directory
    find: ‘/proc/17946/fdinfo/5’: No such file or directory
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值