Skip to content

5000+ Great Articles

Best Articles & Essays: Interesting Articles to Read Online

  • How to Enable Dark Mode Everywhere on Windows 10 Windows 10
  • How to Fix a Wi-Fi Doesn’t Have a Valid IP Configuration Error in Window 10 Help Desk
  • how to access a windows network folder from my mac How-To
  • how to calculate electricity bill from meter reading in pakistan

    how to calculate electricity bill from meter reading in pakistan.If you’ve ever received a high energy bill, it might be time to learn how to read y

  • Where To Find Themes For Google Slides

    Besides PowerPoint, Google Slides templates can get it from here. Google Slides has grown in popularity over the past few years and is not going to

  • How To Find & Upgrade 32-Bit Apps On Your Mac OS X
  • How do I color a specific area in Procreate? technology
  • Things You Should Know About Flipkart Affiliate Program How-To

Create and Edit Zip Files In Linux Using The Terminal

Posted on October 9, 2020 By blog_786 No Comments on Create and Edit Zip Files In Linux Using The Terminal

In the previous article, we covered in detail how to use the tar command to create archives. While tar is a very common compression scheme for Linux, it is not as popular with Windows and Mac OS X users who find that most of their archives are created using the zip format.

On Linux, it is easy to use Zip archives (for creation) and Unzip (for extension). In fact, most GUI archive management programs (such as Ark, File Roller, and Xarchiver) will act as an interface to almost any command line archiving program installed on your computer, and Zip is no exception. Of course, we can also use Zip from the Terminal. Here’s how.

As you may have guessed, the first step is to open the Terminal.

Then enter “sudo apt-get install zip unzip” (without quotes) to make sure zip and unzip are installed.

– /

Note. If these two programs are already installed, you will receive a message stating that it is, as shown above.

Once installed, we can use zip to create archives (or modify existing ones) and unzip to expand them to the originals. For this tutorial, we’ll create a new folder on the desktop called Stuff. In Terminal we can do this with a single command – mkdir / home / username / Desktop / Stuff (of course you will replace “username” with your own username as shown below, and if you already have a Stuff folder on your desktop you will want change name).

Now that we have a Stuff folder, we will use the “cd” command to make the Stuff folder our current working directory.

cd / home / username / Desktop / Stuff

Now enter touch doc1.txt doc2.txt doc3.txt && mkdir Files into your Terminal, which will create a folder named Files, as well as three documents – doc1.txt, doc2.txt and doc3.txt – inside the Stuff folder.

Another command, “cd” to the newly created cd Files folder, because we need other documents inside it.

cd files

Finally, enter touch doc4.txt doc5.txt doc6.txt to create three new documents.

Now enter cd ./ . to return the desktop to the working directory.

Our penultimate step before creating the zip file is to create a couple of “additional” documents on the desktop with the same names as the files we just created, so type touch doc2.txt doc3.txt to create them.

Finally, open each of the two “additional” text files and add text to them. It doesn’t have to be anything meaningful (or lengthy), just so we can see that these documents are indeed different from those already created in the Stuff and files folders.

Once that is done, we can start creating our ZIP files. The easiest way to use zip is to tell it the name of the zip archive you want to create, and then explicitly name each file that should be in it. So, assuming our working directory is the Desktop, we have to enter zip test Stuff / doc1.txt Stuff / doc2.txt Stuff / doc3.txt to create an archive named test.zip (we don’t need to use “.zip “” In the command, since it will be added automatically), which will contain the files doc1.txt, doc2.txt and doc3.txt located inside the Stuff folder.

You will see a small output that tells us that three documents (doc1.txt, doc2.txt, and doc3.txt) have been added to the archive.

We can check this by double-clicking the archive that should be on our desktop. This should open it in a standard archiving program (Ark in KDE, File Roller in GNOME, and Xarchiver in Xfce).

What about the Files folder? Assuming we want this, add the documents inside it to our archive, we could use the same command as above, but add Stuff / Files / * to the end of the command.

An asterisk means all contents of the folder are included. So if there was another folder inside the Files folder, it would also be added. However, if there are items in this folder, they will not be included. For this we need to add -r (which means recursive or recursive).

It should be noted that the above two commands are not intended to “add” files to a zip archive; they are created to create it. However, since the archive already exists, the command simply adds any new files to the existing archive. If we wanted to create this archive all at once (instead of the three steps we followed to gradually add files to it for educational purposes), we could simply enter zip -r test Stuff / * and create the same archive.

From the command and output, you will notice that there are three files inside the Stuff folder included, as well as three documents inside the Files folder, so everything was done with a nice and simple command.

What about those two “additional” documents that we created on our desktop? Zip works like this: if you try to add a file to an archive that already exists in the archive, the new files will overwrite the old ones. So, since the documents we created on our desktop (doc2.txt and doc3.txt) have content (we added hello world to doc2.txt and cheers to doc3.txt), we should have possibility to add these documents and then you can check it. First, we’ll drag the two “extra” documents into the Stuff folder.

You will probably be asked if you want new documents to replace existing ones (remember that this is in a folder, not a zip archive), so let that happen.

Now that this is done, let’s add them to the archive by typing zip test Stuff / doc2.txt Stuff / doc3.txt

You will notice that the above command now shows that files are being updated rather than added. If we check the archive now, we will notice that the files look the same, but when doc2.txt and doc3.txt are open, you will see that they now have content, not empty ones like in our original files. were.

Sometimes on Linux, you can see that some files are hidden by adding a period (“.”) To the beginning of the file name. This is especially true for configuration files that should exist but are often not visible (which reduces clutter and also reduces the chances of accidentally deleting the configuration file). We can add them to the zip file quite easily. First, let’s say we want to create a zip file named backup from every file in the directory. We can do this by typing zip backup * in Terminal.

This will add all files and folders, although no items in that folder will be included. To add them, we would add -r again so that zip -r backup * would be the command.

Now we are almost there. To add folders, files and hidden files recursively, the command is actually very simple: zip -r backup.

Now it’s pretty easy to unpack. However, before we do anything else, delete the documents on the desktop (doc2.txt and doc3.txt) as well as the Stuff folder. When they disappear by typing unzip test.zip, the contents of our original zipped archive will be moved to your current directory.

Note. If we hadn’t deleted the documents, we would have tried to unzip the contents of our zip file into an existing file, so you will be asked if we want to replace each document.

And it’s all! Compressing and unzipping is a fairly common task, and while there are certainly GUI options available, with practice you will find that performing the same tasks from Terminal is also not very difficult.

–

Share this:

  • Twitter
  • Facebook
Linux Tips

Post navigation

Previous Post: Use Alternate DNS Servers In Windows For Faster Internet
Next Post: Shutdown and Restart Your Computer From The Ubuntu Terminal

Related Posts

  • Convert Images Between Formats via the Command Line in Ubuntu Linux Tips
  • BSD vs Linux: The Basic Differences Linux Tips
  • How to Take a Linux System Benchmark Linux Tips
  • How to Uninstall Ubuntu in a Windows 10 Dual-Boot System Linux Tips
  • How to Find, Download, and Install Custom Icons in Linux Linux Tips
  • Use MSStyles to Theme Wine Applications In Linux Linux Tips

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • March 2021
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • December 2019
  • July 2019
  • May 2019
  • April 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018

Categories

  • AI Tools & Guides
  • Amazon Web Services
  • Apple Watch
  • Computer Tips
  • Cool Websites
  • Featured Posts
  • Free Software Downloads
  • Gadgets
  • Gaming
  • General Software
  • Google Software/Tips
  • Hardware
  • Help Desk
  • How-To
  • iOS
  • iPad
  • iPhone
  • islamic Books
  • Linux
  • Linux Tips
  • Mac OS X
  • macOS
  • MS Office Tips
  • Networking
  • Office Tips
  • OS X
  • Product Reviews
  • Reviews
  • Safari
  • Smart Home
  • Smartphones
  • Software Reviews
  • technology
  • text
  • Tools Review
  • Troubleshooting
  • Tutorials
  • Uncategorized
  • Urdu Books PDF
  • Web Site Tips
  • Windows
  • Windows 10
  • Windows 7
  • Windows XP Tips
  • Wordpress
  • 5 Cool Websites to Find Good Movies and TV Shows on Netflix
  • SmartDNS vs VPN – What’s the Difference?
  • How to go Back to the old YouTube Layout (2017)
  • A Simple Trick to Get 50% Discount on Audible for Three Months
  • What Is “Other” Storage on Android And How to Clean It Up ?
DMCA.com Protection Status

Recent Posts

  • 5 Cool Websites to Find Good Movies and TV Shows on Netflix
  • SmartDNS vs VPN – What’s the Difference?
  • How to go Back to the old YouTube Layout (2017)
  • A Simple Trick to Get 50% Discount on Audible for Three Months
  • 6 Best PayPal Alternatives (2017)

Recent Comments

  1. A Simple Trick to Get 50% Discount on Audible for Three Months on Private Browsing: What is it and What it is not
  2. 6 Best PayPal Alternatives (2017) on How to Save Money While Shopping Online in India
  3. Automatically Transcribe YouTube Video/Audio with Google Docs on 5 Best Team Management Apps (For Small and Large Teams)
  4. 6 Things You Need Know About Email Encryption on Delete All Emails from Gmail With Once Click
  5. Looking For YouTube Alternative? Try These 7 Video Sharing Sites on Ten Best YouTube Video Editing Software 2023
  • Alexa Routines and Skills 2023: A Tutorial Smart Home
  • How to Setup Picasa with Google+ Photos Google Software/Tips
  • How to Block Websites on Google Chrome on Windows How-To
  • Why Wsappx Causes High CPU Usage and How To Fix It Help Desk
  • How To Setup a Power Schedule on Your Smart Plug Smart Home
  • Online Gaming: Ping vs Frames Per Second (FPS) Gaming
  • Best kids calculator watch 2020 black
  • how to chat with Apple Support from iPhone iPhone

Copyright © 2023 How To Blog.

Powered by PressBook News WordPress theme

Go to mobile version