Basic Linux Commands

Below is a brief guide for basic usage of a Linux shell (command line). Once you've mastered the commands to move between directories and search for files, using a shell will become very efficient!


A few commands to restart common services:


(CentOS) service httpd restart

(Debian) /etc/init.d/apache2 restart



(CentOS) service cpanel restart



(CentOS) service mysql restart

(Debian) /etc/init.d/mysql restart



For detailed information on any of the commands below, type "man [command]" at the command line.



top - Displays a summary of all running processes, with CPU and memory usage for each.

kill -9 PID - Kills a process. Use 'top' to find the PID of a running process.



grep root /etc/passwd - Shows all matches of root in /etc/passwd.

grep -v root /etc/passwd - Shows all lines that do NOT match root.

find /etc -name config - Lists all files in /etc containing 'config' in their name.


File Manipulation

rm filename.ext - Deletes filename.ext.

rm -f filename.ext - Deletes filename.ext, bypassing confirmation.

tar xvfz file.tar.gz - Extracts a .tar.gz file.

bzip2 filename.ext - Zips filename.ext to filename.ext.

bunzip2 filename.ext.bz2 - Unzips filename.ext.bz2 to filename.ext

cp - Copy file.

mv - Moves a file, and can also change a filename.

chown - Change ownership permissions on a file.


Directory Manipulation

mkdir - Creates a new directory with the name you specify, ex. 'mkdir downloads'

cd - Change directory, for example to move to the directory /root, do "cd /root"

ls - List all files in the current directory.



netstat -an - Shows all open connections to the server.

ifconfig - Shows info for all configured network interfaces.



df -h : Displays a summary of total and used disk space.

passwd - Change your account password. If logged in as root, you can specify a user, e.g. "passwd user"

vi - A basic text editor included with all Linux distributions.

touch - Generates an empty file, ex. 'touch index.php' will create a blank index.php.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Migrating/Restoring large cPanel domain from shared hosting account to your VPS server

cPanel facilitates you to restore full domain including email accounts, MySQL databases, database...

Basic iptables usage

Iptables is a program that allows you to configure Linux's built-in firewall. By default, no...

Installing CSF (ConfigServer Firewall) on a server

This guide will walk you through installing CSF on a VPS/Dedicated server. Preparing the server...

How to SSH into your VPS

After receiving your VPS login details, the first thing you'll want to do is log in to the VPS....

What happens when you reach your VPS bandwidth limit?

If your VPS exceeds its bandwidth limit, our system will automatically suspend the service. You...