You are here

How can I compress a whole directory under a Linux / UNIX using a shell prompt?

It is very easy to compress a Whole Linux/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:

=> Create the archive

=> Compress the archive

You need to use the tar command as follows (syntax of tar command):
tar -zcvf archive-name.tar.gz directory-name
Where,

  • -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/jerry/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog
Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use the following command (it will extract all files in current directory):
$ tar -zxvf prog-1-jan-2005.tar.gz
Where,

  • -x: Extract files

If you wish to extract files in particular directory, for example in /tmp then you need to use the following command:
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -

A note about non gnu/tar command

The above syntax use GNU tar command for compressing and uncompressing tar files. If your system does not use GNU tar, you can still create a compressed tar file, via the following syntax:
tar -cvf - file1 file2 dir3 | gzip > archive.tar.gz

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.
CesRulley (not verified) - Tue, 03/28/2017 - 21:42

Cialis Pour Femme viagra prescription Human Cephalexin For Dogs Baclofene Nancy Online Levitra Buy Nexium Online Zithromax Rash On Face Vibramycin Online Generic Viagra With American Express On Line Amoxicilina In Internet Overnight Shipping Windsor Best Nolvadex Buy Generic Cialis 20 Mg Buy Amoxicillin Amazon 252 Fast Delivery Viagra Side Effects To Amoxicillin Order Now Doxycycline Dapoxetine Buy Se Puede Comprar Viagra Sin Receta En Espana Kamagra Vendita In Tunisia Buy Cialis Puedo Tomar Viagra Hipertension Viagra Migrana Priligy On Line Comprar Cialis Gibraltar Viagra Compra En Madrid Viagra Online Prices Diabete E Cialis Cialis 5 Mg Le Prix Buy Misoprostol Propecia Ebuddy Impotencia Amoxicillin Kidney Infection Buy Priligy Dapoxetine Online Canadian Healthcare buy roche accutane online uk Buying Lasix Folliculitis Against Amoxicillin

Damian (not verified) - Tue, 05/16/2017 - 15:44

I think this is among the most important info for me. And i'm glad reading
your article. But wanna remark on some general things, The website
style is ideal, the articles is really excellent : D.
Good job, cheers

Also visit my page - fuck it (melissahade.wordpress.com)

Lily (not verified) - Wed, 12/13/2017 - 07:00

cialis pills sale canada

cialis generic

buy cheap viagra and cialis

Bryant (not verified) - Thu, 12/14/2017 - 20:22

buy cialis vs viagra

cialis online

buy cialis in usa

Alexander (not verified) - Fri, 12/29/2017 - 09:59

do need prescription order viagra

online generic viagra

buy viagra uk no prescription

Jerome (not verified) - Sat, 12/30/2017 - 04:38

cheap viagra canada pharmacy

online generic viagra

where can i buy viagra yahoo

Sue (not verified) - Mon, 01/08/2018 - 20:34

can buy viagra dubai

generic viagra

best place to order viagra online

Pilar (not verified) - Tue, 02/13/2018 - 01:35

viagra online order no prescription
viagra without a doctor
buy viagra cheap online uk

Sasha (not verified) - Tue, 01/09/2018 - 23:30

usa viagra cheap info

viagra generique

herb viagra sale

Margart (not verified) - Fri, 02/09/2018 - 13:32

slot online

vegas casino games

new usa online casinos 2017

kasino

online gambling casino

Silvia (not verified) - Fri, 02/09/2018 - 12:13

cheaper viagra cialis levitra
generic cialis 2018
what does cialis pills look like

Pages