
For Compress files/directory into tar file
tar -czvf file.tar.gz directory
For extract tar files
tar -xzvf file.tar.gz
Understanding tar command options
tar command option | Description |
---|---|
-c | Create a new archive |
-x | Extract files from an archive |
-t | List the contents of an archive |
-v | Verbose output |
-f file.tar.gz | Use archive file |
-C DIR | Change to DIR before performing any operations |
-z | Filter the archive through gzip i.e. compress or decompress archive |
Getting help
Type the following man command:$ man tar
$ tar --help
Zip package is not default with linux, we have to install it on ubuntu.sudo apt install zip
OR
sudo apt install unzip
To create zip
zip -r files.zip files/directory
To unzip
unzip files.zip