16

My sysadmin is unreachable right now, and I have a zipped file on the server that I would like to unzip...however, we don't currently have zip and unzip installed, and I don't have root access to install them...

Am I out of options entirely? Are there other things that can unzip this file?

johnnietheblack
  • 461
  • 2
  • 5
  • 11

6 Answers6

16

If you have java installed, the jar command can unzip a zipped file:

jar xvf file.zip 

Note that you can install java without root access: http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html

Update: OpenJDK is downloadable for Linux as a tar.gz archive installable without root access here: http://jdk.java.net/17/

The Windows version is however a zip file so that wouldn't help on that OS...

jlliagre
  • 8,691
  • 16
  • 36
12

I haven't tried this, but, there's a zipfile module in Python's standard library since version 1.6, and since version 2.6 has had an extractall method

You should be able to do something like:

  1. Create a file with the following contents (editing it to fit your use case).
  2. Save the file as "unzipfile.py"
  3. Run with python unzipfile.py

And it'll extract test.zip to /home/user/directory.

import zipfile

with zipfile.ZipFile('test.zip', "r") as z:
  z.extractall("/home/user/directory")

Source: https://stackoverflow.com/a/9432315/167299

Alternatively, BusyBox contains an unzip "module", and if you could download and run the statically-linked BusyBox, then you could use that to unzip things.

Tom O'Connor
  • 27,440
  • 10
  • 72
  • 148
3

I don't believe there are other ways of unzipping the file on a system without unzip, but you could send the file to another linux system (with unzip installed or root access available), unzip the file there and - if necessary - send the unzipped file back to the original server.

The command to send a file from one server to another is scp. The syntax to send the file is:

scp <filename> <username>@<otherhostname>:<portnumber><fullpathtolocation>
e.g.: scp file.zip  user@server.example.com:2222/home/user/ 

Hope this helps!

spuder
  • 1,695
  • 2
  • 25
  • 42
2

BSD / Mac OSX

The tar utility that ships with Mac and BSD derivatives, support extracting zip archives from the tar command

tar -xvf foo.zip

tar --version
bsdtar 2.8.3 - libarchive 2.8.3

Debian / RHEL

The tar archive that ships with Ubuntu and others does not support extracting zip files. The best option will be to scp the file to a machine with zip installed.

tar -xvf foo.zip
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

Smoke Test

echo "the quick brown fox jumped over the lazy dog" > bar.txt
zip -r bar.zip bar.txt
rm bar.txt
tar -xvf bar.txt
cat bar.txt
the quick brown fox jumped over the lazy dog

Update

Rewrote answer to clarify that tar -xvf only works on bsd OS's. While it is good information, It will not work in this scenario after all.

spuder
  • 1,695
  • 2
  • 25
  • 42
0

Copy the file to another machine, unzip, and copy back.

dmourati
  • 24,720
  • 2
  • 40
  • 69
0

If the server has Gnome running, use the archive utility

enter image description here

http://www.wikihow.com/Unzip-Files-in-Linux

spuder
  • 1,695
  • 2
  • 25
  • 42