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

2 years ago 297

Find retired however casual it is to make compressed archives from the Linux bid line, utilizing zip. Jack Wallen shows you how.

linuxhero.jpg

Image: Jack Wallen

Recently, I showed you however to make compressed archives from the Linux command-line utilizing the tar command. This clip I privation to show the aforesaid task, but utilizing a instrumentality you're astir apt already acquainted with. The instrumentality successful question is zip, and it creates compressed zip files from immoderate you propulsion astatine it. 

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

So, let's accidental you person the folder TEST and you privation to make the compressed record TEST.zip truthful you tin nonstop it to a colleague. Fortunately, Linux tin usage the zip tool, but first, you mightiness person to instal it with a bid similar sudo apt-get instal zip -y oregon sudo dnf instal zip -y

Once installed, zip is acceptable to go. Let's compress that TEST folder. How you make the zipped record isn't rather arsenic elemental arsenic you mightiness think. The basal bid is zip NAME.zip NAME (where NAME is the sanction of the folder to beryllium compressed). However, if you simply issued the bid zip TEST.zip TEST, you'd upwind up with a record named TEST.zip, but aft uncompressing it, you'd find it's missing the contents. 

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

To see the contents of the TEST folder, you'd adhd the recursive flag, arsenic successful zip -r TEST.zip TEST

SEE: Rust: What developers request to cognize astir this programming connection (free PDF) (TechRepublic)

When you contented the bid with the -r flag, you'll spot zip adds each record wrong the directory to the compressed file. This time, if you decompress the file, with the bid unzip TEST.zip, the contents of the directory stay intact. 

And that's each determination is to creating compressed archives from the Linux Command Line Interface, utilizing the zip tool.

Subscribe to TechRepublic's How To Make Tech Work connected YouTube for each the latest tech proposal for concern pros from Jack Wallen.

Open Source Weekly Newsletter

You don't privation to miss our tips, tutorials, and commentary connected the Linux OS and unfastened root applications. Delivered Tuesdays

Sign up today

Also spot

Read Entire Article