You need to use tar command as follows (syntax of tar command):
tar -zcvf [ํŒŒ์ผ๋ช….tar.gz] [์••์ถ•ํ•˜๊ณ ์žํ•˜๋Š”ํŒŒ์ผ/๋””๋ ‰ํ† ๋ฆฌ ๋ช…]
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, you have directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:

/home/jerry/prog ํด๋” ๋ฐ ํ•˜์œ„ ํด๋”์— ์žˆ๋Š” ๋ชจ๋“  ํŒŒ์ผ์„ prog.tar.gz ๋กœ ์••์ถ•
$ tar -zcvf prog.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 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 following command:

์›ํ•˜๋Š” ์œ„์น˜์— ์••์ถ•์„ ํ’€๊ณ ์ž ํ•  ๋•Œ
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -

 

 

 

์ถœ์ฒ˜ : http://www.cyberciti.biz/faq/how-do-i-compress-a-whole-linux-or-unix-directory/