LINUX - How to Compress a Whole Directory
1.Use the tar command.
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:
If you wish to restore your archive then you need to use the following command
Advanced.
2.Use the zip 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
Post a Comment