Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use tarball Packaging tool under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use tarball packaging tool under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Tarball is the most convenient packaging tool under linux. It uses the tar instruction to package and compress files.

How to create tarball on Linux

Using the following command, you can create a tarball and compress it in a single command.

$tar-cvzf PDFs.tar.gz * .pdf

The result is a compressed file (gzip compressed) that contains all the PDF files in the current directory. Of course, compression is optional. A slightly simpler command that simply packages the PDF file into an uncompressed tarball:

$tar-cvf PDFs.tar * .pdf

Notice that z in the option makes the file compressed. C indicates that the file is created, and v (detailed) indicates that you need some feedback while the command is running. If you do not want to view the listed files, please ignore v.

Another common naming convention is to name the compressed tarball .tgz instead of the double extension .tar.gz, as follows:

$tar cvzf MyPDFs.tgz * .pdf

How to extract files from tarball

To extract all files from the gzip package, you can use the following command:

$tar-xvzf file.tar.gz

If you use the .tgz naming convention, the command will look like this:

$tar-xvzf MyPDFs.tgz

To extract a single file from the gzip package, you can do almost the same thing by adding the file name:

$tar-xvzf PDFs.tar.gz ShenTix.pdfShenTix.pdfls-l ShenTix.pdf-rw-rw-r-- 1 shs shs 122057 Dec 14 14:43 ShenTix.pdf

If you don't compress tarball, you can even delete files from tarball. For example, if we wanted to delete the files we extracted above from PDFs.tar.gz, we would do this:

$gunzip PDFs.tar.gz$ ls-l PDFs.tar-rw-rw-r-- 1 shs shs 10700800 Dec 15 11:51 PDFs.tar$ tar- vf PDFs.tar--delete ShenTix.pdf$ ls-l PDFs.tar-rw-rw-r-- 1 shs shs 10577920 Dec 15 11:45 PDFs.tar

Notice that after deleting ShenTix.pdf, we reduced the space occupied by the tarball file a little bit. If we want, we can compress the file again:

$gzip-f PDFs.tarls-l PDFs.tar.gz-rw-rw-r-- 1 shs shs 10134499 Dec 15 11:51 PDFs.tar.gzFlickr / James St. John

The rich command line options make tarball easy to use.

Thank you for reading this article carefully. I hope the article "how to use tarball Packaging tool under Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report