.tar.gz file on Linux, run tar -xzf archive.tar.gz. Add -C /path/to/folder to extract somewhere else, and -v to list each file as it unpacks. To create one, run tar -czf backup.tar.gz folder/. For .zip files, use unzip archive.zip to extract and zip -r archive.zip folder/ to create.
Before you start
- Connect with SSH.
tarandgzipare installed on every Linux server.zip,unzipandzstdmay need installing:
- Ubuntu / Debian
- AlmaLinux / Rocky
- Check you have enough free space for the unpacked files with
df -h.
How to extract a tar.gz file
1
Look inside first (optional)
2
Extract it
3
Or extract into another folder
What the tar letters mean
Modern GNU tar detects the compression when extracting, so
tar -xf file.tar.xz also works.
How to extract other archive types
How to extract only one file
tar -tzf lists it.
How to create a tar.gz archive
For website or app backups, run
tar with sudo so it can read every file, and stop or pause databases first. Copy database data with a dump tool instead; see back up and restore MySQL databases.How to zip and unzip files
.zip when the archive goes to Windows users. Use .tar.gz for Linux servers: it keeps file permissions and owners.
How to check it worked
List the archive and compare the file count with the source:gzip -t site-backup.tar.gz tests the archive for damage and prints nothing when it is fine.
Frequently asked questions
What does “gzip: stdin: not in gzip format” mean?
The file isn’t really gzip-compressed, often because the download saved an HTML error page. Check withfile archive.tar.gz. If it says POSIX tar archive, extract with tar -xf (no z).
How do I extract a .tar.gz file to a specific directory?
Use-C: tar -xzf file.tar.gz -C /path/to/folder. Create the folder first with mkdir -p.
How do I remove the top folder when extracting?
Add--strip-components=1: tar -xzf wordpress.tar.gz -C /var/www/example.com --strip-components=1 puts the contents of wordpress/ straight into the target.
How do I make a password-protected archive?
zip -e secret.zip file asks for a password, but zip encryption is weak. For backups, use a tool built for encryption such as restic.
Related guides
VPS and dedicated server guides
Every server guide in one place.
Back up a Linux server
Plan proper backups.
Copy files with scp and rsync
Move archives between servers.
Check disk space
Make room before extracting.
Checked against the official GNU tar manual and the Info-ZIP
zip and unzip manuals on 4 November 2026; commands tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026