How pack and unpack archives via SSH
It happens, that some hosting company have inconvenient hosting control panel – and work with files is no possibility, or this feature is bad implemented / this feature is very inconvenient.
FTP manager does not always work – for example, when working with archives. A typical example – Masterhost. Somehow they decided that their customers either do not need to work with the archives, or customers must learn the console commands *nix.
I think, nothing bad in console commands are not present, but personally I do not like when I deprived of choice. I do not like if someone decide how I work with files. That’s why I’ve not hosted my sites on Masterhost. But if the client’s site is hosted on Masterhost – here as say there is no choice, the customer is sacred 😉
Let`s go, run putty and connect.
How to package the files in tar.gz through SSH
tar -zxvf file_name archived_folder
tar -zxvf folder.tar.gz folder/
c – means that you create a new file;
f – by means of this flag is given a name to the archive;
z – archiving will occur via gzip archiver;
v – the console will display information about the process of archiving.
How to pack files into a zip through SSH
zip -r archive_name archived_folder
zip -r logs.zip logs/
r – means that you need to search for files in a folder recursively, otherwise there was one empty folder in the archive.
How to extract the files from tar.gz through SSH
tar -xvf file_name.tar.gz
tar -xzvf archive.tar.gz
How to extract the files from the zip through SSH
One more thing … UNIX console has some tricks that can greatly facilitate the work – such as autocomplete file name. Agree, it would be foolish to unpack, for example WordPress typing the file name “wordpress-4.5.3.tar.gz” manually?
This is not required – the first 2-3 characters is enough to dial and press the “tab” key.
For example, in this case:
tar -xzvf Jo
press the “Tab” and then press the “Enter”