tar#
Tar files are just a collection of files and/or folders, compression is optional.
Command Line Options#
Create a tar file of the /home/username folder#
tar -cvf user-backup-17-11-2023.tar /home/username
c Creates a new archive v Enables verbose output f Allow the user to specify the output tar filename
Extract a tar file#
tar xvf user-backup.tar
x Extracts the contents of the tar file
Extract a tar file to a specific folder#
tar xvf user-backup.tar --directory=myFolder
Compressing when creating a tar#
-j –bzip2 - Use bzip compression -z –gzip - Use gzip compression -J –xz - Use xz compression –zstd - Use zstd compression
Extract a specfic file or files from an archive#
tar -xvf Phpfiles-org.tar.bz2 full/path/of/file/in/archive.txt
tar -xvf Phpfiles-org.tar.bz2 file1 file2