Using SSH and its Commands

Keyboard ImageI have put on this list so maybe someone can benefit from it and I don’t have to keep a list of this commands for myself. This is a basic commands list for SSH. You can use them on your own risk. Because I will not be held responsible if you mess up your server.

I don’t know what utility you might be using for accessing SSH terminal but I use Putty. It can be downloaded from here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Command: cd
Explanation: Changes directory
Result: cd /usr/local/src [Takes you to the /usr/local/src directory]

Command: chmod
Explanation: Sets permissions for the files/folders
Result: chmod 777 /usr/local/src/filename.txt [Sets 777 Permission for the filename.txt]

Command: pico
Explanation: Pico is a text editor for Unix computer systems
Result: pico /usr/local/src/filename.txt [Edit the filename.txt file]

Command: touch
Explanation: Creates an empty file
Result: touch /usr/local/src/filename.txt [Creates the filename.txt file in /usr/local/src/ folder]

Command: cp
Explanation: Copies a file
Result: cp filename.txt filecopy.txt [Copies the filename.txt file as filecopy.txt you can also specify the input or output directory paths for copying files in other directories.]

Command: mv
Explanation: Moves a file
Result: mv /usr/local/src/filename.txt /usr/local/backup/filecopy.txt [Moves the filename.txt file as filecopy.txt in /usr/local/backup/ folder.]

Command: rm
Explanation: Deletes a file
Result: rm /usr/local/src/filename.txt[Deleted the filename.txt file]
Others: 1) rm -f filename.txt [Doesn’t asks for confirmation upon deleting.
2) rm -rf src/ [Removes the directory as well as all files and subdirectories in it]

Command: wget
Explanation: Gets file. Downloads the file onto your server.
Result: wget http://www.keralpatel.com/index.php [Gets the index page of this site in the directory you execute this command]

Command: mkdir
Explanation: Makes an empty directory on your server.
Result: mkdir /usr/local/src/tmp [Makes an empty directory named tmp in /usr/local/src/ folder.]

Command: tar
Explanation: Extracts .tar.gz and .tar files
Result: tar -zxvf filename.tar.gz [Extracts the .tar.gz file]
Others: 1) tar -xvf filename.tar [Extracts the .tar file]

Command: unzip
Explanation: Unzips the files onto the server.
Result: unzip filename.zip [Extracts all the contents of the filename.zip on the server]

Command: service
Explanation: Start/Stop/Restart services on to the server.
Result: service httpd restart [Restarts the Apache web server]

Command: mysqladmin
Explanation: MySql interface for executing commands on MySQL server.
Result: mysqladmin drop dbname [Drops the dbname database]
Others: 1) mysqladmin create dbname [Creates the new database called dbname]
2) mysql -u uname -p pass dbname < dbname.sql [Restores the dbname database. Where uname is the username, pass is the password for that user and dbname is the database name]
3) mysqldump -u uname -p pass dbname > dbname.sql [Creates the backup of dbname database. Where uname is the username, pass is the password for that user and dbname is the database name]
4) mysqlcheck –all-databases -o [Optimizes all the databases on the server]

You Might Also Like