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

Learn how straightforward it’s to create compressed archives from the Linux command line, utilizing zip. Jack Wallen exhibits you the way.


Picture: Jack Wallen

Not too long ago, I confirmed you the right way to create compressed archives from the Linux command-line utilizing the tar command. This time I need to reveal the identical process, however utilizing a software you are most likely already conversant in. The software in query is zip, and it creates compressed zip information from no matter you throw at it. 

SEE: 5 Linux server distributions you have to be utilizing (TechRepublic Premium)

So, for instance you may have the folder TEST and also you need to create the compressed file so you’ll be able to ship it to a colleague. Thankfully, Linux can use the zip software, however first, you might need to put in it with a command like sudo apt-get set up zip -y or sudo dnf set up zip -y

As soon as put in, zip is able to go. Let’s compress that TEST folder. The way you create the zipped file is not fairly so simple as you may assume. The fundamental command is zip NAME (the place NAME is the title of the folder to be compressed). Nonetheless, in the event you merely issued the command zip TEST, you’d wind up with a file named, however after uncompressing it, you’d discover it is lacking the contents. 

Why? Since you solely compressed the folder, not the contents. 

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

SEE: Rust: What builders must learn about this programming language (free PDF) (TechRepublic)

If you problem the command with the -r flag, you may see zip provides each file inside the listing to the compressed file. This time, in the event you decompress the file, with the command unzip, the contents of the listing stay intact. 

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

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise professionals from Jack Wallen.

Additionally see

Recent Articles


Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox