• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Password Protect A Folder In Linux Command Line

How To Password Protect A Folder In Linux Command Line

By Sourabh / January 30, 2026 Category: How To, Ubuntu

Learn how to password protect a folder in Linux command line. You can use the zip command to create password protected folder in Linux.

This blog outlines step-by-step guide to install zip, compress folders, create password-protected zip files, and unzip archives from the terminal.


How to Zip a Folder in Linux Using the Command Line

Before you begin, make sure the zip command-line tool is installed on your Linux system. If it’s not already installed, open the terminal and run the following command to install both zip and unzip utilities:

sudo apt install zip unzip

Once installed, you can use the zip command to compress folders directly from the Linux terminal.


Zip Command Syntax in Linux

The basic syntax of the zip command is:

zip -r <output_file>.zip <folder_1> <folder_2> ... <folder_n>
  • -r enables recursive compression (required for folders)
  • <output_file>.zip is the name of the zip archive
  • <folder_n> represents one or more folders you want to compress

Example: Zip a Folder in Linux

Suppose you want to zip a folder named Image-Folder into a zip file called Image.zip. Run the following command:

zip -r Image.zip Image-Folder

After the command executes successfully, the Image.zip archive will be created in the current directory.

To verify that the zip file was created, run:

ls -l | grep .zip

Zip a Folder in Linux with a Password

To create a password-protected zip file in Linux, use the -e or --encrypt option. This option encrypts the archive and prompts you to set a password.

For example, to zip Image-Folder into a password-protected archive named Image.zip, run:

zip --encrypt Image.zip Image-Folder

You will be prompted to enter and confirm a password for the zip file.


How to Unzip a Zip File in Linux

To extract a .zip file in Linux, use the unzip command:

unzip Image.zip

Note:

If the zip archive is password-protected, you will be prompted to enter the password during extraction.


Primary Sidebar

Latest Posts

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

Linux Command To Check RAM Size In Ubuntu Terminal In GB

How To Install Proprietary Drivers In Linux Ubuntu Using Terminal

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap