Zip is the most common feature to compress the file and transfer the files easily. With Zip, we can also send the directory directly. Also when we work in command-line server, there is no option we can zip file from the GUI. Also it is fast to zip or unzip files from command-line.
In this article, we will discuss on how to zip and unzip the files in Linux OS systems from the command line.
Zip comes preinstalled in the most Linux desktop environment. You can check it from the bellow command.
zip --version
You will get bellow response if zip is already installed.
Or you can also install zip with just bellow command
sudo apt-get install zip
sudo yum install zip
To zip the file, just use the bellow command.
zip filename.zip file1 file2 file3
This will create filename.zip
file.
First install the unzip from the bellow command.
sudo apt-get install unzip
sudo yum install unzip
The bellow command is the basic sintax to unzip the zipped file. It will unzip all the files in the currenct folder without folders.
unzip filename.zip
Use the -d option if you want to unzip the files in the specifies directory.
unzip filename.zip -d /path/to/directory
If you want to see the content in the zipped file without unzipping, the use -l option.
unzip -l filename.zip
This will display content of the zipped file.
If your zip file is password protected, then use the -p option with password.
unzip -p filepassword filename.zip
If you do not want to unzip all the files and want to exclude some file, the use -x option with exclued files.
unzip filename.zip -x file1 file2
If you want to overwrite the file without asking, use -o option.
unzip -o filename.zip
Or if you want don't want to overwrite the file, then use -n option with file name
If you want to unzip the rar files, then first, you need to install unrar.
sudo apt-get install unar
sudo yum install unrar
To unzip the rar file to current directory
unar backup.rar
Check out all the options available for Unrar.
unar man
This way unzip will help you to work with files. If you have any question or suggestion, please feel free to comment bellow.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to check an element is visible or not using jQuery
Use the jQuery :visible Select...Django - How to send an email with Example
Django comes with a yare and facile-to-u...How to Create REST API in Laravel7 using Passport
Hey Artisan Hope you are doing well....JavaScript Redirect to Another Webpage
JavaScript is very extensive. While work...How to convert the first letter of a string to uppercase in PHP
Use the PHP ucfirst() function...