Professional Documents
Culture Documents
Switching to Linux was a wonderful decision, now it's time to explore its power
- the command line!
So you have just switched to Linux and trying to figure out what was the fuss about the command prompt
as the most powerful tool. Well here's a list of Linux commands for a beginner to help you get a glimpse of
what the command prompt can do for you.
VIEW ING, COPYING, MOVING AND DELETING FILES
ls
ls -a
cp filename /path/dir_name
cp -r dir_name /path/dir_name2
cp filename1 filename2
/path/dir_name
rm name
rm -r name
mv filename /path/dir_name
mv filename1 filename2
cat filename
more filename
head filename
tail filename
pwd
cd /path/dir_name
cd ..
Go 1 directory up
mkdir dir_name
rmdir dir_name
Update (create first time used) a database of all files under the root
directory /
locate filename
Starting from the root directory search for the file called filename
Same as above but search for file containing the string filename
grep string
/path/dir_name
ARCHIVED FILES
Decompress
Compress
rpm -e package.rpm
rpm -q str
rpm -qf /path/application_name Display the rpm that contains application application_name
shutdown -h now
halt
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
umount /mnt/hda1
USER ADMINISTRATION
users
adduser username
passwd username
who
whoami
finger username
su
su -
exit
PROCESSES
command
command &
ctrl+z
Suspend a program
ctrl+c
Interrupt a program
ps
kill -9 pid
top
NETW ORKING
hostname
ifconfig
host ip
ping ip/hostname
traceroute ip/hostname
SYSTEM INFORMATION
uname -a
fdisk -l
cp filename /path/dir_name
df -T -h
lspci
lsusb
free -m
PROGRAM COMPILE
gcc -o output file.c
Compile a C program
./output
./output
1. find: Use this command when you need to search for files in a particular directory. It
starts from the parent directory and then moves to the sub directories. The name option
makes the search case sensitive, while the iname option searches irrespective of the case.
2. grep: You use the grep command in order to find lines in a particular file that match a
given string or words.
3. man: The man command is used as the manual pager for the system. It brings online
documentation for a particular command.
4. ps: This is the process command, which shows you the status of all the processes that
are being run by a unique id, known as the PID.
5. kill: This command is used in order to kill a process that is not responding or is not being
used. All you need is to known the process ID or PID. To find the process id, you need to run
ps-A with the grep command (ps-A | grep processname).
6. whereis: When you need to locate the binary, sources and the manual page of a
command you use the whereis command.
7. service: This is the command that is used in order to control the start, stop or restart
function of a particular service. You do not have to restart your system in order to start,
stop or restart the services.
8. alias: This is a built in shell command which is used in order to assign the name for a
long command or for a frequently used command.
9. df: Use this command when you want to report the disk usage of a file system. It is quite
useful for the user and also for the system admin.
10. rm: This command is used in order to remove complete files and directories from your
system.