Linux Commands: A Introduction
Sunil Kumar
July 24, 2014
Contents
1 The Shell 1
2 Linux Command 1
2.1 Syntax of Command . . . . . . . . . . . . . . . . . . . . . . . 1
2.2 Command Help . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 File and Directory Management . . . . . . . . . . . . . . . . . 3
2.4 Text processing . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.5 Process management . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 System Management . . . . . . . . . . . . . . . . . . . . . . . 6
2.7 Miscellaneous Commands . . . . . . . . . . . . . . . . . . . . 7
1 The Shell
Shell is command line interpreter, that provides the interface for Linux sys-
tem. It take input from keyboard as command and transfer to operating
system kernel to carry out. In GUI, KDE uses konsole and GNOME uses
gnome-terminal to interact with the shell.
Shell has two type of shell prompt: $ and #, which represents user level
and root(system administrator) level interaction respectively. User or root
use a set of command on the shell to interact with Linux system.
2 Linux Command
2.1 Syntax of Command
Most commands operate in following manner:
command -options arguments
1
2.2 Command Help
type - Display information about command type
Argument: command-name
which - Locate a command
Argument: command-name
help - Display reference page for shell builtin
Useful options: shell in-build command
Argument: command-name
man - Display an on-line command reference
Argument: command-name
info - Display an info document of a command (all about the com-
mand)
Argument: command-name
whatis - display manual page descriptions
Argument: command-name
apropos - search the manual page names and descriptions
Argument: command-name
whereis - locate the binary, source, and manual page les for a com-
mand
Argument: command-name
alias - Dene or display aliases of a command
Useful options: -p
Argument: command-name
unalias - Remove each NAME from the list of dened aliases
Useful options: -a
Argument: command-name
2
2.3 File and Directory Management
pwd - Display present working directory
cd - change current working directory
Argument: path of new directory
Special cases
cd : change to users home directory
cd . : change to current directory
cd .. : change to parent directory
cd - : change to previous directory
mkdir - Make directory
Argument: Directory-name
rmdir - Remove an empty directory
Argument: Directory-name
ls - list directory contents
Useful options: -a, -A, -D, -h, -l, -r, -R, -S, -t, -1
Argument: directory-name
cp - copy les and directories
Useful options: -a, -f, -i, -l, -R, -r, -S, -u, -v
Argument: source le/s or directory/s and destination le or direc-
tory
rm - remove les or directories
Useful options: -f, -i, -r, -R, -d, -v
Argument: le or directory name
mv - move (rename) les
Useful options: -f, -i, -t, -v
Argument: source le/s or directory/s and destination le or direc-
tory
3
touch - change le time-stamps
Useful options: -f, -i, -d, -t, -v
Argument: le-name
file - determine le type
Argument: le-name
more - view the contents of a text le one screen at a time
Comment: Allow only forward navigation but limited backward nav-
igation through the le
Argument: le-name
less - view the contents of a text le one screen at a time
Comment: Allow both forward and backward navigation through the
le
Argument: le-name
chmod - change le mode bits
Comment: Each MODE is of the form
[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+.
Argument: le-name
chgrp - change group ownership
Argument: group-name and le-name
chown - change le owner and group
Argument: owner and le-name
link or ln - make links between les
Useful options: -d, -f, -i, -L, -P, -r, -s
Argument: (le-name and link name) or (target le-name with path)
or (directory-name and le-name/s)
unlink - remove the link of the specied le
Argument: le-name
4
cksum - checksum and count the bytes in a le
Argument: le-name
cmp - compare two les byte by byte
Useful options: -b, -i, -n
Argument: le-name and le-name
diff - compare les line by line
Useful options: -a, -b, -B, -i, -q, -s, -w, -y
Argument: (le-name and le-name) or (directory name and direc-
tory name)
split - split a le into pieces
Useful options: -a, -b, -C, -l, -n
Argument: le-name
2.4 Text processing
cat - concatenate les and print on the standard output
Argument: le-name/s
sort - sort lines of text les
Useful options: -d, -f, -g, -n, -m, -r, -o
Argument: le-name/s
wc - print newline, word, and byte counts for each le
Useful options: -c, -l, -m, -w
Argument: le-name]
uniq - report or omit repeated lines
Useful options: -c, -d, -u
Argument: le-name]
tee - read from standard input and write to standard output and les
Useful options: -a
5
Argument: le-name
spell - English language spell checker
Argument: text le-name
2.5 Process management
ps - report a snapshot of the current processes
Useful options: -A, T, r, -p, -u
Argument: optional process-name or -id
top - display Linux processes in a dynamic real-time view
Useful options: -d, -H, -p, -u
bg - Move jobs to the background
Argument: job-name
fg - Move job to the foreground.
Argument: job-name
kill - terminate a process
Useful options: -n (n=1-9)
Argument: pid (process-id)
2.6 System Management
passwd - update users authentication tokens
Useful options: -d, -e, -f, -l, -k, -u, -n, -x, -w, -i, -S
Argument: user-name
who - show who is logged on (user-name)
Useful options: -a, -b, -q, -r, -t, -u
uname - print system information
Useful options: -a, -s, -n, -r, -v, -m, -p,-i, -o
6
finger - displays information about the system users
Useful options: -s, -l
talk - talk to another user
Argument: login-name of other user and optional (tty-name)
clear - clear the terminal screen
exit - Exit the shell
history - Display or manipulate the history list
Useful options: -c, -n, -s, -w
su - run a command with substitute user
Useful options: -, -c, -m, (-s SHELL)
Argument: user-name (default root user)
sudo - execute a command as another user
Useful options: -H, -u
Argument: user-name
2.7 Miscellaneous Commands
date - print or set the system date and time
Useful options: -d, -S, -u, date
Environmental variable: TZ (time zone)
cal - display a calendar
Useful options: -1, -3, -s, -m , -y
du - Summarize disk usage of each FILE, recursively for directories
Useful options: -a, -c, -d, -h, -m
df - displays the amount of disk space available on the le system
Useful options: -h
bc - calculator
7