Tuesday, April 6, 2021

HOW TO ZIP (COMPRESS) AND UNZIP (EXTRACT) FILES

 Compressing several files and folders into a single distributable file is the most common way done by many computer users around the world. In Windows, you can simply use Winzip, WinRAR, 7Zip, and so on to zipping and unzipping file. If you’ve installed full Linux distros with GUI, you can also find and use similar app to do similar tasks. But what about a Linux server which you can only access it via SSH client? Realizing that many files are zipped and distributed as .zip file, also that you may need to zip several files into one .zip file so you can download it or transfer it elsewhere, so here it is I tell you how to do zipping and unzipping in a Linux-based VPS or Dedicated server via SSH client (in this case I use Putty, in Linux or Mac you can use Terminal).

Purpose:
I will show you how to zip / compress file and to unzip / decompress / extract file in Linux server via SSH

HOW TO UNZIP / EXTRACT FILE?

Step 1.
Open Putty or Terminal then login to your server via SSH

read: How to use Putty to SSH

Step 2.
Once you are logged into your server via SSH, now navigate to the directory where the .zip file you wish to unzip is located there.

read: How to navigate from one directory to another in SSH


Step 3.
Then type following command to try unzipping

1
unzip [filename].zip

example

1
unzip screenshot.zip

you may be successful but you may not.

error message:
– bash: unzip: command not found

In this case you have to install it first.

Step 4.
Use following command:

for Debian and Ubuntu:

1
apt-get install unzip

for Red Hat Linux/Fedora/CentOS users:

1
yum install unzip

Step 5.
That’s it. Now you can try unzipping it again using command in step 3 above.


HOW TO ZIP / COMPRESS FILE?

Step 1.
Open Putty or Terminal then login to your server via SSH

Step 2.
Once you are logged into your server via SSH, now navigate to the directory where the files and folders you wish to zip / compress are located there.

Step 3.
Use following command:

1
zip [zip file name] [file 1] [file 2] [file 3] [file and so on]

example:

1
zip example.zip 1.txt 2.txt 3.txt

In this example we’ll compress files 1.txt, 2.txt and 3.txt into a single example.zip file


you may be successful but you may not.

error message:
– bash: zip: command not found

In this case you have to install it first.

Step 4.
Use following command to install zip function:

for Debian and Ubuntu:

1
apt-get install zip

for Red Hat Linux/Fedora/CentOS users:

1
yum install zip


Step 5.
That’s it. Now you can try zipping it again using command in step 3 above.


Link: http://www.servermom.org/how-to-zip-compress-and-unzip-extract-files/65/

No comments:

Post a Comment