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

Laviskajoermoy

New member
Joined
Jan 18, 2014
Messages
84
Points
0
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

New member
Joined
Mar 5, 2013
Messages
397
Points
0
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
I learned from this my post https://www.webmastersun.com/threads/7769-Why-htacess-file-didn-t-show-on-console-command

If you want unzip yourfilename.zip then try to type following command

Code:
unzip yourfilename.zip
Hope it helps!
 

Developer

Active member
Joined
Dec 21, 2015
Messages
412
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
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

New member
Joined
Jan 5, 2016
Messages
32
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

New member
Joined
Apr 22, 2015
Messages
64
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
Recommended threads

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

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