Extracting .tar.gz file from command line
.tar.gz file represents many compressed files combined together in order to save storage in the system. This is also used when we want to transfer files from one server to another. We can actually make a tarball of all the files which we want and zip them to form a compressed tarball and transfer it using any command like scp.
How to create a tarball
We can use the following command to create a tar file by selecting files
tar –cvzf file1 file 2
- c – instructs tar to create the tarball
- v – list out the files it’s creating, verbose
- z – instructs tar to compress the files
- f – tells tar the filename
If you want to tar a directory use this command
tar –cvzf tarballname foldername
How to extract the files from a tarball.
If you want to extract a tarball to the current path you can use the following command
tar –xvzf tarballname
- x – instructs tar to extract the files from the .gz file
- v – list out the files it’s extracting, verbose
- z – instructs tar to decompress the files
- f – tells tar the filename
If you want to extacr a tarball to any other path,
tar –xvzf tarballname –C path
DevOps Gurukul is one of the best training academies which provides Linux course in Kochi. We have experienced training professionals who are passionate about grooming the right candidates to start their successful careers. Come learn Best online linux training in Kerala with us and have a bright future!