Basic Commands For Your Linux VPS

Basic Commands For Your Linux VPS



As I have seen people running their site on Linux virtual private servers and controlling it through cPanel control panel. In fact they are not aware of simple Linux SSH commands that they can run into shell(command line interface) to check things for an example: Checking CPU/Memory usage or free disk space on the server. So today I am writing this article for those who want to check the server status themselves before contacting technical support for help.

To login into shell(CLI: command line interface) you need to download this software PuTTY from this URL on your PC:

http://www.putty.org/

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Once its downloaded then run it and place a short cut icon of it on your desktop. When you double click it will open and looks like the below image:

Put your server IP in host name field and leave the default port 22 -> Click on Open button.

It will give you access to command line interface asking your username and password. Type in your username as root and press enter. It will ask you for your server password on next prompt. Type in password(you will not see the password while typing  as its a security feature so that no one can see your password while you entering it) and press enter.

Now you are logged in your server using shell access.

ex:
login as: root

[email protected]'s password:
Last login: Mon Jul 22 16:56:24 2013 from 182.170.131.26

Now you can run the following basic commands to check few things:

1> free -m

It will show your server total, used , free & cached memory:

ex:
root@server [~]# free -m

total    used   free   shared   buffers  cached
Mem:   2048     1891   156       0     124      811
-/+ buffers/cache:   955      1092
Swap:            0   0         0

So in the above result, the server is having 2048MB(2GB) memory and out of that 1891MB is under use and only 156MB RAM is free.

2> top -d2

This command will give you a lot of information on current status of server:

First line will give the server time, number of days since server is up and running, users logged in and load average on server.

Second line will tell you total no. of tasks, active/sleeping/stopped/zombie tasks.

Third line will show the CPU usage and followed by fourth and fifth line showing Memory and Swap usage respectively.

Then after that it will show all the process running with their ID, user, % of CPU/Memory used and time.

You can come out by pressing CTRL + C.

Top command

 

 

 

 

 

3> df -h

This command will show you disk space usage details:

In this picture below /dev/sda1 is your root partition which contains all the system files, database, emails & Cpanel accounts.

So the total size of root partition is 50Gb , used 14Gb and available 33Gb.

Disk free command

 

 

 

Sometime I have seen people reporting that MySQL database service is not working on the server and restarting the service from CLI is not working either.

The most common reason for this issue is that you do not have any space left on root partition and that’s is why you are not able to restart service via SSH.

Clear out some space on your server by deleting unwanted emails/files and then restart MySQL service. It will then work.

 

Cheers!


Categories

  • If users are unfamiliar with command line, would you recommend them go with a Managed VPS in that instance?

  • Hi Brad,
    Thanks for your comment.
    We usually would recommend to go for server management if users are not familiar with SSH commands.

  • Hey Vikram,
    Excellent info.Thanks a lot for sharing the helpful commands.These will save my time.

  • No worries, Thanks.