How to ZIP (compress) and UNZIP (extract) files on your server via SSH?

Laviskajoermoy

Active member
Registered
Joined
Jan 18, 2014
Messages
68
Points
8
I logged into my server via SSH, I want to use Putty or Terminal to zip ZIP (Compress) and UNZIP (Extract) files and folders in a folder on server. How to do?
 

Maxwell

Well-known member
Registered
Joined
Mar 5, 2013
Messages
189
Points
28
I logged into my server via SSH, I want to use Putty or Terminal to zip ZIP (Compress) and UNZIP (Extract) files and folders in a folder on server. How to do?
Hey there,

Using this code

Code:
zip -r yourfilename.zip * .htaccess
If you want unzip yourfilename.zip then try to type following command

Code:
unzip yourfilename.zip
Hope it helps!
 

Developer

Well-known member
Registered
Joined
Dec 21, 2015
Messages
292
Points
43
Just to go into a little more depth here, following is what I always send my customers
when they ask how to zip via Telnet/SSH/Putty, etc...

To zip a file, use the following (without the quotes)

"zip zip-file-name.zip file1.html file2.php file3.txt"

1. (zip) issues the "zip" command
2. tells the system to name the zip file "zip-file-name.zip"
3. tells the system to include 3 files (file1.html, file2.php and file3.txt)

The initial "zip" command, you will NOT change.
The second and third variables (zip-file-name.zip AND file1.html, file2.php and file3.txt)
would all be changed to match your exact needs.

Having been a server admin for many years, post back if you have any other questions.
I'd be happy to help in any way I can.
 

RDPNation

New member
Registered
Joined
Dec 3, 2015
Messages
5
Points
0
May be you can try following commands in putty :-

To extract you ZIP file..
Code:
unzip archive.zip
To ZIP your file..
Code:
zip archive.zip 1.txt 2.txt 3.txt
NOTE : if you get some error code like command not found,..then you first have to install the zipping/unzipping feature.
 

hmb-robert

Member
Registered
Joined
Jan 5, 2016
Messages
30
Points
0
Hello,

Linux allows you to compress and Un-compress files in different ways. Following are few important commands

gunzip
unzip
pack
tar
uncompress
zcat
 

vps9

Member
Registered
Joined
Apr 22, 2015
Messages
19
Points
0
- To Compress the file
# xz -z file_name
it will be saved as file_name.xz

- To Decompress the file
# xz -d file_name.xz
it will decompress the file and the file will be saved as its default format.
 
Latest Threads
Replies
1
Views
56
Replies
0
Views
47
Replies
0
Views
65
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top