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,
  • -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

Popular posts from this blog

(Solved) (Fixed )MariaDB Unmet Dependencies on Ubuntu 20.04.

Solution to Moodle Error: Coding error detected, it must be fixed by a programmer: Failed to unserialise data from file. Either failed to read, or failed to write.

ACTION_FAILED:OU_INVALID: Solution for GoogleApps bulk user upload issue, username@domainname.com:ACTION_FAILED:OU_INVALID. This error is because you have not specified the Org Unit Path properly.