一、简介
tar命令是Unix/Linux系统中备份文件的可靠方法,几乎可以工作于任何环境中,它的使用权限是所有用户。建议针对目录
二、压缩:语法tar 选项 压缩包名称 源文件
[root@localhost ~]# tar -cf etc.tar /etc
[root@localhost ~]# tar -czvf etc-gzip.tar.gz /etc/
[root@localhost ~]# tar -cjf etc-bzip.tar.bz /etc/
[root@localhost ~]# tar -cJf etc-xzip.tar.xz /etc/
[root@localhost ~]# tar -cvf home.tar /home //打包
tar: 从成员名中删除开头的“/”
/home/
/home/yonghu/
/home/yonghu/.mozilla/
/home/yonghu/.mozilla/extensions/
/home/yonghu/.mozilla/plugins/
/home/yonghu/.bash_logout
/home/yonghu/.bash_profile
/home/yonghu/.bashrc
/home/1.txt
/home/file2-h2
/home/file222-1
[root@localhost ~]# ls
anaconda-ks.cfg **home.tar** 公共
asd.ttx initial-setup-ks.cfg 模板
bbb installer 视频
etc 图片
etc-bzip.tar.bz 文档
etc-gzip.tar.gz metasploit-latest-linux-x64-installer.run 下载
etc.tar metasploit-latest-linux-x64-installer.run.1 音乐
etc-xzip.tar.xz msfinstall
[root@localhost ~]# tar -xf home.tar //解压
[root@localhost ~]# ls //查看
anaconda-ks.cfg **home** pub
asd.ttx home.tar 公共
bbb initial-setup-ks.cfg 模板
etc installer 视频
etc-bzip.tar.bz 图片
etc-gzip.tar.gz 文档
etc.tar metasploit-latest-linux-x64-installer.run 下载
etc-xzip.tar.xz metasploit-latest-linux-x64-installer.run.1 音乐
file2 msfinstall 桌面
三、解压
查看压缩文件:tar -tf +压缩包名
解压:tar -xf +压缩包名
解压:tar -xf +压缩包名 -C +指定存放目录
1.解压gzip压缩包
[root@localhost ~]# ls
anaconda-ks.cfg installer 模板
asd.ttx bbb 视频
etc-bzip.tar.bz metasploit-latest-linux-x64-installer.run 文档
**etc-gzip.tar.gz** metasploit-latest-linux-x64-installer.run.1 下载
etc-xzip.tar.xz msfinstall 音乐
file2 pub 桌面
initial-setup-ks.cfg 公共
[root@localhost ~]# tar -xf etc-gzip.tar.gz //解压
[root@localhost ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg 公共
asd.ttx installer 模板
bbb **etc** 视频
图片
etc-bzip.tar.bz metasploit-latest-linux-x64-installer.run 文档
etc-gzip.tar.gz metasploit-latest-linux-x64-installer.run.1 下载
etc-xzip.tar.xz msfinstall 音乐
file2 pub 桌面
2.解压文件指定存放·
[root@localhost ~]# tar xf etc-bzip.tar.bz -C /root/bbb
[root@localhost ~]# ls /root/bbb
apps etc