Ask Dave Taylor
  • Facebook
  • Instagram
  • Linkedin
  • Pinterest
  • Twitter
  • YouTube
  • Home
  • YouTube Videos
  • Top Categories
  • Subscribe via Email
  • Ask A Question
  • Meet Dave
  • Home
  • Linux Help
  • How Can I Create a Password Protected Zip Archive in Linux?

How Can I Create a Password Protected Zip Archive in Linux?

July 27, 2020 / Dave Taylor / Linux Help / No Comments

I want to share some of my source files for my new game with a colleague, but don’t want to send them in the clear. Is there a way to create an encrypted, password protected Zip Archive in Linux so I can email them safely? I’m running Ubuntu Linux, if that matters, and she’s working on a Mac.

While many operating systems have the ability to create encrypted files or folders and some email systems support secure file sharing, there’s a lot to recommend the Zip archive system, even if it’s over a hundred years old in Internet time. Actually, it was designed by Phil Katz of PKWARE and Gary Conway of Infinity Design Concepts and introduced back in 1989, if you’re curious!

At this point, every major operating system include a ZIP archive and unarchive or extraction application, though most are fairly crude or awkwardly designed as many basic utilities end up being. This means, however, that you can create a ZIP archive – including one with password protection – on any of the major operating systems and share it with users on any other OS. Mac to Windows? Linux to Mac? All of that works just fine.

The basic approach is straightforward too: Create a folder, copy all the files you want to send into that folder, then launch the ZIP utility to create an archived version of that folder and its contents, all neatly packed into that encrypted, password protected file. On Linux, the fastest and easiest is probably to just use the command line, so here’s how that would progress. First, check where you are in the file system with pwd then create the folder you want to send:

linux mkdir

In this case I’m making a directory called SecretFiles.

Now’s the fun part; use the cp command to copy all the files you want into that folder. The ls command can show you the contents of the directory when you’re ready to proceed:

linux ls command

You can see I have a spreadsheet (financials.xls), a Word doc (readme.doc) and a plain text file FYEO (which stands for ‘for your eyes only’ if you’re stymied on that acronym).

On just about every Linux and Unix system on the planet, the ZIP command is known by the name zip, and the basic syntax is zip [flags] [outputfile] [list of input files and directories]. In this instance, you want to specify two flags -r and -e, the former denoting that it should recursively scan for files to include to ensure it includes the contents of the new folder, and the latter indicating that you want to encrypt the archive. Like this:

linux zip create encrypted password archive command

Notice it prompted for a password twice, to ensure you typed it correctly, then quickly added both the directory and the three files within, trying to compress (deflate) each of them. A win:win, really: it saves the files encrypted, and it shrinks them down to make them faster and easier to share too.

I specified “secret” as the output (second parameter on the command invocation) but it automatically added the correct suffix “.zip”. But there’s a really important limitation in these encrypted files that you should know about: the folder names and file names are not encrypted or hidden in any way. Consider when I enter the wrong password after trying to unzip the new archive:

linux zip archive wrong password encrypted

For some people, that’s a show-stopper because the names of directories and files can contain a lot of information too, particularly if you have good naming practices. Above, even without the password, you can glean that I’m sending financials and a Word doc, more information than you probably want known. For most people, however, it’s not a big deal, just something to know about.

The file icon in Linux is identical if the ZIP archive is encrypted or not, as you can see:

ubuntu linux zip archive icon

Some operating systems differentiate so you can immediately recognize it’s encrypted, probably a better approach. If you are using the graphical user interface for your Ubuntu Linux system, then you can double click on the ZIP archive and explore the file hierarchy, which is disconcerting. Once you go to open up a file of any sort, however, it prompts:

linux password required encrypted zip archive

Let’s look at sharing it with your colleague, however. One easy way to share it is through Gmail as an attachment. This is where that compression (deflation) is helpful. You might need to warn her, however, that when she receives the email it might be a bit alarming in Gmail:

gmail encrypted zip archive not scanned warning

That’s ok if she can verify with you that you did indeed send it and it’s not a scam or malware. Then she can save the attachment to her own Downloads folder and double click on it:

macos x mac enter password encrypted zip archice

That’s it. Once she correctly enters the archive password it all be unpacked and extracted and a new folder will exist on the Mac system with all the original contents you included:

mac folder finder xls doc

Windows is mostly the same, though creating a password protected ZIP archive on a Win system is a bit more convoluted. I explain how to do that here: How to Create a Password Protected Encrypted Zip Archive on a Windows 10 System. You can also read my Create An Encrypted Zip Archive on your Mac Easy article too!

Pro Tip: I’ve been writing about Linux since the dawn of the operating system. Please check out my extensive Linux and Unix help area for lots more tutorials while you’re visiting!

Let’s Stay In Touch!

Never miss a single article, review or tutorial here on AskDaveTaylor, sign up for my fun weekly newsletter!
Name: 
Your email address:*
Please enter all required fields
Correct invalid entries
No spam, ever. Promise. Powered by FeedBlitz
Please choose a color:
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!
create zip archive linux, encrypted zip archive, password protected archive, password protected folder, unzip linux, zip archive, zip linux

Leave a Reply Cancel reply

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

Search

Recent Posts

  • How Can I Add My Pronouns to my Instagram Account Profile?
  • Possible to Pair Bluetooth Headphones with my Vizio TV?
  • Possible to Schedule a Windows 11 System Update & Restart?
  • How Can I Add Spacers and Divider Lines to my MacOS 12 Dock?
  • How Do I Pair Bluetooth Earbuds with my Google Chromebook?

On Our YouTube Channel

Google Pixel 6a Budget Android Smartphone -- DEMO & REVIEW

QueStyle M15 Mobile Lossless DAC / Headphone Amp -- UNBOXING & REVIEW

Categories

  • AdSense, AdWords, and PPC Help (106)
  • Amazon, eBay, and Online Shopping Help, (161)
  • Android Help (201)
  • Apple iPad Help (145)
  • Apple Watch Help (52)
  • Articles, Tutorials, and Reviews (344)
  • Auto Tech Help (11)
  • Business Advice (199)
  • Chrome OS Help (25)
  • Computer & Internet Basics (764)
  • d) None of the Above (165)
  • Facebook Help (383)
  • Google, Chrome & Gmail Help (179)
  • HTML & Web Page Design (245)
  • Instagram Help (48)
  • iPhone & iOS Help (607)
  • iPod & MP3 Player Help (173)
  • Kindle & Nook Help (93)
  • LinkedIn Help (85)
  • Linux Help (166)
  • Linux Shell Script Programming (87)
  • Mac & MacOS Help (894)
  • Most Popular (16)
  • Outlook & Office 365 Help (26)
  • PayPal Help (69)
  • Pinterest Help (53)
  • Reddit Help (18)
  • SEO & Marketing (81)
  • Spam, Scams & Security (92)
  • Trade Show News & Updates (23)
  • Twitter Help (217)
  • Video Game Tips (66)
  • Web Site Traffic Tips (62)
  • Windows PC Help (921)
  • Wordpress Help (204)
  • Writing and Publishing (72)
  • YouTube Help (46)
  • YouTube Video Reviews (159)
  • Zoom, Skype & Video Chat Help (57)

Archives

Social Connections:

Ask Dave Taylor


Follow Me on Pinterest
Follow me on Twitter
Follow me on LinkedIn
Follow me on Instagram


AskDaveTaylor on Facebook



microsoft insider mvp


This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to our terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. Our lawyer says "Thanks for your cooperation."
© 2022 by Dave Taylor. "Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.
Privacy Policy - Terms and Conditions - Accessibility Policy