General Linux Shell Usage & Basic 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:

 

SSH:

(CentOS) service sshd restart

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

 

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.

 

  • payment
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What happens when a VPS reaches its bandwidth limit?

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

OpenVZ or Xen VPS - Which is faster, and which is better?

The question is often asked whether OpenVZ or Xen, two of the most common hypervisors in VPS web...

How to Check CPU Info with SSH on Linux VPS

To check the CPU allocation and information on your VPS, simply log in to SSH as root, and run...

Basic iptables Usage & Commands

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

Do I need a VPS? (Shared vs. VPS Hosting)

We often hear the question, "do I need a VPS?" Whether you are looking to upgrade from Shared...