How to Use Basic Linux Commands on Your VPS Server

How to Use Basic Linux Commands on Your VPS Server

Linux is an open-source operating system that powers a majority of web servers and thousands of personal computers. Built around the Linux Kernel, the operating system comes in different distributions for both desktops and servers, including Ubuntu, CentOS, CoreOs, Arch Linux, Fedora Debian among others.

Although the distributions may differ in some ways, there are common Linux commands that work in all of them. In this guide, we will focus on how you can utilize the power of these basic Linux commands to manage your system better.


  • A VPS plan running any Linux distribution>
  • Shell access to your server

# 1: Linux cd command

In Linux cd is an acronym for ‘change directory’.  This command is useful if you want to change to a different working directory. For instance, to move to the ‘var’ directory, type the command below:

$ cd /var

The command is also useful if you want to navigate one directory up. To do this, just type the cd command followed by two dots:

$ cd ..

# 2: mkdir

Linux ‘mkdir’ stands for ‘make directory’. The command allows users to make new directories using the syntax below:

$ mkdir <directory name>


$ mkdir sample

# 3: pwd

Another great command is pwd which means ‘print working directory’. This command shows the current directory that you are working from. To use the command just type the command below on your terminal window:

$ pwd

Sample output:


# 4: cp

cp command is used to copy a file using the syntax below:

$ cp <source> <destination>

For instance, to copy the file ‘sample.txt’ to ‘sample2.txt’ on the same directory, we can use the command below:

$ cp sample.txt sample2.txt

Please note you must have the right permissions to copy files to a directory.

# 5: mv

When you are moving files in Linux, you can use the mv command by typing the command below:

$ mv <source> <destination>

For instance, to move the file ‘sample.txt’ from the working directory to the downloads directory,  we can use the command below

$ sudo mv sample.txt  /downloads/sample.txt

# 6: ls

The ls command is used in Linux to list the contents of a directory. For instance, to list the contents of our ‘/var’ directory, we can type the command below:

$ ls /var


backups  crash  local  log   opt  snap   tmp
cache    lib    lock   mail  run  spool  www

# 7: cp -a

You can use the cp -a to copy a directory. For instance, to create a backup of our mail directory, we can use the syntax below where ‘mail.bk’ is then the name of our new directory:

$ sudo cp -a /var/mail /var/mail.bk

# 8: chmod

chmod is used to change the permissions of a directory. For instance, we can alter the permissions of ‘var/www’ directory by typing the command below:

$ chmod 755 /var/www

In the above example, full access is maintained for the current user while other people are kept from modifying the files in that directory.

A permission of 755 means that the owner of the file will have read, write and execute permissions while the group and other users on the system will only have read and execute permissions only

# 9: chown

You can change the ownership of a file or directory in Linux by using the ‘chown’ command.

Basic syntax:

$ chown [options] <new_user> <file_or_directory>

For example, to change the ownership of ‘/var/www/’ folder to a user named ‘francis’, we can use:

$ chown -R francis /var/www/

Please note we have used -R command line option in order to change ownership of all files and directories inside our target directory recursively.

You can also use chown command to change both the owner and group of the file using the below syntax:

$ chown new_user:new_group <file_or_directory>

For example:

$ chown james:www-data /var/www/

# 10: free

You can check the total used and available memory on Linux by using the free command:

$ free

Sample Output

              total        used        free      shared  buff/cache   available
Mem:         595512      394600       71196       17144      129716       90124
Swap:             0           0           0

# 11: df

Use the df command to get a report about the disk space on your Linux server.

$ df

If you want to get the information in a human readable format, use the  -h option

$ df -h


Filesystem      Size  Used Avail Use% Mounted on

/dev/sda1       9.6G  1.8G  7.8G  19% /


# 12: rm

Use rm command to completely delete a file from the system

$ rm <filename>


$ rm sample.txt

You can also delete a directory using the the rm command with a -r option


$ rm -r /tmp/sample

Ensure you have the right permission to delete the file or use sudo to do the task.

To remove a directory use the rm -f command as shown below:

$ rm -f <directory name>


$ rm  -f mail.bk

# 13: date

To get the current date and time of your Linux server, use the date command as follows:

$ date

Sample Output

Thu Aug  9 12:52:59 UTC 2018

# 14: reboot and shutdown

To restart your Linux VPS server, type:

$ sudo reboot

To shut down the server, type the command below:

$ sudo shutdown -h

# 15: touch

In Linux, the touch command is used to create new files. For instance to create a new file on your current folder, run the command below

$ touch sample.txt

# 16: cat

You can display the content of files in Linux by using the cat command.

$ cat sample.txt

Or to combine the content of multiple files run the command below:

$ cat sample1.txt sample2.txt

You can also append the content of the concatenated files to a different file e.g. sample3.txt using the command below:

$ cat sample1.txt sample2.txt >> sample3.txt

# 17: more

Use the more command to read the content of a file one screen at a time:

$ more sample.txt

# 18: grep

If you want to search for a certain text in a file, you can use the linux grep command.

The basic syntax is:

$ grep '<keyword(s)>' <file_name>

For instance to look for the phrase chemist in a file named sample.txt, type the command below:

$ grep 'chemist' sample.txt

Sample Output

Our chemist was filled with water during the floods

Please note, if your keyword is found, it will be highlighted in red.

# 19: history

This command will display a list of previously used commands:

$ history

Sample Output:

1  free
2  df -h
3  date
12  grep chemist sample.txt
14  history


To reuse a previously used command type the ! character followed by the numeric key associated with the command.

For instance;

$ !3

# 20: clear

Sometimes the screen may get filled with lots of commands and output. To clear these, run the clear command:

$ clear

# 21: traceroute

You can track the route followed by packets from your computer to a given host.


$ traceroute


traceroute to (, 30 hops max, 60 byte packets
 1  localhost (  0.052 ms  0.004 ms  0.003 ms

# 22: ifconfig

ifconfig stands for Interface Configuration use this command to query network interface parameters

$ ifconfig

Sample Output:

ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1460
        inet  netmask  broadcast
        inet6 fe80::4001:aff:fe8e:2  prefixlen 64  scopeid 0x20<link>
        ether 42:01:0a:8e:00:02  txqueuelen 1000  (Ethernet)

# 23: ssh

Use Linux ssh command to connect to another remote server:

$ ssh <server's IP/Domain_name>


$ ssh

# 24: wget

You can download files in a Linux machine using the wget command using the below syntax

$ wget <URL>


$ wget


I hope you have enjoyed reading and testing the basic Linux command that works on all distributions. Although this is not a conclusive list of all commands available on Linux, they can give you a better foundation of managing your Linux server as a beginner.

Check out these top 3 Linux hosting services

$1.79 /mo
Starting price
Visit FastComet
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Set Up SSH on a CentOS 7 VPS from a Windows Client

Download puttygen into the Windows machine as shown in figure 1. Then sta
4 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Connect to a Server by Using SSH on Linux and Mac

Most servers in the world are run on Linux servers. They’re dependable, afford
4 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

Use Python to Automate Routine Tasks on Your VPS or Dedicated Server

Here we'll use basic knowledge of Python to teach you how to leverage the extrao
6 min read
Md. Ehsanul Haque Kanan
Md. Ehsanul Haque Kanan
Hosting Expert provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top