Quick News Bit

Linux 101: How to create a compressed archive of a folder from the CLI with zip

0

Find out how easy it is to create compressed archives from the Linux command line, using zip. Jack Wallen shows you how.

linuxhero.jpg

Image: Jack Wallen

Recently, I showed you how to create compressed archives from the Linux command-line using the tar command. This time I want to demonstrate the same task, but using a tool you’re probably already familiar with. The tool in question is zip, and it creates compressed zip files from whatever you throw at it. 

SEE: 5 Linux server distributions you should be using (TechRepublic Premium)

So, let’s say you have the folder TEST and you want to create the compressed file TEST.zip so you can send it to a colleague. Fortunately, Linux can use the zip tool, but first, you might have to install it with a command like sudo apt-get install zip -y or sudo dnf install zip -y

Once installed, zip is ready to go. Let’s compress that TEST folder. How you create the zipped file isn’t quite as simple as you might think. The basic command is zip NAME.zip NAME (where NAME is the name of the folder to be compressed). However, if you simply issued the command zip TEST.zip TEST, you’d wind up with a file named TEST.zip, but after uncompressing it, you’d find it’s missing the contents. 

Why? Because you only compressed the folder, not the contents. 

To include the contents of the TEST folder, you’d add the recursive flag, as in zip -r TEST.zip TEST

SEE: Rust: What developers need to know about this programming language (free PDF) (TechRepublic)

When you issue the command with the -r flag, you’ll see zip adds every file within the directory to the compressed file. This time, if you decompress the file, with the command unzip TEST.zip, the contents of the directory remain intact. 

And that’s all there is to creating compressed archives from the Linux Command Line Interface, using the zip tool.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Also see

For all the latest Technology News Click Here 

 For the latest news and updates, follow us on Google News

Read original article here

Denial of responsibility! NewsBit.us is an automatic aggregator around the global media. All the content are available free on Internet. We have just arranged it in one platform for educational purpose only. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials on our website, please contact us by email – [email protected]. The content will be deleted within 24 hours.

Leave a comment