1. Home »
  2. Tech

Guide To Useful SSH Commands

SSH

SSH is a very useful and secure connection to control your own web sever remotely. On Windows you can use PuTTY to connect to your server using SSH. Using SSH can be useful when deleting or moving large number of files at once as this process can take hours when you use FTP client.

Open Directory Using SSH

cd downloads/

Renaming Files Using SSH

mv original_file new_name

Move Folder And Content Using SSH

mv wordpress/* ./

This will move all the files in the directory named wordpress to the current working directory.

Copy Files Using SSH

cp original_file new_file

Where original_file is the original file name and new_file is your copied file name.

Delete Folder And Contents Using SSH

rm -rf foldername/

Database Backup Using SSH

First go to the directory you want your backup to be placed in by typing “cd” followed by the directory path.

Then type the following command to perform the backup.

mysqldump --opt --user='username' --password='password' --host='yourMySQLHostname' 'databasename' > 'nameofyourbackup.sql'

Database Restore Using SSH

First upload your backup file using FTP. Open SSH command window and type ‘cd’ followed by the directory path where your backup is placed.

Then type the following command to restore your backup.

mysql -h 'mysql.example.com' -u 'username' -p 'password' 'dbname' < 'databasefile.sql'