Sometimes you need to zip a folder to make it easier to share or store. Don’t worry, it’s simple to do on Linux! In this guide, we’ll walk you through how to zip a folder step by step.
1. Open Your Terminal
First, open your Terminal. The Terminal is where you’ll run commands to interact with your system. You can open it by searching for “Terminal” in your app menu or by pressing Ctrl + Alt + T
.
2. Navigate to the Folder You Want to Zip
Now, you need to navigate to the folder that contains the folder you want to zip. For example, if the folder is in your “Documents” directory, you can go there by typing:
cd ~/Documents
You can also use cd
to go to any folder where your folder is located.
3. Zip the Folder
Once you’re in the right directory, it’s time to zip your folder! To do this, you’ll use the zip
command followed by the -r
flag (which stands for “recursive”). This flag is necessary because it allows the command to include all the files and subdirectories inside the folder.
Here’s the basic format:
zip -r name_of_your_archive.zip folder_name
name_of_your_archive.zip
: This is the name of the zip file you want to create.folder_name
: This is the folder you want to zip.
For example, if you want to zip a folder called my_folder
and name the zip file my_archive.zip
, you would type:
zip -r my_archive.zip my_folder
Hit Enter, and your folder will be zipped! You’ll see the list of files being added to the archive in the Terminal.
4. Check Your Zip File
Once the process is done, you can check your zip file. It should appear in the same folder where your original folder is located. You can list the files in your current directory by typing:
ls
This will show you a list of files, and you should see your new .zip
file listed there.
5. Optional: Exclude Files or Directories
If you want to exclude certain files or subdirectories from the zip file, you can use the -x
option. For example, if you want to zip a folder but exclude all .txt
files, you can do this:
zip -r my_archive.zip my_folder -x "*.txt"
This will create a zip file of my_folder
, but leave out all the .txt
files.