61-Archive Files

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Archive Files:

An archive file is a collection of files and directories that are stored in one file. The archive file is
not compressed it uses the same amount of disk space as all the individual files and directories
combined. Archives are commonly used for backups, transferring files & package distribution.
An archive file is not compressed, but a compressed file can be an archive file.

TAR Command:
Tar stand for Tape Archiver. The tar program is used to create, maintain, modify, and extract
files that are archived in the tar format. This is a good way to create backups and archives. The
tar command does not compress the files by default. Archiving and compressing files are useful
when creating backups and transferring data across a network. A leading - is not required for
tar options it can work with - or without -.

Tar Commands Description


# tar -cvf filename.tar File Create archive for one file
# tar -cvf filename.tar File1 File2 File3 Create archive for more than one files
# tar -cvf filename.tar dir1 Create archive for directory
# tar cvf archive.tar file1 file2 Create archive without using – dash
# tar -c -f archive.tar file1 file2 Different way to create archive for files
# tar -tvf filename.tar To list the contents of a tar file
# tar -rvf filename.tar file3 Add to file or directory to archive
# tar -xvf filename.tar To extract the contents of a tar file
# tar -xzvf filename.tar.gz -C /tmp Extract files to a specific directory or path
# tar -cjvf filename.tbz2 file Create bzip2 compressed tar file
# tar -xjvf filename.tbz2 Extract bzip2 compressed tar file
# tar -czvf filename.tgz file Create gzip compressed tar file
# tar -xzvf filename.tgz Extract gzip compressed tar file
# tar -cJvf filename.txz file Create xz compressed tar file
# tar -xjvf filename.txz Extract xz compressed tar file

1 | P a g e Created by Ahmad Ali E-Mail: [email protected] , WhatsApp: 00966564303717


TAR Options:
Options indicates which operation executes on the files (creation, extraction, etc.). Following it
the list of options available with tar command.

Tar's Options Description


-c Create a new archive (Create)
-j Compress the tar file with bzip2
-z Compress the tar file with gzip
-J Compress the tar file with xz
-x Extract files from an archive (Extract)
-v Displays Verbose Information (Verbose)
-t Lists the contents of an archive (Contents)
-f File name of the archive to work on (File Name)
-u Archives and adds to an existing archive file
-A Concatenates the archive files
-w Verify an archive file.
-C Change the extracted files Location (Change)
-r It is used to update file or directory in already existing .tar file

2 | P a g e Created by Ahmad Ali E-Mail: [email protected] , WhatsApp: 00966564303717

You might also like