How To Archive Directory In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Using the Tar Command:
Open the terminal and navigate to the directory where the folder you want to archive is located.
Type the following command to archive a directory named “myfolder” and its contents into a single compressed file named “myfolder.tar.gz”:
tar -zcvf myfolder.tar.gz myfolder/
The options used in the command are:
-z: Compress the archive with gzip
-c: Create a new archive
-v: Verbose output
-f: Specify the filename of the archive
2. Using the Zip Command:
Open the terminal and navigate to the directory where the folder you want to archive is located.
Type the following command to archive a directory named “myfolder” and its contents into a single compressed file named “myfolder.zip”:
zip -r myfolder.zip myfolder/
The options used in the command are:
-r: Recursively add all files and subdirectories
-f: Specify the filename of the archive