Jan 2016 - tar

From Jacksonville Linux Users Group
Jump to: navigation, search
  • things you need to know:
-cvf  (create, verbose, file) 
-tvf  ('table of contents', verbose, file)
-xvf  (extract, verbose, file)
z (use gzip compression)
j (use bzip2 compression)
p (preserve permssions. default by root)
  • proper usage to create a tarball:
tar -cvf backup.tar /foo/bar/*
tar -cvzf backup.tgz /foo/bar/*
tar -cvjf backup.tbz /foo/bar/*
  • Before extracting, make sure you know what is in the tarball!!! (i.e. did they use absolute paths which could hose your system???)
tar -tv[jz]f backup.ext
  • proper usage to extract a tarball:
tar -xv[zj]f backup.ext
  • Use tar to copy a directory tree over the network!
 tar -cvf – /data | ssh otherhost tar -xvf –
 [root@CentOS7cacti ~]# tar -cvf - objects/ | ssh amanda-server tar -xvf -