7-Zip for Linux is the best solution for file compression and decompression. And if you are the type of person who regularly deals with compressed files such as Zip and RAR formats, well then, the 7Zip should be on our list of installed apps. Before we show you how to install and use the software on Linux, make sure to check out our other guides on 7Zip.
- Mac Terminal Zip Multiple Files File
- Mac Terminal Zip Multiple Files Extractor
- Mac Terminal Zip Multiple Files
- Mac Terminal Zip Multiple Files Folder
- Mac Terminal Zip Multiple Files Recovery Software
For compressed files, 7Zip is the only one that can compare head to head with the ever-popular WinRAR. But in reality, 7Zip is the much better one. As a matter of fact, 7Zip is a tool for many professionals who really know their stuff.
Contents
As a systems engineer who works extensively in the Terminal, and as somebody who tried to adopt zsh/oh-my-zsh into my workflow, I can honestly say I would never recommend ZSH to anyody. Sure, you can symlink zsh to a file named after any other shell and emulate that shell, but when you do that it doesn't read your.bashrc,.bashprofile, etc. Most important is to have unfolding directories and ability to select multiple files from anywhere within the tree structure simultaneously. Other important features I am looking for: 1. Drag and Drop with Spring loaded folders 2. Tabbed windows 3. Quickview like previews 5. Ability to change color and background image of windows 6. Tech and Science topics: phones, computers, gadgets, and the Internet, astronomy & earth science, climate & weather, environment & green living and much more. 7-Zip for Linux is the best solution for file compression and decompression. And if you are the type of person who regularly deals with compressed files such as Zip and RAR formats, well then, the 7Zip should be on our list of installed apps. Think of zip files as a satchel that you can store smaller individual files in for convenience. For example, if you wanted to send someone 30 photo files, you could just compile them in a zip file and then send the one zip file instead of 30 individual files.
- 3 7-Zip Commands
- 3.1 Command Options
What is 7-Zip?
7Zip is a powerful tool in the right hands. It is a secure open-source file archiver that can compress multiple files into one simplified cabinet-like folder and vice versa.
The 7Zip was created by Igor Pavlov back in 1999. It supports the most known compression type of formats on both packing and unpacking methods. This includes ZIP, Gzip, bzip2, xz, tar and WIM for Windows installer.
Basically, the 7Zip archiving tool is pretty much near-universal in terms of its focused purpose. It has a powerful compression algorithm and supports password protection. This app is a tool for benchmarking processing power by some experts. According to some reviewers, the 7Zip is a tool far better than what the popular counterpart can do. Nevertheless, it is not perfect and has its own downsides.
There are two main accesses to use 7Zip. One is through a 7Zip command line. The other one is through your typical graphical interface which is more user-friendly for most users. The 7Zip for Linux will work more on the command-line support.
How to Install 7-Zip for Linux
For those of you that are not familiar with how apps are installed on Linux or any Linux-based distribution, this is the 7Zip tutorial written just for you. This will be the simplest coding you will ever do so you should be able to follow this if you manage to do this in repetition. Still, it’s not as easy as installing 7Zip for Windows or Mac. Yes, it’s just like they said, practice makes perfect.
On Ubuntu and some other Linux-based platform, 7Zip is packaged as p7Zip. To install p7Zip, you will need to do this procedure. Here’s how it goes.
- The first thing you need to do is to launch the Terminal to execute some commands. If you cannot find the Terminal, you can use Ubuntu’s search service and type in Terminal.
- On the Terminal, type in this command: sudo apt-get update
- You will be asked to enter your password. Please do so as this first command will update your system.
- Once the system update finishes, you will need to type in this command: sudo apt-get install p7Zip-full
- Again, you will need to enter your system password to confirm the command request.
- The command will now start to download the necessary files from the repository
- As soon as all the files are downloaded, you will be asked if you want to continue or not with the installation. Type “Y” for yes and “N” for no. In this case, just type “Y” and press the Enter key.
- This will now initiate the unpacking of the downloaded files and start setting it up for installation.
- When the command line appears again, it means the installation is through.
- To make sure that the 7Zip really installed on your Linux computer you will need to type in this command: sudo apt-qq list p7Zip-full
- Type in your system password again to confirm the request.
- Read the following line and find the word “Installed.”
- Now type this command: sudo dpkg -s p7Zip-full | grep Status
- The next line should say “Installed” again.
- That’s it. You now have 7Zip installed on your Ubuntu system.
7-Zip Commands
Now, if you want to know all the corresponding commands to execute some tasks, you will only need to launch the Terminal again. From the Terminal, just type in 7Z. It should show you the different types of commands that you can use. To execute any command, it should follow this pattern:
- 7z [command option] [archive file name & format] [files]
Command Options
- a —means to add files in archive
- l —means to list the contents of archive
- u — means to update the files in the archive
- e — means to extract files from archive without their full path
- x — means to extract files from archive with their full path
- d — means to delete files from archive
For the “archive file name & format” you will type in the name of the compressed file that you want as output with the file format that you want like ZIP, RAR, or 7Z. For the “files” that the name of the file that you want to compress. To do this, here is an example and how to do it:
- Create a folder on your desktop.
- Paste the file inside that folder. Let’s assume that the file’s name is “Sample.”
- Now, still in the same folder, launch the Terminal.
- Now, type in this command: 7z a Sample.zip Sample
- Wait for a few seconds or minutes depending on the size of the file. The bigger the file, the longer the compression takes place.
- That’s it. A new file will now appear inside the folder with the name Sample.zip next to the original file named Sample.
Conclusion
For the old-timers and advanced users, these commands will be such ease. But if this is your first time, you will need some getting used to. Ubuntu and other Linux-based distributions are a bit complicated especially if you came from the point-and-click operating system like Windows 7 to 10.
Now, as a question for today’s topic, do you think the 7Zip for Linux is a good tool? If not, do you have an alternative in mind? If you do, do tell us in the comment section. We would love to know your recommendations.
If you have any questions about today’s topic, please feel free to leave your message in the comment section below as well. We will try to get back to you as soon as we can.
One of the most useful commands in Linux is the ability to zip (compress) and unzip (extract) the files and folders. We don’t fully understand how useful this really is. That is because honestly, we take the ability to zip and unzip files for granted. Most of the personal computers run Windows OS. And you can compress any number of files by right click and select send to compressed. Now imagine you have a full WordPress site hosted on a Linux VPS. And you want to move it to another location. It is a very simple task. But quickly becomes difficult without knowing how to zip (compress) and unzip (extract) files and folders in a Linux VPS. Today, I will show you all the different methods of compressing and extracting files in Linux using very simple commands. I am using a Ubuntu 18.04 LTS Cloud server from Vultr for this tutorial, but this should work on all Linux systems regardless of which operating system you have.
HOW TO ZIP (COMPRESS) AND UNZIP (EXTRACT) FILES IN LINUX VPS
Page Contents
- 1 HOW TO ZIP (COMPRESS) AND UNZIP (EXTRACT) FILES IN LINUX VPS
I am using a Windows 10 computer as a client to connect to the Linux Cloud VPS using Putty as my terminal program. If you are also using Windows PC, I highly recommend you to use Putty to make the SSH connection. For Mac and Linux users, you can simply use terminal to connect to the server using the ssh command.
First of all, we need to connect to the Linux cloud VPS using Putty or Terminal. I won’t be showing you how to do it. If you have just bought a cloud VPS for the first time, the VPS company must have sent you an email about it.
Once you are logged into the server SSH, we can start typing in the commands.
How to unzip / Extract files in Linux
Step 1: Navigate to the right directory
The first thing you need to do, after login, is to find the .zip file. Basically, we will need to change our working directory to the folder which has our .zip file. And to do that, we use the command called cd
, short for change directory.
For example, if I want to unzip or extract a file called word.zip
. And this file is in the folder called public
. I will need to open the public
folder and then run the unzip
command.
So, run the following command. replace path/to/folder
with the actual folder path.
cd path/to/folder
Step 2: Verify that the zip file is there in the folder.
You can do it by running the ls
command. This is the list command, and it lists all the files and directories in the current working directory.
Step 3: Unzip (Extract) the zip file
This step can vary a little. Basically, if you want to unzip/extract the zip file in the current directory, then it is a simple command.
unzip word.zip
Don’t forget to replace word.zip
with the actual name of the zip file.
Pro tip: If the file name is very long and complicated, you can type a few starting letters of the file name and then press the tab key. Many SSH clients, including putty, will auto-complete the name for you. This is a major time saver.
How to extract/unzip to a specific directory?
For example, you are moving a WordPress website and you wish to unzip extract the backup zip to the public_html
folder. How do you do that? Well, it is very simple, all you have to do is add the destination directory at the end of the unzip
command.
unzip word.zip -d /home/user/public_html/
-d
option tells Linux that the directory after it is the required destination folder.
That’s it, you have successfully extracted the zip file. But what if you receive the bash: unzip: command not found error? This happens if your Linux system does not have the unzip command installed.
How to fix the bash: unzip: command not found error?
To fix this error, you will need to install the unzip
command in your Linux system. You can do it by running the following command.
If you have Ubuntu or Debian based Linux distro, you will need to run the following command.
sudo apt-get install unzip -y
For RedHat, Fedora and CentOS based systems, you will need to run the following command.
sudo yum install unzip -y
Don’t use sudo
if you are using a root user. The -y
argument is optional. It basically skips the verification prompt and runs the command without asking for verification.
Fun fact: When you run the command to install zip command, Linux will automatically install the unzip command as well.
Now you can run the unzip
command again, and this time you should see that the zip is being extracted successfully.
How to unzip/extract a particular file from the zip in Linux?
Let’s say you want to only extract one particular file out of a .zip file. How do you do that? Well, it is very easy, let me show you how.
unzip zipfile.zip filename
In this command, the zipfile.zip
is the zip archive you already have. And filename
is the file you wish to extract. So make sure to replace zipfile.zip
and filename
with actual names. Otherwise you will get an error.
How to Zip / Compress one file in Linux VPS?
Step 1: Navigate to the right folder
After you have successfully logged into the cloud VPS via SSH, you will need to go to the folder which has the file you want to zip/compress. For me this is the /tmp
folder, so I will be running the cd
command like this.
cd /tmp
Make sure to replace the /tmp
folder with the actual path of the folder.
Step 2: Zip/Compress the file
Mac Terminal Zip Multiple Files File
Now simply run the following command in the terminal window and the file will be compressed.
zip zipfile.zip filename
zipfile.zip
is the file name of the resulting zip archive file. For example, if I have a photo.png
file and I wish to compress it as picture.zip
, I will run the following command.
zip picture.zip photo.png
How to zip/compress multiple files in Linux?
Mac Terminal Zip Multiple Files Extractor
To compress multiple files in a zip archive in Linux, you can run the following command in the terminal.
zip zipfile.zip filename1 filename2 filename3 …
Keep in mind that the zipfile.zip
will be the resulting .zip archive which will have the filename1
and all the files in it.
How to compress/zip all files in a folder in Linux?
If you wish to zip all files in a folder using one command, it is very simple in Linux. Here I have an example command which you can use.
zip zipname.zip folder/*
And if you wish to zip/compress all the files in the current directory, use the following command.
zip zipname.zip *
The zipname.zip
is the resulting zip archive. And the *
tell Linux that you want to compress every file in the folder, and put it in the zipname.zip
file.
How to zip/compress all files in a folder including sub-directories? (Recursive)
What if you want to compress not only the files in a folder, but also include all the sub-folders and their files as well in the zip archive? This is particularly helpful if you wish to create a full backup of all the files.
zip -r zipfilename.zip foldername
Make sure to change the zipfilename.zip
to the actual name of the zip file you wish to have. This is the .zip file Linux will create. Don’t confuse it with a file you may already have. The -r
attribute tells Linux that the zip command is recursive, and it needs to include all the sub-directories as well.
How to fix bash: zip: command not found error?
For those of you who are unable to run the zip command because of the bash: zip: command not found error, let me show you how to fix it. Basically, this error mostly comes when you have minimal Linux distro, instead of the full image. You can fix this by simply running the following command in the terminal.
For Ubuntu/Debian based systems, run the following command.
sudo apt-get install zip -y
And if you have Red Hat/Fedora/CentOS based system, run the following command.
Mac Terminal Zip Multiple Files
sudo yum install zip -y
Mac Terminal Zip Multiple Files Folder
Don’t use sudo
if you are using a root user. The -y
argument is optional. It basically skips the verification prompt and runs the command without asking for verification.
Mac Terminal Zip Multiple Files Recovery Software
Now run the zip
command and it should start compressing the files with no issues.
Fun fact: You don’t really need to add the .zip
file extenstion when using the zip
command. It is only used for the understanding of our human minds. When you will run the zip
command, it will automatically add .zip
extension to the first name after zip
.
That’s it, now you know how to zip (compress) and unzip (extract) files in Linux (VPS) using the SSH terminal commands. If you liked this tutorial then make sure to share it with others and also don’t forget to follow us on twitter for more tutorials like this.