Useful Unix Commands

Many people ask, where to start learning Linux.

Answer 1: Install Ubuntu on pen drive and boot your system. It wont disturb your existing OS. You can save files too on pen drive.

Answer 2: Search in google for free unix shells or free unix accounts.

Download Putty.exe and start accessing free unix accounts.

======== Basic Commands ========

Clear all screen

See all commands you typed before

Shows date


Man means manual
>man cal

======== CHECK LOGS ========

Prints server.log file on console while app is running
>tail -f server.log

Shows last 100 lines
>tail -100 server.log

Shows first 100 lines
>head -100 server.log

Shows one page at a time
>more server.log

Use cat for small files. This prints whole file on console
>cat server.log

======== CHECK Processes ========

To see all running process
>ps -ef

To check specific process
>ps -ef | grep process name

======== Disk, CPU, Memory Usage ========
Check Disk Space

Check CPU Usage


Direcotry space in Unix
>du -sh dir1

To get CPU Details
>cat /proc/cpuinfo

uname will help us to find given os is 32 bit or 64 bit.

>uname -m
i386 / i686 ==> 32 bit
x86_64 ==> 64bit

To get OS information
cat /proc/version

To get CPU Usage
>ps -e -o pcpu,cpu,nice,state,cputime,args -sort pcpu | sed ‘/^ 0.0 /d’

Memory Information

>cat /proc/meminfo

To do profiling

>free -m

======= VI Commands ===========
Please check any VI Commands cheat sheet

>vi file name

Takes to end of the file
>shift g

To quit
>esc :q!

To write
>esc :w!

======= Compress/Decompress Commands ===========

$tar -cvf file1.tar a.txt

$tar -xvf file1.tar


$gzip a.txt
Output: a.txt.gz

$gunzip a.txt.gz
Output: a.txt


How to change prompt to present working directory?

>export PS1=’$PWD>’

Search in google to get more command lists


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s