How do I Compress a directory in Linux?
Using tar command you can compress a directory as follows
syntax: tar -zcvf archive-name.tar.gz directory-name
Where,
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, if you want to compress /home/sjamso/webfiles then the command is:
# tar -zcvf mycompressfile-20-01-11.tar.gz /home/sjamso/webfiles
The above command will create a compress file named mycompressfile-20-01-11.tar.gz in current directory. The compress file will contain all the file in /home, all files in /sjamso and all files in /webfiles
To restore or unzip tar files:
# tar -zxvf mycompressfile-20-01-11.tar.gz
Where -x: Extract files
Comments
Post a Comment