常用压缩
- gzip(不能压缩目录)
- bzip2(不能压缩目录)
- tar
tar
语法
tar 命令 压缩后文件名 压缩文件位置
命令
第一组
- -c create 创建 create a new archive 创建压缩
- -t list 列表 list the contents of an archive 查看压缩包
- -x extract 提取 extract files from an archive 从压缩包提取文件 解压缩
上面3个选项中 都不可以共同使用
第二组(可选)
- -z gzip 通过gzip方式进行过滤(压缩,查看压缩包,解压)
- -j bzip2 通过bzip2方式进行过滤(压缩,查看压缩包,解压)
上面2个选项中 不可以共同使用
第三组
- -v 显示文件详情 可选的,不要也可以
- -f 文档名称 ,必选
- -C 改变目录 指定解压文件位置。不加这个默认加压到当前目录下
实际使用
压缩文件
tar -cvf demo.tar.gz /root/demo
查看文件
tar -tf demo.tar.gz /root/demo
解压文件
tar -xvf demo.tar.gz /root/demo