LINUX - How to Compress a Whole Directory

1.Use the tar command.

tar -zcvf archive-name.tar.gz directory-name

  • -z : Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name

For example, say you have a directory called /home/admin/workspace and you would like to compress this directory then you can type tar command as follows:


$ tar -zcvf src.tar.gz /home/admin/workspace

If you wish to restore your archive then you need to use the following command


$ tar -zcvf src.tar.gz /home/admin/workspace
  • -x: Extract files

Advanced.

tar -jcvf src.tar.bz2 /home/admin/workspace  # even more compression

#change the -c to -x to above to extract

2.Use the zip command.


$ zip -r file-name.zip /path/to/directory
$ unzip file-name.zip

Comments

Popular posts from this blog

Python3 + Django + uWSGI + Nginx On FreeBSD

arduino最小構成 (atmega328/8MHz/3.3V/内部クロック)FT232RLにてブートローダーの書き込み

FreeBSD: Configuring Apache to permit CGI