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:

Apache:

(CentOS) service httpd restart

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

 

cPanel:

(CentOS) service cpanel restart

 

MySQL:

(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.

 

Processes

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.

 

Search

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.

bz2.
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.

 

Network

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

ifconfig - Shows info for all configured network interfaces.

 

Misc

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

Installing CSF (ConfigServer Firewall) on a server

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

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....

How to install Python with mod_wsgi on a CentOS VPS or Server with cPanel?

The world knows that cPanel/WHM is not too Django, or python friendly. However, this is a step...

How to Find the folder with most files / inodes?

To find the folder with most files or inodes run the following command:find / -xdev -printf...

How do I upload files large or small to my VPS server?

We don't do posting and going to data centre anymore to upload files.Also uploading via any of...