Knowledge Base
Categories: ,

Cloud VPS and Dedicated Server SSH Primer


We typically expect our Cloud VPS customers to have a higher level of knowledge when managing their hosting, but if you're new to command line interfaces (CLI), that's okay, too!

To help you get started, here are some basic commands you can use with your cPanel VPS. Many of these commands will work on our shared hosting as well, but the target of this particular guide is users who will have root access to the machine.

Using SSH (for Windows or Mac)

You can use the Cloud Command console, but a dedicated SSH client is usually better. It is helpful to remember that the console is available to you because you can use it when SSH is unavailable (a common one being that the firewall has blocked you from connecting).

For Windows

A great and free SSH client is PuTTY. You can find it here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. 
Any SSH client will work; these two are known to be powerful and freely available.

For Mac/OSX

If you're using OSX, you're already on a Unix-based operating system, so there's one called Terminal. Open Terminal to SSH into your server.

Getting Connected via SSH

Both Xshell and PuTTY have a number of advanced features that go beyond the scope of this guide, but they're worth exploring if you have the time. To connect to your Cloud VPS:

  1. Provision and configure your Cloud VPS
  2. Enter the server's IP address or domain name and the port (default is 22)
  3. Enter your username and password when prompted

The default administrative user is 'root'; the default password will be shown in Cloud Command. You'll notice that nothing shows up when you type the password. That's normal, don't fret!

Tip! Highlighting text adds it to your clipboard, and right-clicking will paste it into the application you're currently using. Don't press CTRL+C to copy, as this cancels any in-progress actions in Linux.

WARNING: When logged in as the 'root' user there are very few things the operating system will prevent you from doing, even things that will irreparably damage the operating system, so take care when you execute commands. It's advisable to be logged in as a non-administrative user when possible, and utilize the 'su' and 'sudo' commands that require elevated permissions. Logging in as root is not inherently dangerous, but it's important to understand what you're doing.

Basic Commands

These are specifically for our standard CentOS cPanel image, but most commands are universal.
Note: do not include the ' when you are typing commands.

 cd <directory> - lets you traverse directories; for example, cd / will put you in the '/' directory, and cd /home/ puts you in the '/home/ directory'; using this command without any modifiers will return you to your current user's home directory

Note: you can experiment with directory traversal by cd'ing into a directory, typing ls to see the files and directories in your current directory, and then changing into one of the new directories. cd .. will move you up one directory.

  • ls - list directory; will show you what files and folders are in the directory you're in; for a more detailed view, use ls -l
  • apf -u <IP address> - un-ban a previously blocked IP address in the firewall we install by default - APF
  • su <user> - changes the current user account to the one selected; without any modifiers (just typing in su) it will attempt to switch to the superuser (typically 'root')
  • exit - exits the current session; if you're logged in as another user using su, this will bring you back to your root session, or if you're logged in as root, it will close the session entirely
  • mv <target> <destination> - used to move and rename files; to keep a file in the same pace, but change its name, you'd type mv oldfilename newfilename; to move it to another location type mv oldfile /path/to/newfile

Resource Management Commands

Here are a few commands that can help you identify and review which processes are running on your server and what resources they are using. Many of these commands go very in-depth, but we're just providing a little info to give you an idea of what is available.

  • ps aux - displays all running processes; the 'a' tells it to display all processes associated with a user (except processes not associated with any terminal) rather than just the current user; the 'u' provides more detailed information about the running processes; 'x' adds processes that do not have a controlling terminal to the process
  • top - similar to the task manager in Windows; refreshes periodically and displays the currently running processes (as opposed to ps, which offers a snapshot of running processes); useful options are SHIFT+M and SHIFT+P, which will sort by memory usage and processor usage
  • mysqladmin processlist - displays running MySQL processes
  • netstat - like ps, but instead of running processes, it displays information about network connections
  • sar - very useful when investigating a crash; sar -q shows historical load data while sar -r displays memory usage
  • vmstat - collects and displays a summary of information about your computing resources; vmstat one will run vmstat each second and can be useful to monitor raw resource usage

Modifying and Executing Files

There are a couple of text editors built in, and several more that you can install if preferred. Two good options are vim and Nano. Nano is much more user-friendly, so I'd suggest using that unless you want to teach yourself vim. Neither is more effective than the other in terms of the end product, so it's entirely your preference. The commands to edit an existing file and the command to create a new one are the same: nano <filename>.

There are a number of useful scripts provided by cPanel in the '/scripts' directory. To look through them, you can move to that directory by typing cd /scripts and then show the contents by typing ls. To restart your web server (not your VPS, just the program that serves your websites - typically Apache), you can execute the command /scripts/restartsrv_httpd. To execute a command in your current directory, type ./


Linux systems have a file permission system that determines which users can access a file and what they can do with it. The permissions are broken down into three classes: the user, the group, and others. There are several bits used to determine these permissions: read, write, and execute. Each of the three classes has these permissions. If you type ls -l, for example, you might see an entry like drwxr-xr-x 2 root root 4096 May 15, 2012, perl5/

That entry tells us:

  • drwxr-xr-x - a directory (the leading 'd') that the user who owns it can read, write, and execute the file (the rwx); members of the group associated with the file can read and execute the file but cannot modify it (the first 'r-x') and that other users can read and execute but not modify the file (the second 'r-x')
  • 2 - tells us the number of linked hard links
  • root - the owner of the file
  • root - the group associated with the file
  • 4096 - the size of the file
  • May 15, 2012 - the modification date of the file
  • perl5/ - the name of the file (or folder, in this case)

This may seem like a lot to take in, but it's important to at least have a basic understanding. These file permissions affect how easily your site can be compromised and can cause many problems if misconfigured. Permissions can also be represented by numbers, which you will see in cPanel. 'read' permission adds 4, 'write' adds 2, and 'execute' adds 1 for the affected class. Therefore, the above example would be 755 - 4+2+1 for the owner, 4+1 for the group, and 4+1 for everyone else. This is a relatively safe configuration because it means that only the file owner can modify it.

Many commands have help files that explain the command and can show you what the allowed flags are (the operators following the dash in a couple of the previous examples). To read an existing help file, just type the command followed by --help. For example, chmod --help shows the help page for the chmod command. In addition to (and sometimes instead of) the --help flag, most programs/commands have a manual page. To view it, type man <command>. The 'man page' is often much more in-depth than the help information and will often contain examples.

Did you find this article helpful?

* Your feedback is too short