Archive
File compression is a fundamental task in managing and transferring data efficiently on a Linux system.
An archive file is a compressed file that contains one or more files bundled together for more accessible storage and portability.

Archiving commands in Linux are tools used to package and compress one or multiple files or directories into a single archive file.
The most commonly used archiving commands in Linux include tar, gzip, zip, and rar.
Understanding Archiving Commands in Linux
Archiving commands in Linux are a set of tools used to create, manage, and extract archive files.
These tools allow users to package one or more files or directories into a single archive file, compress the data, and store it in an organized and efficient manner.
They help to reduce the overall size of files and directories, making them easier to transfer and store.
common archiving commands in Linux
tar
Used to create, manage, and extract tar archives. Tar stands for “tape archive,” which refers to its origins as a tool for backing up data to tape drives.
gzip
Used to compress and decompress files using the gzip compression algorithm. Gzip is commonly used in conjunction with tar to create tarballs, which are tar archives that have been compressed with gzip.
zip
Used to create, manage, and extract zip archives. Zip is a popular archive format that is supported by many operating systems.
rar
Used to create, manage, and extract rar archives. Rar is a proprietary archive format that supports compression, spanning, and error recovery.
Basic Archiving Commands
tar command
tar -cvf file.tar /path/to/folderThis command creates a tar archive called file.tar from the contents of the directory located at /path/to/folder
tar -xvf file.tarThis command extracts the contents of the file.tar archive into the current directory.
gzip commands
gzip file.txtThis command compresses a file called file.txt and replaces it with a compressed file called file.txt.gz.
gunzip file.txt.gzThis command decompresses a file called file.txt.gz and replaces it with a decompressed file called file.txt.
zcat file.txt.gzThis command displays the contents of a compressed file called file.txt.gz on the terminal without extracting it.
zless file.txt.gzThis command allows you to view the contents of a compressed file called file.txt.gz in a more user-friendly way.
zip commands
zip archive.zip file1.txt file2.txtThis command creates a new zip archive called archive.zip and adds two files called file1.txt and file2.txt to it.
unzip archive.ziprar commands
rar a archive.rar file1.txt file2.txtThis command creates a new rar archive called archive.rar and adds two files called file1.txt and file2.txt to it.
unrar x archive.rarThis command extracts the contents of the archive.rar file into the current directory.
Last updated