- How to zip a folder in Ubuntu Linux / Debian Linux
- zip a folder in Ubuntu Linux using the cli
- How do I use zip command to compress a folder?
- Compress a directory in Ubuntu Linux
- zip a folder in Ubuntu Linux using the GUI method
- Password protecting zip file
- Conclusion
- How to Create a Password Protected ZIP File in Linux
- How to Create Password Protected ZIP in Linux
- How to Unzip Password Protected ZIP in Linux
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How to Create a Password Protected Zip File in Linux
- Create password protect zip file in Linux [Command Line Method]
- How To Password Protect A Folder In Linux
- Create a password protected zip file in Linux [GUI Method]
- Step 1:
- Step 2:
- Step 3:
- Step 1
- Step 2
- Step 3
- Step 4
How to zip a folder in Ubuntu Linux / Debian Linux
zip a folder in Ubuntu Linux using the cli
First install the zip command using apt command or apt-get command. Open the terminal and type the following command:
$ sudo apt install zip unzip
How do I use zip command to compress a folder?
The syntax is
zip -r filename.zip folder
zip -r filename.zip folder1 folder2
zip -r filename.zip /path/to/folder1 /path/to/file2
To create compressed archive named data.zip of data folder in the current directory, run:
zip -r data.zip data/
Verify file with the ls command:
ls -l data.zip
You can encrypt data.zip with a password by passing the -e option:
zip -r -e data.zip data/
Sample outputs:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
zip command has many more options as follows:
Option | Description |
---|---|
-f | freshen: only changed files |
-u | update: only changed or new files |
-d | delete entries in zipfile |
-m | move into zipfile (delete OS files) |
-r | recurse into directories |
-j | junk (don’t record) directory names |
-0 | store only |
-l | convert LF to CR LF (-ll CR LF to LF) |
-1 | compress faster |
-9 | compress better |
-q | quiet operation |
-v | verbose operation/print version info |
-c | add one-line comments |
-z | add zipfile comment |
-@ | read names from stdin |
-o | make zipfile as old as latest entry |
-x | exclude the following names |
-i | include only the following names |
-F | fix zipfile (-FF try harder) |
-D | do not add directory entries |
-A | adjust self-extracting exe |
-J | junk zipfile prefix (unzipsfx) |
-T | test zipfile integrity |
-X | eXclude eXtra file attributes |
-y | store symbolic links as the link instead of the referenced file |
-e | encrypt |
-n | don’t compress these suffixes |
-h2 | show more help |
Compress a directory in Ubuntu Linux
The zip command syntax is as follows to compress a directory in Ubuntu Linux:
zip -r compressed_data.zip /path/to/foldername
zip -r compressed_data.zip /home/vivek/Jan-2018
zip a folder in Ubuntu Linux using the GUI method
To access and organize your files you use “Files” app (file manager)”. Use the Files file manager to browse and organize the files on your computer. Open it. Select folder name such as data and right click the “Compress…“:
Gif 01: Compressing a folder in Ubuntu Linux using GUI method i.e. Files file manager
Password protecting zip file
We can encrypt and password protect our zip file as follows:
zip -r -e output.zip /path/to/folder/
We can also use and state password on the CLI to encrypt zipfile entries:
zip -r -e -P ‘YOUR_PASSWORD_HERE’ output.zip /path/to/folder/
WARNING: The -P ‘YOUR_PASSWORD_HERE’ option to the zip IS INSECURE! Avoid it. Many multi-user operating systems such as Linux provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the-shoulder peeking. Storing the plaintext password as part of a command line in an automated script is even worse. Whenever possible, use the non-echoing, interactive prompt to enter passwords. And where security is truly important, use strong encryption such as Pretty Good Privacy (PGP/GPG) instead of the relatively weak standard encryption provided by zipfile utilities. See “ HowTo Encrypt And Decrypt Files With A Password Using GPG on Linux and Unix-like Systems” for more info.
Conclusion
You just learned how to compress a directory in Ubuntu Linux or Debian Linux using the zip command. The same command used to zip a folder in Linux. For more info please see this page here.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
How to Create a Password Protected ZIP File in Linux
ZIP is a very popular compression and file packaging utility for Unix-like operating systems as well as Windows. While perusing through the zip man page, I discovered some useful options for protecting zip archives.
In this post, I will show you how to create a password protected zip file on the terminal in Linux. This will help you learn a practical way of encrypting and decrypting contents of zip archive files.
First install zip utility in your Linux distribution using the package manger as shown.
How to Create Password Protected ZIP in Linux
Once installed, you can use the zip command with -p flag to create a password protected zip archive called ccat-command.zip from the directory of files called ccat-1.1.0 as follows.
Create Password Protected Zip File
However, the above method is absolutely insecure, because here the password is provided as clear-text on the command line. Secondly, it will also be stored in the history file (e.g
.bash_history for bash), meaning another user with access to your account (more especially root user) will easily see the password.
Therefore, try to always use the -e flag, it shows a prompt allowing you to enter a hidden password as shown.
Create Password Protect Zip Archive
How to Unzip Password Protected ZIP in Linux
To unzip and decrypt the content of the archive file called ccat-command.zip, use the unzip program and provide the password you entered above.
Decrypt ZIP Archive
That’s It! In this post, I described how to create a password protected zip file on the terminal in Linux. If you have any queries, or other useful related tip/tricks to share, use the comment form below ping us.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How to Create a Password Protected Zip File in Linux
Last updated October 29, 2020 By Abhishek Prakash 13 Comments
Brief: This simple tutorial shows you how to create a password protected zip file in Linux both in command line and graphical way.
We have seen how to password protect folders in Ubuntu earlier. We have also seen encrypted text editor for Linux. Today, we’ll see how to create password protected zipped files in Linux, in both command line and graphical way.
I am using Ubuntu in this tutorial but you can use any Linux distribution that uses Nautilus (now called Files) file manager for the graphical part. Command line steps are the same for any Linux distribution.
There are several ways you can encrypt zip file in Linux. In fact, there are dedicated command line tools for this task, but I am not going to talk about those. I am going to show you how to password protect a zip file without installing a dedicated tool.
Create password protect zip file in Linux [Command Line Method]
First thing first, make sure that you have zip support enabled in your Linux system. Use your distribution’s package manager and try to install it. If its not installed already, it will be installed.
In Debian/Ubuntu, you can use this command:
Now, let’s see how to password protect a zip file in Linux. The method is almost the same as creating zip folder in Linux. The only difference is the use of option -e for encryption.
The -r option is used to recursively look into directories. The -e option is for encryption.
You’ll be asked to enter and verify the password. You won’t see the password being typed on the screen, that’s normal. Just type the password and press enter both times.
Here’s what the process looks like on the screen:
zip -re my_zip_folder.zip agatha.txt cpluplus.cpp test_dir
Enter password:
Verify password:
adding: agatha.txt (deflated 41%)
adding: cpluplus.cpp (deflated 4%)
adding: test_dir/ (stored 0%)
adding: test_dir/myzip1.zip (stored 0%)
adding: test_dir/myzip2.zip (stored 0%)
adding: test_dir/c.xyz (stored 0%)
Do note that if someone tries to unzip this file, he/she can see the content of the folder such as which files are there in the zipped file. But the files cannot be read.
Recommended Read:
How To Password Protect A Folder In Linux
Have secrets? Keep them safe by locking folders with password in Linux.
Create a password protected zip file in Linux [GUI Method]
I have created a password protected zip file in Ubuntu 18.04 here but you can use the same steps on any Linux distribution with GNOME desktop environment.
Step 1:
Search for Archive Manager and open it.
» data-medium-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?fit=300%2C86&ssl=1″ data-large-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?fit=800%2C230&ssl=1″ loading=»lazy» width=»800″ height=»230″ src=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?resize=800%2C230&ssl=1″ alt=»Archive Manager Ubuntu» srcset=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?w=800&ssl=1 800w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?resize=300%2C86&ssl=1 300w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?resize=768%2C221&ssl=1 768w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Archive Manager
Step 2:
Drag and drop the file(s) you want to compress into a zip file. Select Create Archive option here.
Create a zip file
» data-medium-file=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?fit=300%2C184&ssl=1″ data-large-file=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?fit=800%2C491&ssl=1″ loading=»lazy» width=»800″ height=»491″ src=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=800%2C491&ssl=1″ alt=»Create Archive Ubuntu 1″ srcset=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=800%2C491&ssl=1 800w, https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=300%2C184&ssl=1 300w, https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=768%2C471&ssl=1 768w, https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?w=1053&ssl=1 1053w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Create a zip file
Step 3:
In here, choose the type of compressed file. It will be .zip in my case. You’ll see the “Other Options”, click on it and you’ll see the password field. Enter the password you want and click on the Save button.
Create Password Protected Zip file
» data-medium-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?fit=300%2C182&ssl=1″ data-large-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?fit=800%2C485&ssl=1″ loading=»lazy» width=»800″ height=»485″ src=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=800%2C485&ssl=1″ alt=»Creating Password Protected Zip file in Ubuntu Linux» srcset=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=800%2C485&ssl=1 800w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=300%2C182&ssl=1 300w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=768%2C465&ssl=1 768w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?w=1046&ssl=1 1046w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Create Password Protected Zip file
That’s it. You have successfully created a password protected zip file in Ubuntu Linux graphically. The next time you want to extract it, it will ask for a password.
» data-medium-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?fit=300%2C176&ssl=1″ data-large-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?fit=800%2C469&ssl=1″ loading=»lazy» width=»800″ height=»469″ src=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=800%2C469&ssl=1″ alt=»Password Protected Zip file in Ubuntu» srcset=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=800%2C469&ssl=1 800w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=300%2C176&ssl=1 300w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=768%2C451&ssl=1 768w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?w=852&ssl=1 852w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Password Protected Zip file in Ubuntu
If you are using Ubuntu 16.04 with Unity desktop environment, things will be slightly different. Click on the next section to see the steps for Unity desktop.
To follow this tutorial, you just need to make sure that you are using Nautilus/Files file explorer. If you are using Fedora, Ubuntu Unity, or any other Linux distribution with GNOME as its desktop environment, you have Nautilus.
Step 1
Right click on file(s) and/or folder(s) and click on Compress:
Select the compression format you want to choose. There are several formats available but you cannot use all of them for password protecting the files.
Step 2
I advise to use the .zip format. After selecting the compression format, click on the Other Options.
Step 3
You’ll see option of entering password in Other Options. If the compression format you selected doesn’t support encryption, this Password area would be greyed out.
It may also happen that you’ll have to install the compression utility to use the encryption. For example, if you do not have RAR installed, password option will not be available.
Step 4
Enter a suitable password and click on Create:
Compression takes time based on the size of the file or directory. You’ll see a message like this when the files are compressed successfully:
The compressed file thus created is password protected. If you try to extract it, it will ask you to enter the password:
As you can see, no one (in normal ways) can extract this file without the password. Congratulations, you just learned how to encrypt zip files in Ubuntu Linux.
Just for your information, double clicking on the password protected directory might give the impression that you may access the encrypted directory without a password, but you cannot actually read those files.
I hope this quick tutorial helped you to create password protected zip files in Linux. In coming days, we shall see how to password protect a directory in Linux and how to break the encryption. Stay tuned 🙂
Like what you read? Please share it with others.
Источник