So, you have installed your favorite linux distro and you are sitting in front of it. Probably you must have heard a lot of frightening things about its console. Here you will see some basic linux commands which will help you to get familiar with linux command line. So let's continue with the linux commands cheatsheet.

But first a few words about a very basic command called man. man comes from manual and it works like this man command_name. With this command you can view information on how to use any command of your system. There is even a man page for man! Try typing man man and you ll get the point. So if want further information and details on a command listed below just type man command_name

Lets get started!

Viewing, copying, moving and deleting files

ls Display the contents of the current directory
ls -a Display also hidden files and hidden directories
cp filename /path/dir_name Copy filename into directory /path/dir_name
cp -r dir_name /path/dir_name2 Copy the entire dir_name into /path/dir_name2
cp filename1 filename2 /path/dir_name Copy filename1 and filename2 into /path/dir_name
rm name Remove a file or directory called name
rm -r name Remove an entire directory as well as its included files and subdirectories
mv filename /path/dir_name Move filename into /path/dir_name
mv filename1 filename2 Rename filename1 to filename2
cat filename Display filenames contents
more filename Display filename in pages. Use spacebar to view next page
head filename Display filenames first 10 lines
head -15 filename Display filenames first 15 lines
tail filename Display filenames last 10 lines
tail -15 filename Display filenames last 15 lines
pwd Display current directory
cd /path/dir_name Change to directory /path/dir_name
cd .. Go 1 directory up
mkdir dir_name Create directory dir_name
rmdir dir_name Delete directory dir_name


Finding files and text within files

updatedb Update (create first time used) a database of all files under the root directory /
locate filename Find file filename searching in the database
find / -name filename Starting from the root directory search for the file called filename
find / -name *filename Same as above but search for file containing the string filename
grep string /path/dir_name Starting from /path/dir_name search for all files containing string
which application_name Search $path for application app_name
whereis application_name Search $path, man pages and source files for application_name


Archived files


tar -xzf filename.tgz Decompress tzg file
tar -xzf filename.tar.gz Decompress tar.gz file
tar -xjf filename.tar.bz2 Decompress tar.bz2 file



tar -czf filename.tar /path/dir_name Compress directory /path/dir_name to filename.tar
gzip -c filename > filename.gz Compress /path/dir_name to filename.tar.gz
bzip2 -c filename > filename.bz2 Compress /path/dir_name to filename.tar.bz2


Using rpm files 

rpm -hiv package.rpm Install rpm called package.rpm
rpm -hiv --force package.rpm Install rpm called package.rpm by force
rpm -hUv package.rpm Upgrade rpm called package.rpm
rpm -e package.rpm Delete rpm called package.rpm
rpm -qpil package.rpm List files in not-installed rpm called package.rpm
rpm -ql package.rpm List files in installed rpm called package.rpm
rpm -q str List installed rpms containing the string str
rpm -qf /path/application_name Display the rpm that contains application application_name


Starting and Stoping 

startx Start the X system
shutdown -h now Shutdown the system now and do not reboot
Same as above
shutdown -r now Reboot
reboot Same as above
shutdown -r +10 Reboot in 10 minutes


Mounting filesystems

mount -t vfat /dev/sd(a)(1) /mnt/c_drive Mount the first partition 1 of the first hard disk drive a which is in fat32 vfat dormat under /mnt/c_drive directory
mount -t iso9660 /dev/cdrom /mnt/cdrom Mount cdrom under /mnt/cdrom directory
umount /mnt/hda1 Unmout the above


User administration

users Display users currently logged in
adduser username Create a new user called username
passwd username Define password for user called username
who List logged-in users
whoami Display current user
finger username Displays info about user username
su Log in as root from current login
su - Log in as root from current login and take root's path
exit Exit from console login (ie, logout).



command Execute command in the foreground
command & Execute command in the background
ctrl+z Suspend a program
ctrl+c Interrupt a program
ps List all processes
kill -9 pid Kill process with id pid
top Monitor processes in real time



hostname List the system's hostname
ifconfig Set/Display network information
host ip Resolves ip's hostname
ping ip/hostname Check if ip/hostname is reachable
traceroute ip/hostname Find network path to ip/hostname


System Information

uname -a General system information
fdisk -l List partition tables
cp filename /path/dir_name Copy filename into directory /path/dir_name
df -T -h List filesystem disk space usage
lspci List PCI devices
lsusb List USB devices
free -m Display RAM+Swap usage


Program Compile

gcc -o output file.c Compile a C program
./output Run a C program you have compiled
g++ -o output file.cpp Compile a C++ program
./output Run a C++ program you have compiled
./configure && make && su -c 'make install' Configure, compile and install a program with Makefile

Comments (36)

Subscribe to this comment's feed
Sum what OK
srini , July 13, 2007
nice command thanx for fedora
pradeep , November 20, 2008
thanks for your work
by , December 07, 2008
thanks,it's very useful to me.I'm a novice in the area fedora
jack li , December 11, 2008
Thank you guys! smilies/cheesy.gif
axel , December 11, 2008
Thanks You Very Much....
It will help a lot . smilies/grin.gif smilies/cool.gif
hanmant , December 20, 2008
Now in found them. thanks alot
estiko , January 13, 2009
Think you ,I need it!!
manna , February 14, 2009
A great list of commands. Some suggested changes:

rm -r name: Change 'as long as' to 'as well as'
rpm -hiv --force package.rpm: Change 'in force way' to 'by force'
rpm -qpil package.rpm: Change 'not installed' to 'not-installed'
rpm -q str: Change 'rpms installed containg' to 'installed rpms containing' (typo here)
shutdown -r 10: This should be 'shutdown -r +10'. The command, as listed, would wait until 10:00 system time.
mount -t vfat /dev/hda1 /mnt/c_drive: Put '1' and 'a' in brackets [(1) and (a)]. Change 'dormat' to 'format'. Also, shouldn't '/dev/hda1' be '/dev/sda1' now?
who: Change 'logged in' to 'logged-in'
exit: Add after 'Exit': 'from console login (ie, logout)'
top: Change to 'Monitor processes in real time'
hostname: Change to 'List the system's hostname'
geoff_f , February 27, 2009
Thanks for your comment and suggestions geoff_f! I have made all the changes you propose.

I wrote this commands list a couple of years before and haven't updated since then. So, yes hda1 should be sda1 now.

axel , March 01, 2009
Please Give Me more Commands for display the output & how to compile the program
Amol Divekar , March 11, 2009
Ok Amol Dicekar. I will post more commands this weekend or sooner if I find some time. smilies/smiley.gif
axel , March 11, 2009
thank you~~~~
ys_sunshine , August 13, 2009
Basic Linux Commands
Thank you for the List of Basic Commands for Linux. I have a final practical exam coming up and this is one of the nicest finds so far, since I am allowed to use any notes I want during the practical exam. In 11 weeks of class, who can expect anyone to remember the commands and syntax. I hope to find a little more advanced linux command sheet tonight as the test is tomorrow. Kind of focusing around a Network Administrator who has to be able to do the administration for Linux using the command line.
flyboydale54 , August 18, 2009
I hope you've passed your exams flyboydale54 smilies/wink.gif

Linux commands seem a little frustrating for everyone at the beginning but once you use them a 'few' times you can't use Linux without them. smilies/wink.gif
axel , August 31, 2009
أحـــــــــلى شششرح تسسلم يا مبدع smilies/grin.gif
Hack-_!_ , November 05, 2009
I'm sorry Hack-_!_ for not being able to understand what you wrote (google translate didn't help me smilies/sad.gif ). From the smile I believe it's something good. smilies/wink.gif
axel , November 07, 2009
thanx for these commands sir, i really need of them. smilies/smiley.gif
Faiza , November 09, 2010
Thank you
These are very useful commands.Thanks for giving me such a nice information.
shireen , June 06, 2011
command lines
where could i find an app to teach command lines?
kanimambo , August 07, 2011
thank you
hi friend thank you very much!...
grate job.
since i expect more from u
sathish kumar , August 20, 2011
Iam luvin it!!
thanx ppl!!!u hav made ma work more simple...smilies/cheesy.gifsmilies/smiley.gif
prathibha karthikeyan , September 11, 2011
Linux commands are useful smilies/cry.gifsmilies/cry.gifsmilies/cry.gif
shreeshail.Basappa.Ourasang , September 15, 2011
Thank you
Thank you for the time to prepare these wonderful and helpful linux cmd. Very much appreciated. Cheers.
JASH , November 05, 2011
These commands are very useful ans easy to understand due to classification. smilies/smiley.gif
Sonal Dhangare , July 12, 2012
Thank you for the time to prepare these wonderful and helpful linux cmd. Very much appreciated. Cheers.
Sangeet Shah , August 28, 2012
top commands in linux
tis s very useful to me..........i need it.......
Janani , October 08, 2012
This is very helpful to me....
Thank so much.....
Hein Minn Soe , March 06, 2013
Thank you for the command list!smilies/smiley.gifsmilies/smiley.gif Just one correction I see - The Starting and Stoping?? I think you meant Stopping.smilies/wink.gif ET
Ernest Tolman , May 26, 2013
hope this will help with my interview tomorrow. I like it how you reply to everybody comments. hint
max , June 12, 2013
meethi command enga da????
arunkumarfghdhgh , July 04, 2013
RPM commands vs ARM linux server
I have QNAP 219P II which linux NASBACKUP arm5 tel is installed on it. I'm struggling with this machine to add the php oci8 in order to connect to an oracle database.
I followed many ways I found in Internet but no much success so far. As this machine is a small server, some commands such as rpm, yum are not supported.
Is there any hope to get these commands installed on this machine?
Best regards,
Abdel , September 08, 2013
Thanks for ur cmmand it is very useful for me
gopi , December 18, 2013
thanks for these command . smilies/smiley.gif
Dipesh Pandey , January 31, 2014
thanks for these commands
Dipesh Pandey , January 31, 2014
Top tip, thanks a million
darragh , February 12, 2014

Write comment

smaller | bigger
security image
Write the displayed characters



Login Form

Follow me on...

  • Facebook
  • Twitter
  • Google+: u/0/b/113039112812192417058/
  • Digg
  • Reddit: myguides
  • RSS Feed
  • e-mail

Member Login