Author : Piyush Gupta
Archive files and directories In Linux, There are multiple tools available in Linux system for creating archive files. In this article we will see how to archive files and directories using tar, zip and gzip command.
Archive files and directories In Linux, There are multiple tools available in Linux system for creating archive files. In this article we will see how to archive files and directories using tar, zip and gzip command.
Below is the most common programs to archive files and directories are;
- zip
- tar
- gzip
1 – Zip
zip is the most popular command line archiving utility for Linux systems. zip program comes pre-installed with some Linux distros. Just in case if it is not available, you can install it using the distribution’s default package manager.
On Arch Linux and variants:
On RHEL, CentOS, Fedora:
On Debian, Ubuntu, Linux Mint:
On SUSE/openSUSE:
Now let us see some examples.
Create Archive of File
Create Archive of Directory
Extract Archive
2 – Tar
Tar is an Unix command which stands for Tape Archive. It is used to combine or store multiple files (same or different size) into a single file. There are 4 main operating modes in tar utility.
- c – Create an archive from a file(s) or directory(s).
- x – Extract an archive.
- r – Append files to the end of an archive.
- t – List the contents of the archive.
Create Archive of File
Create Archive of Directory
Extract Archive
3 – gzip
gzip is a utility to compress and decompress files using Lempel-Ziv coding (LZ77) algorithm.
gzip is one more tool for command line users for making archive files. gzip also supports to take input of data as standard input or through pipe and create zip file.
Create Archive of File
Create zip file of piped data
Extract Archive
Combined – Tar + gzip
Tar also combined gzip program to enable higher compression level of files. Using tar with gzip created files extension will be .tar.gz.
No comments:
Post a Comment