Compress and Extract Files Using the tar Command on Linux
Compress an Entire Directory or a Single File
- -c: Create an archive
- -z: Compress the archive with gzip
- -v: Verbose mode. Display progress in the terminal
- -f: Allows you to specify the filename of the archive.
tar czvf name-of-archive.tar.gz /path/to/directory-or-file /path/to/another-directory-or-file
Exclude Directories and Files
tar czvf name-of-archive.tar.gz /path/to/directory-or-file --exclude=/home/user/folder-to-exclude --exclude=/home/user/file-to-exclude.txt --exclude=*.iso
Extract an Archive
tar -xzvf archive.tar.gz
tar -xzvf archive.tar.gz -C /home/user/extracted
Related
- DD Essentials
- Linux Command Line Text Editors Essentials
- Nano Essentials
- What is Filling up my Disk Space
- How to Create a Command Alias in Linux
- Find Command in Linux
- Displaying Network Statistics in Linux
- Linux IP Essentials
- Linux Routing Essentials
- Simple Public Linux File Share Samba
- Enable IP Forwarding in Linux
- LUKS: Linux Unified Key Setup Essentials
- How to Blank the Screen on a Linux Desktop
- Hostapd Essentials
- IP Tables Essentials
- dnsmasq Essentials
- /etc/ssh/sshd_config Essentials
- YAML Essentials