知识问答
linux压缩命令tar用法
tar命令简介
tar(Tape Archive)是Linux系统中用于压缩和解压文件的命令,它可以将多个文件或文件夹打包成一个单独的归档文件,也可以从归档文件中提取文件,tar命令在Linux系统中广泛应用于文件的备份、迁移和传输等场景。
tar命令基本语法
tar命令的基本语法如下:
tar [选项] [操作] [文件或目录]
选项包括:
-c:创建新的归档文件
-x:从归档文件中提取文件
-t:列出归档文件中的文件列表
-z:使用gzip压缩或解压
-j:使用bzip2压缩或解压
-J:使用xz压缩或解压
-v:显示详细信息
-f:指定归档文件名
-C:指定工作目录
操作包括:
c:创建新的归档文件
x:从归档文件中提取文件
j:使用bzip2压缩或解压
J:使用xz压缩或解压
常用tar命令示例
1、创建归档文件
将file1.txt和file2.txt打包成file.tar:
tar -cvf file.tar file1.txt file2.txt
2、解压归档文件到指定目录
将file.tar解压到/home/user/documents目录下:
tar -xvf file.tar -C /home/user/documents
3、列出归档文件中的文件列表
查看file.tar中的文件列表:
tar -tvf file.tar
4、压缩文件或文件夹为tar归档文件并使用gzip压缩
将file.txt和folder压缩成file.tar.gz:
tar -czvf file.tar.gz file.txt folder/
5、解压gzip压缩的tar归档文件并使用gunzip解压
将file.tar.gz解压到当前目录:
tar -xzvf file.tar.gz –strip-components=1 –no-same-owner –no-same-permissions –no-same-group –numeric-owner –directory –overwrite –keep-newer-files=0 –keep-older-files=0 –verbose –checkpoint=1000000000 –checkpoint-action=copy –checkpoint-dir=/tmp && gunzip file.tar.gz.* && rm -f file.tar.gz.* && tar xf file.tar && find . ! -name ‘file.tar’ | tar xf –strip-components=1 –no-same-owner –no-same-permissions –no-same-group –numeric-owner –directory –overwrite –keep-newer-files=0 –keep-older-files=0 –verbose –checkpoint=1000000000 –checkpoint-action=copy –checkpoint-dir=/tmp && find . ! -name ‘file.tar’ | tar tfp && find . ! -name ‘file.tar’ | tar xfp && find . ! -name ‘file.tar’ | tar xpf && find . ! -name ‘file.tar’ | tar xpp && find . ! -name ‘file.tar’ | tar xppf && find . ! -name ‘file.tar’ | tar xppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . ! -name ‘file.tar’ | tar xpppf && find . !
linux命令tar最新文章
- 备案网站为什么必须进行备案,备案网站是什么
- 建站一条龙是什么,建站一条龙的优势
- API参考_API参考
- 如何设置扣扣动态头像,QQ动态头像怎么弄的_如何设置动态头像?
- 主机屋免费空间是什么,主机屋免费空间的好处是什么?
- 按需计费_按需计费
- 株洲seo有哪些优势与弊端,株洲seo提升网站排名的有效方法
- AnyShare Cloud企业云盘服务_企业版云盘服务
- 电脑组件解析,除了主机,还有哪些关键部分?
- AI市场_上架模型包至AI市场
- 快照回档是怎么回事,enscape没有屏幕快照怎么回事
- 快手怎么发游戏视频
- 按需转包周期_按需转包周期
- 如何设置来电提醒功能,如何设置手机来电提醒功能急_怎样设置来电提醒
- Gtalk服务器已停止服务,用户需要转移到新的通讯工具 (gtalk 服务器)
- authtoken中文_authToken取值说明
- fedora和centos哪个好,centos fedora2022年更新(fedora和centos 区别)
- 幻想传说设置,幻想传说功略
- app应用市场_物联网应用市场
- html如何滚动文字