Jump to content

Ubuntu:Create archive tar: Difference between revisions

From Wiki
Created page with "Say you want to compress an entire directory named <code>/home/vivek/data/</code>, then type: <syntaxhighlight lang="shell"> tar -czvf file.tar.gz /home/kangtain/data/ </syntaxhighlight> To compress multiple directories and files, execute: <syntaxhighlight lang="shell"> tar -czvf file.tar.gz /home/kangtain/data/ /home/kangtain/pics/ /home/kangtain/.accounting.db </syntaxhighlight> One can use <code>bzip2</code> compression instead of <code>gzip</code> by passing the..."
 
No edit summary
 
Line 27: Line 27:
==Source==
==Source==
*[https://www.cyberciti.biz/faq/how-to-tar-a-file-in-linux-using-command-line/ cyberciti.biz]
*[https://www.cyberciti.biz/faq/how-to-tar-a-file-in-linux-using-command-line/ cyberciti.biz]
[[Category:Linux]]
[[Category:Ubuntu]]
[[Category:Tutorial]]
[[Category:Debian]]

Latest revision as of 05:28, 3 November 2022

Say you want to compress an entire directory named /home/vivek/data/, then type:

tar -czvf file.tar.gz /home/kangtain/data/

To compress multiple directories and files, execute:

tar -czvf file.tar.gz /home/kangtain/data/ /home/kangtain/pics/ /home/kangtain/.accounting.db

One can use bzip2 compression instead of gzip by passing the -j option to the tar command:

tar -cjvf file.tar.bz2 /home/vivek/data/

Where,

  • -c : Create a new archive
  • -v : Verbose output
  • -f file.tar.gz : Use archive file
  • -z : Filter the archive through gzip
  • -j : Filter the archive through bzip2

Source