Learn how to create, extract, and list files within a compressed tar archive in Secure Shell (SSH), or cPanel Terminal, with the tar command.
- Create an archive
- Extract Files
- List Archived Files
Want to spend more time working on your website than setup? Check out our Shared Business Hosting with Softaculous Instant Installer and WP-CLI included.
Create an Archive
tar -czvf archive-name.tar.gz path-to-directory-or-files
Example: tar -czvf images.tar.gz *.png – Archive all PNG image files in the current directory into a images.tar.gz file
Example: tar -czvf backup.tar.gz * – Archive all files and folders in the current directory into a backup.tar.gz file
-c – create -z – compress or decompress -v – list files processed -f – specify filename
Extract Files
tar -xzvf archive.tar.gz
Example: tar -xzvf images.tar.gz
Used options:
-x – Extract -z – compress or decompress -v – list files processed -f – specify filename
Extract to Another Directory
tar -xzvf archive.tar.gz -C another-folder
Example: tar -xzvf images.tar.gz -C restored – Extract files from the images.tar.gz file into an existing /restored folder
Used options:
-x – Extract -z – compress or decompress -v – list files processed -f – specify filename -C – Specify directory
List Files
tar -tvf archive.tar.gz
Used options:
-t – list files processed -v – list files processed (with more info including file size and date modified) -f – specify filename
For more options, type the tar --help command or visit GNU.org.
Discover more from WIREDGORILLA
Subscribe to get the latest posts sent to your email.


