Skip to content

Instantly share code, notes, and snippets.

@xiaoysh8
Created June 5, 2018 07:04
Show Gist options
  • Save xiaoysh8/ef24944a3d574a5c2916e287ccb299ff to your computer and use it in GitHub Desktop.
Save xiaoysh8/ef24944a3d574a5c2916e287ccb299ff to your computer and use it in GitHub Desktop.
linux tar
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
Here’s what those switches actually mean:
-c: Create an archive.
-z: Compress the archive with gzip.
-v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f: Allows you to specify the filename of the archive.
tar -czvf archive.tar.gz /home/ubuntu --exclude=/home/ubuntu/Downloads --exclude=/home/ubuntu/.cache
tar -czvf archive.tar.gz /home/ubuntu --exclude=*.mp4
tar -xzvf archive.tar.gz -C /tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment