My Unix Commands for CentOS & RedHat

By | November 14, 2012

The listed Linux commands are most common with my web development. Other commands get into greater detail in bellow Resource section.

# cat /etc/redhat-release
To find out the CentOS distro version.

# cat /etc/issue
To find out the Ubuntu distro version.

# cd
change directory

# du -sch *
Breakdown of disk usage. (-a, -d, -H, k, L, s, x)

# kill -9 PID
To kill a process.

# ls
This will list what is inside current directory.

# ln
Link files together.

# ln -s
Creates soft link for files.

# mkdir
Make Directory

# mkdir blabla
This makes the directory /blabla/

# mv
Move files

# mv * ..
Moves all files to root

# netstat -p
Monitoring ports.

# ps aux | grep java
To look for a specific process. This example returns the owner and the PID, along with other information, such as the percentage of CPU and memory usage, size of the command, time the command was launched, and the name of the command.

# pwd
This will display your current directory.

# rmdir
This removes directory.

# rm -fr
Removes all the files from directory.

# rm -r
Removes the entire directory.

# su root
Switch to super user mode or root.

# vmstat 5 10
The preceding command runs vmstat every 5 seconds for 10 iterations.

# watch free
You will see the output of the free command updated every 2 seconds. This is similar to “Ctrl-Alt-Del” in Windows, it shows your RAM availability.

# df -h
That’s going to tell you how much disk usage you’re actually using on your server.

Definitions:

ps = process
ps -A = lists all process runing
ps -a = local & all other shell users
ps = local
who = who is logged on

Resources:

CentOS is a free operating system, derived entirely from Red Hat Enterprise Linux: http://en.wikipedia.org/wiki/CentOS
Helpful Linux Commands: http://www.linuxforums.org/forum/misc/93765-putty-commands.html
Linux and Unix rm Commands: http://www.computerhope.com/unix/urm.htm
Manipulating Files & Folders: http://www.westwind.com/reference/os-x/commandline/files-folders.html
du (Unix) Usage: http://en.wikipedia.org/wiki/Du_(Unix)
Linux Consulting: http://frankmash.blogspot.com/2007/11/ln-s-examples.html