Zip with Terminal

Terminal or the command line is a pretty powerful place to be, and a great building block to learn and enjoy.

A quick and dirty, “can you password protect and zip this folder” job popped up last week and it reminded me what Terminal can do.

Zip up a file or folder very quickly and simple, whilst even adding a password if required.

Step 1 - How to zip a file

  • When you get starting using zip when Terminal, it’s probably best to do everything on the desktop as your working directory, so open up terminal, and the type “cd Desktop” and press enter.

“cd” means change directory

“Desktop” is the desktop

  • Next sense check is to type “ls” followed by enter.

    “ls” mean Listings

  • You’ll see the contents of your desktop, if everything matches your current Desktop you’re in the right place. iCloud desktop and the MacOS’s desktop can sometimes get confused.

The Blue items are folders and the white items are files.

The command to zip a file is as follows

Zip -r [Zip file name] [The file to be zipped]

  • Zip is the command to tell terminal to zip up the following items.

  • -r mean recursive (all the items in the folder)

  • Zip file name, the name of the new zip file example.zip

  • The file to be zipped - is the folder or file

So we’ve going to zip up the Mini Disc folder, with the following command, using the above template.

Zip -r Minidiscinfo.zip Minidisc/

The program runs, and you see all the file(s) being zipped up within the new folder

Run the “ls” command again, to see the folder on the desktop

Password Protect Zip Folder

The process is exactly the same as above, but you an a extra “e” option to the command.

“e” standing for encryption

Zip -er Minidiscinfo.zip Minidisc

You’ll be asked for a password, and then to verify the password, each time pressing enter.

No fancy or expensive tools are needed, and you don’t need to send the documents off site through a web browser either.

The new zip files can be opened by all different types of operating systems, and not limited to MacOS / OSX.

Previous
Previous

We stand with Ukraine

Next
Next

Rocket