Compress Folder in Terminal

Problem

We need to copy a large amount of files but we don’t want to type in every file name and want to save space. So basically we want to compress a folder (or files) in terminal.

Compress folder in terminal

We have many alternatives on this topic, to keep it simple I’ll be using the zip command.

zip -r output.zip folder

A real example would look like

zip -r backup.zip uploads/

This will produce a neat file with all the contents from the folder we want to compress.

Extract files in terminal

We’ve learned how to compress folder in terminal and now we need to learn how to extract files in terminal so that we can actually use our files.

unzip backup.zip

This command will extract the contents of the archive exactly as they were before they were zipped.

Conclusion

You can copy files using SSH terminal and move it between your servers using this way. Compressing saves space and makes everything easier.

Copy files using SSH Terminal

Problem

Sometimes we need to copy large files from one terminal to another. We want to do this by using the SSH terminal Secure copy (scp) program to copy the files. So lets copy files using SSH Terminal.

There are simple terminal commands that go hand in hand on this task.

Copy files using ssh

scp [email protected]:remote_path local_path
scp [email protected]:/home/old/public_html/backup.zip /home/new/public_html

Your local terminal will connect to the remote terminal and start to copy the file(s) in the specified path. After you execute the command you will be asked to provide the password of the machine you’re trying to connect to.

The progress will be displayed by the scp progress indicator.

scp progress indicator