Linux gtar命令教程,包括示例和与Tar的比较

Linux provides gtar command in order to compress and create tar files. If we are trying to tar a directory and within this directory, there will be a lot of sub-directories and files. We need to tar this directory with tar format. We can use gtar which is an alias of the tar command to create tar archives.

Linux提供gtar命令以压缩和创建tar文件。 如果我们尝试将目录压缩到该目录中,则该目录中将包含许多子目录和文件。 我们需要将该目录以tar格式tar 。 我们可以使用gtar它是tar命令的别名)来创建tar归档文件。

为Ubuntu,Debian,Mint,Kali安装 (Install For Ubuntu, Debian, Mint, Kali)

We can install tar command with the following command.

我们可以使用以下命令安装tar命令。

$ sudo apt install tar
Install For Ubuntu, Debian, Mint, Kali
Install For Ubuntu, Debian, Mint, Kali
为Ubuntu,Debian,Mint,Kali安装

安装Fedora,RedHat,CentOS(Install Fedora, RedHat, CentOS)

We can install tar for Fedora, RedHat, CentOS with dnf or yum command like below.

我们可以使用dnfyum命令为Fedora,RedHat,CentOS安装tar ,如下所示。

$ sudo yum install tar

OR

要么

$ sudo dnf install tar

创建Tar存档 (Create Tar Archive)

We can create new tar file by using cvf options like below. We will provide the directory name or path and also provide the newly created archive file with .tar extension. We will tar the directory with the nmap to the nmap.tar

我们可以使用cvf选项创建新的tar文件。 我们将提供目录名称或路径,并提供新创建的扩展名为.tar存档文件。 我们将带有nmap的目录tar到nmap.tar

$ tar -cvf nmap.tar nmap
Create Tar Archive
Create Tar Archive
创建Tar存档

提取Tar存档(Extract Tar Archive)

We can extract a tar archive with the xvf option like below. We will just provide the name of the tar archive which is nmap.tar in this case.

我们可以使用xvf选项提取tar存档,如下所示。 在这种情况下,我们仅提供tar存档的名称为nmap.tar

$ tar -xvf nmap.tar

用Gzip压缩Tar存档 (Compress Tar Archive with Gzip)

We can create a tar archive which is also compressed by using Gzip compression algorithm. We will just provide the -z option to the default tar creation options. We will create tar.gz gzip compressed archive from the directory nmap in this example.

我们可以创建一个tar归档文件,该归档文件也可以使用Gzip压缩算法进行压缩。 我们仅将-z选项提供给默认的tar创建选项。 在此示例中,我们将从目录nmap创建tar.gz gzip压缩存档。

$ tar cvzf nmap.tar.gz nmap
Compress Tar Archive with Gzip
Compress Tar Archive with Gzip
用Gzip压缩Tar存档

使用Bzip压缩Tar存档(Compress Tar Archive with Bzip)

Bzip is another compression algorithm which can be used to compress tar files to use less storage. We will provide extra -j  option to the xvf like below.

Bzip是另一种压缩算法,可用于压缩tar文件以减少存储量。 我们将为xvf提供额外的-j选项,如下所示。

$ tar cvjf nmap.tar.bz  nmap
LEARN MORE  How To Install Tar.Gz or Tar.Bz2 Application Source Code?
了解更多信息如何安装Tar.Gz或Tar.Bz2应用程序源代码?

翻译自: https://www.poftut.com/linux-gtar-command-tutorial-with-examples-and-compare-with-tar/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值