The most well-known archive/compression tool in Linux

Source: Internet
Author: User

The most well-known archive/compression tool in Linux

In many cases, sending or receiving large files and images over the Internet is a headache. The compression and decompression tools can solve this problem. Next, let's quickly browse some open-source tools in Linux that make our work easier.

Tar

Tar is derived from 'tape archiver, which is initially used to archive and store files on tapes. Tar is a GNU software that can compress a group of files (archive), extract them, and perform operations on existing archive files. It is useful in storage, backup, and file transfer. When creating an archive file, Tar can keep the original file and directory structure unchanged. The suffix of an object archived through Tar is '.tar '.

The basic usage is as follows:

A) create an archive (c/-- create)
  1. tar --create --verbose --file=archive.tar file1 file2 file3

Or

  1. tar cvf archive.tar file1 file2 file3

Create an archive

B) list the content of an archive object (t/-- list)
  1. tar --list archive.tar

List objects contained in an archive

C) extract archive (x/-- extract)
  1. tar xvf archive.tar
  2. Tar xvf archive.tar -- wildcards '*. c'
    -Extract files with the suffix *. c from the archive.

Extract files

Extract only required files

D) update the archive file (u/-- update)
  1. Tar uvf archive.tar newfile. c
    -If the archived newfile. c is newer than the previously archived newfile. c, add the updated newfile. c to the archive.

Update an archive

E) delete an object from the archive (-- delete)
  1. tar --delete-f archive.tar file1.c
  2. -Delete the file 'file1. c' from the compressed package 'archive.tar'

Delete an object

For more details, refer to the tar homepage.

Gzip/Gunzip

Gzip is GNU zip. It is a widely used compressed application in the Linux operating system. The suffix of the compressed file is '*. gz '.

The basic usage is as follows:

A) compressed file
  1. gzip file(s)

Each file is compressed separately.

Compressed file

After compression is complete, it will delete the original file. We can use-cTo retain the original file.

  1. gzip -c file > file.gz

Retain the original file after compression

We can also compress a group of files into a single file.

  1. cat file1 file2 file3 | gzip > archieve.gz

Compressing a group of Files

B) Check the compression ratio

You can use the '-l' option to check the compression ratio of the compressed file.

  1. gzip -l archieve.gz

Check compression rate

C) decompress the file

Gunzip is used to extract files. Here, the original (Compressed) files are also deleted after being decompressed. Use-cTo retain the original file.

  1. gunzip -c archieve.gz

Decompress the file

Gzip + '-d' option and gunzip have the same effect on compressed files.

For more details, see the gzip homepage.

Bzip2/Bunzip2

Like gzip, Bzip2 is also a compression tool. Compared with other traditional tools, Bzip2 can compress files to a smaller size, but its disadvantage is that it is slower than gzip.

The basic usage is as follows:

A) compressed file

In general, Bzip2 does not need any options for compression, so it will pass the compressed file as its parameter. Each file is compressed separately, and the compressed file is suffixed with 'bz2.

  1. bzip2 file1 file2 file3

File compression

You can use the '-k' option to retain the original file after compression or decompression.

Retain the original file after compression

B) decompress the package

The '-d' option is used for decompression.

Use the-d option to decompress the file

You can also use bunzip2 for decompression.

  1. bunzip2 filename

Decompress the file

Bunzip2 can decompress files with the suffix bz2, bz, tbz2, and tbz. After the files with tbz2 and tbz are compressed, the suffix will be changed to '.tar '.

  1. bzip2 -dc
  2. -Decompress the file to the standard output.
7-zip

7-zip is another open source compression software. It adopts the new compression format 7z and supports high compression ratio. Therefore, it is considered to be a better software than the previously mentioned compression tool. In Linux, you can use the p7zip package, which contains three binary files: 7z, 7za, and 7zr, you can refer to p7zip wiki to learn about the differences between the three binary files. In this article, we will use 7zr to explain 7-zip usage. The archive file is suffixed with '.7z.

How to install 7zip in Linux

The basic usage is as follows:

A) create an archive
  1. 7zr a archive-name.7z file-name(s)/ directory-name(s)

Create an archive file

B) List Archived Files
  1. 7zr l archive-name.7z

List objects contained in an archive

C) extract archive files
  1. 7zr e archive-name.7z

Extract Archive

D) Update the archive file
  1. 7zr u archive-name.7znew-file

Update an archive file

E) delete an object from an archive object
  1. 7zr d archive-name.7z file-to-be-deleted

Delete an object

Confirm File Deletion

Decompress RAR and 7Z files in Ubuntu 12.10

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.