Tar is the best tool to pack an archive and Gzip is the most widely used archive type when using Linux and this is a short tutorial on how to do it.
Creating a tar.gz archive
tar pczf archive.tar.gz /home/document
This command would create archive.tar.gz from all the files in found in /home/document.
p - preserving the attributes of the files
c - creating the archive
z - using gzip
f - using a file name
Extracting a tar.gz archive
tar xzf archive.tar.gz -C /home/document
This command would extract archive.tar.gz to the document folder.
x - extract command
z - extract using gzip
f - file name mentioned
C - the directory in which it should be extracted. Not adding it would make it extract it in the current directory.
Adding v (verbose) would list all the files and directories getting extracted during the process as well.
If you want to extract just one file out of the archive, you just need to add it at the end:
tar xzfv archive.tar.gz file.txt
- 0 Users Found This Useful
Related Articles
How to run MTR to diagnose network issues
MTR is a network diagnostic tool that combines traceroute and ping utilities. It enables system...
Finding files via SSH
Finding files and content in the command line can be tricky sometimes, but with a bit know...
SSH connection to MySQL
Connecting to your MySQL server via SSH can be very useful for developers and system admins and...
Using Putty to connect via SSH
Connecting to your Linux server via SSH is usually done via Putty at...
Using grep to search inside files
One very important tool that Unix provides is the grep command, which processes files line by...