Using Terminal to encrypt a zip file in sequoia on my MacBook Air M2

I was able to password my zip file, which is on my desktop, with Terminal. When I did that and now open it, it seems to zip the folders before getting to the actual pdf document.

eg. it zipped Users/Me/Desktop/ file.pdf (3 clicks to see file)

I put the zip file up in Google Drive, and when I open it, it shows the same way. ie; 3 folders to click on, to get to the pdf file.


  1. Will others see it that way too when they open the password protected zip file?
  2. Is there a command so it doesn't show like this? I want only the file zipped so one click.

MacBook Air (M2, 2022)

Posted on Oct 29, 2024 1:01 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 29, 2024 4:08 PM

If you want just the PDF involved and not the directories, consider encrypting the PDF itself:

Password-protect a PDF in Preview on Mac - Apple Support


If you don’t want the directories, either set Finder to the folder, or use the command-line zip after using the cd command to change your default directory to the directory where the PDF resides.


Rather than

-j
--junk-paths

you can also use an available zip switch to exclude the directories:

-D
--no-dir-entries


The zip encryption is weak, if that matters to you.


16 replies
Question marked as Top-ranking reply

Oct 29, 2024 4:08 PM in response to Quacks

If you want just the PDF involved and not the directories, consider encrypting the PDF itself:

Password-protect a PDF in Preview on Mac - Apple Support


If you don’t want the directories, either set Finder to the folder, or use the command-line zip after using the cd command to change your default directory to the directory where the PDF resides.


Rather than

-j
--junk-paths

you can also use an available zip switch to exclude the directories:

-D
--no-dir-entries


The zip encryption is weak, if that matters to you.


Nov 4, 2024 7:21 AM in response to Quacks

Quacks wrote:

Thank you! I don’t know much about using terminal so this will help.
Puzzles me as to why having to use Terminal for such an easy thing. Apple needs to make an app or fix the compress to allow a password. Odd that has been done.

Because as @MrHoffman mentioned, Zip encryption is not actually secure. Apple definitely does not want to give the user a false sense of security. Zip encryption is like locking a screen door, anybody can poke a hole in the screen to open the door.

Oct 29, 2024 4:29 PM in response to MrHoffman

Thank you! The reason for the zip file is that I needed to upload it to my google drive (just started using for sharing docs). Did some reading, and like Dropbox, I read that there are security issues (end to end encryption I think? not as secure as pCloud). Recommended that for sensitive docs, to password protect and password protect into a zip file. Not really sure why but something to do with Google doing something on password protected files. Zip they can't or don't??? I didn't quite understand. I did use a strong password if that helps. Maybe I am being way too untrusting with the cloud stuff which I tend to stay away from. I created my own for myself.

Thanks for the options on password protecting my zips!


Oct 29, 2024 8:24 PM in response to Quacks

Quacks wrote:

Does it work if others don’t have Apple id’s, use windows and androids etc?


If you don’t try to restrict the file sharing, yes, anybody with the URL can access the file.


Per Apple, from elsewhere, “Anyone with the link: Allow anyone who receives the link to access the file or folder. If you choose this option, people you invite can share the link and give access to others not included in your original invitation.”


I’ve shared session notes with presentation audiences using this. No Apple Accounts, and who-knows-what the participants were using to access it.


Maybe try it?


After pressing and holding to get the pop-up menu, select Share in the Files app, select collaborate and anyone can view:



When tapping where anyone-can-view is shown above, here is how to get anyone-can-view selected:



then select this to get the URL used to share the file:



Once shared, you have no control how far the URL can spread, same as the PDF password or zip password.


To stop sharing, select Manage Sharing from the popup shown when pressing and holding on the file:





iPhone and iPad are very similar (above images), while the macOS UI is a little different but with similar capabilities.

Nov 1, 2024 1:31 PM in response to Quacks

Again, Preview app can password-protect PDF files, as was linked above.


No need for added tools.


Select File > Edit Permissions... in the menus.



Yes, if you're passing around other files, you can potentially need other tools if the files involved need encryption.


zip encryption is open for various shenanigans, as well.


Other Apple tools include built-in protection mechanisms, as well.


Apple iWork Pages, for instance:


Password-protect a Pages document on Mac - Apple Support


I'd be surprised to learn Microsoft Office couldn't also password-protect files.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using Terminal to encrypt a zip file in sequoia on my MacBook Air M2

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.