-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhow do I Compress a Directory.txt
37 lines (28 loc) · 1.45 KB
/
how do I Compress a Directory.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
How do I Compress a Whole Linux or UNIX Directory?
You need to use 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, you have 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 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 -
-------------------------------------------------------------------------------------