Skip to content

Instantly share code, notes, and snippets.

@matheus-santos
Last active September 24, 2015 17:14
Show Gist options
  • Save matheus-santos/3c3683c867dd1c034838 to your computer and use it in GitHub Desktop.
Save matheus-santos/3c3683c867dd1c034838 to your computer and use it in GitHub Desktop.
Managing tar files
tar stores relative paths by default. GNU tar even says so if you try to store an absolute path:
# Create .tar file (with gzip)
tar -zcvf foo.tar /home/foo
# Have a look at what's in the tar file:
tar -tvf foo.tar
# Extracting file from tar file
tar -xvf foo.tar home/foo/bar # Note: no leading slash
# Simulating absolute paths
tar -C / -xvf foo.tar home/foo/bar # -C is the ‘change directory’ option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment