Five Best Linux Command Line archiving tools
In our daily work, archive files on various platforms may be Windows, Mac, or Linux. Several applications can be used to create and decompress archive files on all platforms. Speaking of working on the Linux platform, we need to process archive files very frequently.
Linux Command Line archiving Tool
In this article, we will discuss the archive tools, features, and instances available for the standard Linux release. This article is divided into two parts, each of which introduces five command line archiving tools, that is, a total of ten best Linux Command Line tools ).
What is archive
An archive file is a compressed file consisting of one or more computer files and metadata.
Archiving features
- Data Compression
- Encryption
- File Union
- Automatic Decompression
- Automatic Installation
- Source volume and media information
- File spanning
- Checksum
- Directory structure information
- Other metadata about data)
- Error discovery
Application fields
- Stores computer file systems and metadata.
- Applicable to local file transfer.
- It is suitable for transferring files over the Internet.
- Software packaging applications.
The practical archive application software on the standard Linux release includes the following:
1. tar command
Tar is a standard archiving application software tool for UNIX/Linux. In the early stages, it used to be a tape archiving software, and then gradually developed into a General Archive software package that can process various types of archive files. Tar can accept many archive filters with options.
Tar Option
- -A: add the tar file to the end of the existing archive.
- -C: Create a new archive file.
- -D: Use the specified file system to compare archives.
- -J: compress and archive with bzip.
- -R: add the file to the end of the existing archive.
- -T: list existing archived content.
- -U: update the archive.
- -X: Extract files from existing archives.
- -Z: Compressed and archived with gzip.
- -Delete: delete an object from an existing archive.
Tar instance
Create a tar archive file.
- # tar -zcvf name_of_tar.tar.gz /path/to/folder
Decompress the tar archive file.
- # tar -zxvf Name_of_tar_file.tar.gz
For more details, see the article "18 Tar command instances in Linux": http://www.tecmint.com/18-tar-command-examples-in-linux /.
2. shar command
Shar indicates the shell archive. This is a shell script. You can execute this script to create a document. Shar is a self-extracting archive file, an old-fashioned utility that requires a Unix Bourne shell to decompress the file. Shar has the advantage of using plain text, but it may be dangerous because it outputs executable files.
Shar options
- -O: Save the output to the archive file specified in the option.
- -L: restrict the size of the output file specified in the option, but do not split the input file.
- -L: limit the size of the output file specified in the option, but separate the input file.
- -N: add the archive name to the header of the shar file.
- -A: allows automatic file header generation.
Note: If the "-l" or "-L" option is used, the "-o" option is used. If the "-a" option is used, the "-n" option is required.
Shar instance
Create a shar archive file.
- # shar file_name.extension > filename.shar
Decompress the shar archive file.
- # unshar file_name.shar
3. ar command
Ar is a utility used to create and process archives. It is mainly used for binary object file libraries. Ar represents an archiving tool that can be used to archive all types of archives for any purpose, but has basically been replaced by tar. Now, it is only used to create and update static library files.
Ar options
- -D: delete a module from the archive.
- -M: a Member in the mobile archive.
- -P: displays the content of the specified archive member.
- -Q: add quickly.
- -R: inserts file members into the archive.
- -S: adds an index to an archive.
- -A: Add a new file to an existing archive member.
Ar instance
Use the "ar" tool to create an archive. The static library is "libmath. a", and the two object files are "substraction" and "division", as shown below.
- # ar cr libmath.a substraction.o division.o
Decompress the "ar" archive file.
- # ar x libmath.a
4. cpio
Cpio indicates Copy in and out to Copy the input and output ). Cpio is a common file archiving tool for Linux. It is actively used by the Red Hat Software Package Manager RPM) and is an important archive tool in the initramfs initial RAM File System of the Linux kernel, or the Installation Tool pax of apple.
Cpio options
- -0: read the list of file names terminated by null characters instead of line breaks.
- -A: reset the access time.
- -A: add it to an existing archive.
- -B: Exchange.
- -D: create a directory.
Cpio instance
Create a "cpio" archive file.
- # cd tecmint
- # ls
- file1.o file2.o file3.o
- # ls | cpio -ov > /path/to/output_folder/obj.cpio
Decompress the cpio archive file.
- # cpio -idv < /path/to folder/obj.cpio
5. gzip
Gzip is a standard and widely used utility for File compression and decompression. Gzip allows the Union of files. Use gzip to compress the file and you can get the tarball package file in the format of "* .tar.gz" or "*. tgz.
Gzip options
- -Stdout: Write the output to the standard output device.
- -To-stdout: Write the output to the standard output device.
- -Decompress: decompress the file.
- -Uncompress: Decompress the file.
- -D: Decompress the file.
- -F: forcible compression/decompression.
Gzip instance
Create a "gzip" archive file.
- # tar -cvzf name_of_archive.tar.gz /path/to/folder
Decompress the "gzip" archive file.
- # gunzip file_name.tar.gz
After executing the preceding command, you must execute the following command.
- # tar -xvf file_name.tar
Note: Due to the architecture and functions of gzip, it is difficult to restore damaged tar archive files processed by gzip. Therefore, we recommend that you back up several important files processed with gzip in different places.
So much is introduced for the moment. In the next article, we will introduce the Linux-oriented compression and decompression application software. Stay tuned.
Http://www.tecmint.com/command-line-archive-tools-for-linux/.