Table of contents
Last Blog Review →
In the last blog we understood, the basics of archiving what it does and how archiving is done in Linux using Tar command. Tar command syntax and it’s option which is used to modify the tar command. Later on in coming blogs we will see the use of tar command to archiving files and directories and extracting it.
Linux commands for Archiving files
To create tar archive file
tar -cvf my_archive.tar /home/user/project
To extract the archive file on desired location
tar -xvf my_archive.tar -C /home/user/logs
To extract the archive file on default location
tar -xvf my_archive.tar
To create a tar archive file with compress in size using gzip
tar -czvf my_archive.tar.gz /home/user/project
To extract a compress archive file in gzip
tar -xzvf my_archive.tar.gz
To create a tar archive file with compress in size using bz2
tar -cjvf my_archive.tar.bz2 /home/user/my_folders
To extract a compress archive file in bz2
tar -xjvf my_archive.tar.bz2
To show the file size in human readable format
du -sh /home/user/my_projects
To create a compress archive file in xz
tar -cJvf my_archive.tar.xz /home/user/my_folders
To extract a compress archive file in xz
tar -xJvf my_archive.tar.xz
Conclusion →
In the blog we understood the commands to archive a file using tar in Linux along with different compression techniques.