tar
To extract a tar file, run
1 |
tar xf file.tar.gz |
Uncompress tar.gz file
1 |
tar -zxvf ncftp-3.2.2-src.tar.gz |
Uncompress tar.bz2 file
1 |
tar -jxvf ncftp-3.2.2-src.tar.bz2 |
Create a tar file
1 |
tar -cvf file.tar FOLDER_OR_FILE_NAME |
Example
1 |
tar -cvf backup.tar public_html |
Once backup.tar file is created, you can make it tar.gz with command
1 |
gzip backup.tar |
Exclude a folder from tar file
To exclude a folder, you can use –exclude option.
1 |
tar cvf backup.tar --exclude=public_html/uploads --exclude=public_html/wordpress public_html |
List content of a tar file
1 |
tar --list --verbose --file=BACKUP.tar.gz |
If you want to exclude a folder from the file list, use
1 |
tar --list --verbose --file=BACKUP.tar.gz --exclude=home/haridy/Maildir |
This will exclude all files that are inside folder “home/haridy/Maildir”. You can use multiple –exclude if required.
Using tar over SSH Session
Split Large file into smaller files
How to view the contents of tar.gz file