How to unpack large archived files on the server using SSH

If you have a large zipped file (.zip, .tar, tar.gz) and you need to unzip on the server, it can take a long time using the file manager. The process may also be affected by your internet connection. The best way to overcome this is to use SSH.

To start a secure shell (SSH) session, you need an SSH client. Windows users can install a free client called Putty (a Google search of "Putty" will find the download pages for you), whilst Mac OS X users already have the Terminal built-in – look in Applications > Utilities.

Using Putty:
Under "Host Name" enter your server name or server IP address.

Ensure SSH is the selected protocol, using port 22 – and click on "Open"

A session window will open with black screen, showing "login as:" – type in "root" or user username and press Enter.

At the prompt, type in your main server root password and press Enter (your password will not be visible, so type carefully and remember that it is case-sensitive).

If no error message is displayed, you are now logged in to your document root. If your archive is in the root, type "ls" (lower-case L) to list the contents of that directory. You should now see your archive file listed.

If the archive is in a lower directory, you first need to change directory to where the archive is.
To change directory, type:
cd directoryname

Then press Enter. Now type "ls" to list the contents of this directory. When you are in the right directory where your zipped file is located, you can now enter the commands to unzip it.

To unpack a .zip file, simple type:
unzip yourfilename.zip
and Enter – you will now see the files inflating.

To extract a file compressed with tar (e.g., yourfilename.tar), type:
tar xvf filename.tar

To extract a file compressed with gunzip (e.g. yourfilename.tar.gz), type:
tar -zxvf yourfilename.tar.gz

Tagged:

Comments

  • I have done this but looks like there is ownership or permission issue. How can I change ownership so I can see the contents of the folders?

  • edited December 2016

    This can be done with this command:

    sudo chown -R cpaneluser /home/cpaneluser/public_html

Sign In or Register to comment.