Professional Documents
Culture Documents
Compiled by:
Under guidance of – Preeti Vatnani
Prof. Niranjan Shrivastava Pushpendra Patel
Preeti Soni
5-12-2010
What is UNIX :
UNIX is an operating system.
5-12-2010
What is LINUX :
5-12-2010
5-12-2010
5-12-2010
Features of UNIX :
•UNIX is a multi-user, multi-tasking operating
system. Multiple users may have multiple tasks
running simultaneously. This is very different than
PC operating systems.
•UNIX is a machine independent operating system.
Not specific to just one type of computer hardware.
Designed from the beginning to be independent of
the computer hardware.
•UNIX is a software development environment. Was
born in and designed to function within this type of
environment.
5-12-2010
The shell
The shell acts as an interface between the user and
the kernel. When a user logs in, the login program
checks the username and password, and then starts
another program called the shell. The shell is a
command line interpreter (CLI). It interprets the
commands the user types in and arranges for them to
be carried out. The commands are themselves
programs: when they terminate, the shell gives the
user another prompt (% on our systems).
5-12-2010
Basic UNIX Commands
5-12-2010
Topics
Handling Files and Directories
Text Editors
Compiling and Linking
Handling Processes
Archiving and Compressing Files
Other Useful Commands
5-12-2010
Handling Files and Directories
ls : list files
cp : copy files
mv : move files
rm : remove files
mkdir : make directories
cd : change directories
rmdir : remove directories
pwd : print working directory
chmod : change permission mode
5-12-2010
ls command
Syntax
ls [-Options] [name ...]
Description
Lists contents of directory.
5-12-2010
cp command
Syntax
cp [-Options] file1 [file2 ...] target
Description
File1 is copied to target.
5-12-2010
mv command
Syntax
mv [-Options] file1 [file2 ...] target
Description
File1 is moved to target.
Examples
mv p*.c mydir
5-12-2010
rm command
Syntax
rm [-f] [-i] file . . .
Description
Removes files or directories.
rm -r mydir
5-12-2010
mkdir command
Syntax
mkdir [-m mode] [-p] dirname . . .
Description
Creates the specified directories.
Options
-m Specifies the mode to be used
-p Create missing intermediate directories
Examples
mkdir -m 700 letter
mkdir abc
mkdir -p ./abc/def/ghi
5-12-2010
cd command
Syntax
cd [directory]
Description
Change working directory.
cd ./abc/def/ghi
cd ..
5-12-2010
rmdir command
Syntax
rmdir [-p] [-s] dirname . . .
Description
Removes directories.
Options
-p Remove the directory dirname and its parent
directories which become empty.
-s Suppress the message when –p is in effect
Examples
rmdir letter
5-12-2010
pwd command
Syntax
pwd
Description
Prints the path name of the working (current) directory.
Examples
pwd
5-12-2010
chmod command
Syntax
chmod [-R] mode file ...
Description
Changes the permissions mode of a file or directory.
Examples
chmod 444 file1
5-12-2010
Handling Processes
ps : Prints information about active processes
kill : Sends a signal to a process
5-12-2010
ps command
Syntax
ps [-Options]
Description
Prints information about active processes.
5-12-2010
kill command
Syntax
kill [-signal] pid . . .
Description
Sends a signal to the specified processes.
Examples
kill 389
5-12-2010
Other Useful Commands
grep : search files for a pattern
man : on-line reference manuals
wc : word, line and byte or character count
5-12-2010
grep command - I
Syntax
grep [-E| -F] pattern_list [file . . .]
Description
Searches the input files, selecting lines matching one or
more patterns
Frequently Used Options
-i Case-insensitive search
-l Write file names only
-n Display line number
5-12-2010
grep command - II
Examples
grep -i unix p1.c
grep -n UNIX *.c *.h
5-12-2010
man command
Syntax
man [-Options] [-M path] [-T macropackage] [ -s section] name ...
man [-M path] -k keyword ...
Description
On-line reference manuals
5-12-2010
wc command
Syntax
wc [ file . . . ]
Description
Counts lines, words, and characters
Options
-c Count the number of bytes
-m Count the number of characters
-l Count the number of newline characters
-w Count the number of words
Examples
wc -l *.h *.c
5-12-2010
date
Guess what :-)
Displays dates in various formats
% date
% date -u
in GMT
% man date
5-12-2010
cal
5-12-2010
clear
Clears the screen
There’s an alias for it: Ctrl+L
Example sequence:
% cal
% clear
% cal
Ctrl+L
5-12-2010
sleep
“Sleeping” is doing nothing for some time.
Usually used for delays in shell scripts.
% sleep 2 2 seconds pause
5-12-2010
Command Grouping
Semicolon: “;”
Often grouping acts as if it were a single command, so an
output of different commands can be redirected to a file:
% (date; cal; date) > out.txt
5-12-2010
history
Display a history of % !n
recently used commands repeat command n in the
% history history
all commands in the history
% !-1
% history 10
repeat last command = !!
last 10
% !-2
% history -r 10
repeat second last command
reverse order
% !ca
% !!
repeat last command that
begins with ‘ca’
repeat last command
5-12-2010
exit / logout
Exit from your login session.
% exit
% logout
5-12-2010
shutdown
Causes system to shutdown or reboot cleanly.
May require superuser privileges
% shutdown -h now - stop
% shutdown -r now - reboot
5-12-2010
THANK YOU
5-12-2010