3. Kernel
• Core of the operating system
• Collection of programs and sub routines written
in C
• Is in direct control of the underlying hardware
Functions include:
1. File management
2. Process management
3. Memory management
4. Converting data from user level to machine
level.
5. CPU scheduling
6. Dealing with interrupts from hardware
devices.
4. Shells and GUIs
• Shell acts as a command interpreter, which interprets
the user commands and transfers them to the kernel
for execution
• Performs as an interface between the user and the
kernel.
• Only one kernel and there can be several shells running
in the memory, one for every logged – in user.
• Shell invokes a command line prompt (for ex: $), where
the user can type a UNIX command.
5. Types of shells
1. Bourne shell
2. C shell
3. Korn shell
4. Bourne – again shell
Bourne shell
• Most common shell distributed with UNIX system.
• Is named after its author Stephen Bourne
• Most widely used shell
• Executable filename is sh
6. C shell
• Developed by Bill Joy
• Coding is similar to C programming language
• Shell scripts of this will not work with Bourne
shell
• Major advantage over Bourne shell is its ability
to execute processes in the background.
• Executable file is csh
• TC shell(tcsh) is a free version of C shell under
Linux
7. Korn shell
• Developed by David Korn
• Combines the best features of Bourne shell and C
shell
• One of the widely used shells
• Runs Bourne shell scripts without any changes
• Executable file is ksh
Bourne – Again shell
• Developed by Fox and C Ramey
• Default shell for most Linux operating systems and
its variants
• Executable file is sh
8. File system
• A major component.
• Is organized in an hierarchical manner.
• In UNIX, everything including hardware devices is
treated as a file.
• Resembles a tree structure with its root at the
top.
• Can be local or distributed.
9. System utilities and application programs
• System utilities such as ls, cp, grep, bc etc.
perform a single task extremely well.
• System utilities provide remote network and
administration services
• Application programs in Linux include editor, c
compiler, drawing package, Soffice (StarOffice)
etc.
10. UNIX command format
• UNIX commands can be very simple one word
commands or they can take a number of additional
arguments (parameters) as part of the command.
• In general a UNIX command has the following
general form...
$command option(s) filename(s)
• The command is the name of the utility or program
that we are going to execute.
Ex: $rm –i test1 #the command rm deletes the file test1, -i
prompts before deleting file.
11. • The options are passed into the command to
modify the way the command works. It is typical
for these options to have be a hyphen followed by a
single character, such as-l.
• The filename is the last argument for a lot of UNIX
commands. It is simply the file or files that we want
the command to work on.
• Take note that not all commands work on files, such
as ssh which takes the name of a host as its
argument.
(The ssh command is used to logging into a remote host and
execute commands on the remote machine.)
12. • The clear command, which is used to remove
all previous commands and output from the
display screen, is one of the rare commands
that accepts neither options nor arguments.
13. UNIX internal and external commands
• UNIX commands are classified into two types
Internal Commands - Ex: cd, echo,fg
External Commands - Ex: ls, cat
Internal Command:
• Internal commands are something which is built into the shell.
• For the shell built in commands, the execution speed is really high. It is because no
process needs to be generated for executing it.
• For example, when using the "cd" command, no process is created. The current
directory simply gets changed on executing it.
External Command:
• External commands are not built into the shell.
• These are executables present in a separate file.
• When an external command has to be executed, a new process has to be
generated and the command gets executed.
• For example, when you execute the "cat" command, which usually is at /usr/bin,
the executable /usr/bin/cat gets executed.
15. pwd - print working directory or present working directory)
• Prints the absolute pathname of our current working directory
• The pwd command can have options, but it doesn’t take any arguments
Syntax & Ex: $pwd
cd - changing the directory
• Is used to move from one directory to another.
• Uses a pathname (either relative or absolute) as its argument.
Syntax: $cd directoryname
Ex: $cd /home/harley/essays
• To change to the / (root directory), use:
$cd /
• To return to home, use:
$cd
• To change to the parent directory, use:
$cd ..
Please note: There is a space between the command cd and its argument
16. mkdir – making directory
• To make a directory, we use mkdir command.
Syntax: $mkdir directoryname
Examples:
$mkdir extra
$mkdir sample1 sample2
rmdir – removing directory
• Removes one or more directories or sub –
directories
• Directories can be removed only when they are
empty.
Ex: $rmdir sample1
17. • A directory tree can be removed recursively and
forcefully using the rm command with the –r and –f
options
mv – moving or renaming a directory
• To move or rename a directory, we use mv command
Syntax: $mv directory target
where directory is the directory we want to move or
rename and target is the target or new name
Ex: $mv data extra
• We use mv command to “move” a directory from one
place to another.
• The command mv both moves and renames.
18. tree
• Lists the contents of directories in a tree like
format.
• Options –d (list directories only), -f (prints the
full path prefix for each file), -p (list a tree that
also shows the file permissions)
Ex: $tree -p
20. cat
• Is used for creating files, displaying contents of
the files, concatenating files and for appending
files.
Creating files:
• Can be used to create small files.
• Takes input from keyboard and sends the output
to the monitor.
Ex: $cat > fruits
Apple
Orange
Grapes
<ctrl d>
21. Displaying contents of files
• cat can be used to display the contents of the one
file or more than one files
Examples:
$cat fruits
$cat fruits vegs
Concatenation of files
• cat command can concatenate the contents of two
or more files and store them in another file.
Ex: $cat test1 test2 > test3
22. Append files
• The cat command can be used to append or add
data to the contents of the file using the symbol >>
Ex: $cat >> fruits
Pineapple
Guava
<ctrl d>
• Can also be used to append the contents of one file
to another file
Ex: $cat fruits >> item
• Options with cat command are –v (displays non –
printable ASCII characters also), -n (numbers the
lines in the file) etc.
23. cp
• Can copy a file or a group of files, across
directories.
Syntax: $cp <source_file> <new_filename>
Ex: $cp test1 test2 #creates an exact copy of test1 with
file name as test2
• More than one file can be copied into another
directory
Ex: $cp test1 test2 testdir
24. cp options
• -i : interactive, prompts the confirmation
before overwriting the target file.
• -r : is recursive copying
• -p : copies the file and preserves the attributes
such as owner id, group id, permissions and
last modification time
25. mv – moving or renaming a file
• To move or rename a file, we use mv command
Syntax: $mv filename target
Where filename indicates the file we want to move
or rename and target is the target or new name
Ex: $mv veg vegetables
• We use mv command to “move” a file from one
place to another.
• The command mv both moves and renames.
• A group of files can also be moved into a
directory.
26. mv options:
• -f : suppresses all prompting and forces
overwriting of target file.
• -i : prompts before overwriting of destination
file
• -p : preserves the attributes such as owner id,
group id, permissions and last modification
time
27. rm
• Is used to delete one or more files
• Meta characters(*,? etc.) can be used to delete
files with common patterns
Syntax: $rm filename
Ex: $rm fruits
rm options:
• -f : suppresses all prompting.
• -i : prompts before deleting files
• -r : is recursively removes the files. (Ex: $rm –r*)
28. touch
• Is used to create empty files
Examples:
$touch course1
$touch course1 course2
touch options
• -a : to change the access time
• -m : to change the modification time
29. ls
• Is used to display all the files and sub directories in a
current directory
ls options:
• -a : list all files including hidden files.
• -x : list the content in a row – wise format.
• -r : list the contents, sorted in a reverse alphabetical
order.
• -i : displays inode numbers of files
• -l : display all the files and subdirectories in the long
format including permissions, file type, owner id, group
id etc.
• -u : list the contents based on the access time or usage
time.
30. Meta characters can be used with ls command as
follows:
• $ls *t : list all files ending with the letter t.
• $ls p* : list all files starting with the letter p.
• $ls ?at : list all three letter file names ending with
‘at’ and starting with any character.
• $ls [abc]* : list all files starting with the letters a, b
or c.
• $ls [!abc]* : list all file names which do not start
with the alphabets a, b or c
• $ls / : lists the contents of the root directory
31. more
• Is used to view the contents of a file page by
page.
• Takes one or more file names as arguments
Ex: $more studdet.txt
• The user can quit from more by typing q
32. head
• Is used to display the first few lines of one or
more files
• Without any options, by default, it displays
first 10 lines of the file.
Examples:
$head bcalist
$head -4 bcalist
• The head command can be used with multiple
files
Ex: $head -2 bcalist bsclist
33. tail
• Is used to display the last few lines of a file.
• By default, it displays the last 10 lines of the file.
Examples:
$tail bcalist #displays the last 10 lines
$tail -4 bcalist #displays the last 4 lines
$tail +7 bcalist #displays all the lines starting
from the line number 7 up to end of file
• The tail command cannot take multiple files
34. Comparing files
• The commands for comparing files can be
used to compare two versions of the same
file.
• Most common commands for comparing two
files are:
cmp
diff
comm
35. cmp
• Is used to determine whether the two files are
identical in all respects.
• When files are identical, system prompt
appears without any message.
• When there are differences, the location of
the first mismatch is echoed on the screen.
Ex: $cmp bcalist bsclist
36. diff
• It first compares the two files byte by byte,
and indicates the differences.
• Also tells how the contents of the first file can
be changed to match the text from the second
file and vice versa.
Ex: $diff bcalist bsclist
37. comm
• Compares two sorted files and shows
lines that are same and those that are
different.
Ex: $comm bcalist bsclist
38. Disk related commands
The df command - disk free
• Reports the amount of free space available for
each file system separately.
Examples:
$df
$df -h
df options:
• -h : print sizes in human readable format
(e.g., 1K 234M 2G)
• -T : print file system type.
• -a : include dummy file systems
• -i : list inode information instead of block usage.
39. The du command – disk usage
• It estimates and displays the disk space used
by files.
Ex: $du
du options:
-a : displays the space that each file is taking up
-ch : displays file sizes and the total capacity of
all files combined
-k : reports the file sizes in units of 1024 bytes
40. The ulimit command – user limit
• This command is used to control occupying huge
amount of space by files created by users.
• When applied at the command prompt ulimit
displays a value which signifies the largest file that
can be created by the user in the file system.
Ex: $ulimit
• The default value of Solaris and Linux for ulimit is
unlimited.
41. • An ordinary user can decrease the value, but
cannot increase it.
• Once the limit is decreased, it remains effective
till the user logs out.
• A super user can use ulimit to impose restriction
on the maximum file size, that a user is allowed
to create.
• A super user can increase or decrease the value
of ulimit.