2. What is Unix?
Just like Windows, it is an operating system.
Linux is one of the popular versions of the UNIX operating system, which is designed to
offer a free or low cost operating system for personal computer users.
Android is powered by the Linux operating system.
An operating system is software that manages all of the hardware resources associated
with your desktop or laptop.
To put it simply, the operating system manages the communication between your
software and your hardware. Without the operating system (OS), the software wouldn't
function.
3. Why use?
Does that operating system you are currently using really work ? Or, do you find
yourself battling obstacles like viruses, malware, slow downs, crashes, costly
repairs, and licensing fees?
If you struggle with the above, Unix or its flavour might be the perfect platform for
you.
Combine that reliability with zero cost (Free)of entry and you have the perfect solution
for a desktop platform.
Open source
Open source follows these key tenants:
The freedom to run the program, for any purpose.
The freedom to study how the program works, and change it to make it do what
you wish.
The freedom to redistribute copies so you can help your neighbour.
The freedom to distribute copies of your modified versions to others.
4. The Linux operating system comprises several
different pieces:
Bootloader – The software that manages the boot process of your computer. For
most users, this will simply be a splash screen that pops up and eventually goes
away to boot into the operating system.
Kernel – This is the one piece of the whole that is actually called Unix. The kernel is
the core of the system and manages the CPU, memory, and peripheral devices. The
kernel is the lowest level of the OS.
Daemons – These are background services (printing, sound, scheduling, etc.) that
either start up during boot or after you log into the desktop.
etc.
5. Unix System Architecture
The kernel is the core part of the operating system, which is responsible for all the major
activities of the operating system
6. Portable: Unix operating system can work on different types of hardware's as well
as kernel supports the installation of any kind of hardware platform.
Open Source: Source code of operating system is freely available and, to enhance
the ability of the operating system, many teams work in collaboration.
Multiuser: It is a multiuser system, which means, multiple users can access the
system resources like RAM, Memory or Application programs at the same time.
Multiprogramming: It is a multiprogramming system, which means multiple
applications can run at the same time.
Shell: Unix operating system offers a special interpreter program, that can be used
to execute commands of the OS. It can be used to do several types of operations
like call application programs, and so on.
Security: Unix operating system offers user security system using authentication
features like controlled access to particular files.
Features of Unix Operating System
7. Applications
User Support Tools
Text processing (vi, sed, awk)
Productivity applications
Programmer Support Tools
Programming languages & compilers (C, C++, Java)
Shell scripts
Personal software process: version control
Source Code Control System (SCCS)
Revision Control System (RCS)
Unix as server
Web server, mail server, application server
9. UNIX Shells
sh
Bourne shell: Steve Bourne, 1978
Almquist shell (ash): BSD sh replacement
Bourne-Again shell (bash): GNU/Linux
csh
C shell, Bill Joy, BSD, 1978
tcsh
Tenex C shell (tcsh): GNU/Linux
others: Korn shell (ksh), Zshell (zsh), …
10. Help
Some web sites
www.unixtools.com
www.ugu.com
www.unix-manuals.com
www.unixcities.com
www.tldp.org
www.linux.com
www.linux.org
linux.die.net
11. The most common Unix/Linux commands
Command Description
cat [filename]
Display file’s contents to the standard output
device
(usually your monitor).
cd /directorypath Change to directory.
chmod [options] mode filename Change a file’s permissions.
chown [options] filename Change who owns a file.
clear
Clear a command line screen/window for a
fresh start.
cp [options] source destination Copy files and directories.
date [options] Display or set the system date and tim
12. df [options] Display used and available disk space.
du [options] Show how much space each file takes up.
file [options] filename Determine what type of data is within a file.
find [pathname] [expression] Search for files matching a provided pattern.
kill [options] pid
Stop a process. If the process refuses to stop,
use kill -9 pid.
less [options] [filename] View the contents of a file one page at a time.
ln [options] source [destination] Create a shortcut.
locate filename
Search a copy of your filesystem for the
specified
filename.
lpr [options] Send a print job.
ls [options] List directory contents.
13. man [command]
Display the help information for the specified
command.
mkdir [options] directory Create a new directory.
mv [options] source destination Rename or move file(s) or directories.
passwd [name [password]]
Change the password or allow (for the system
administrator) to
change any password.
ps [options]
Display a snapshot of the currently running
processes.
pwd
Display the pathname for the current
directory.
rm [options] directory Remove (delete) file(s) and/or directories.
rmdir [options] directory Delete empty directories.
ssh [options] user@machine
Remotely log in to another Linux machine,
over the network.
Leave an ssh session by typing exit.
14. su [options] [user [arguments]] Switch to another user account.
tail [options] [filename]
Display the last n lines of a file (the
default is
10).
tar [options] filename
Store and extract files from a tarfile (.tar)
or tarball (.tar.gz or .tgz).
top
Displays the resources being used on
your system. Press q to
exit.
touch filename
Create an empty file with the specified
name.
who [options] Display who is logged on.
15. Unix directory structure revisited
'cd ~' change directory to your
home
'cd ~ sonali' change directory to
sonali's home
'cd ..' change directory to upper
directory
'cd / ' change directory to root
Use tabs to complete the file name
(write partial file name and then use
tab)
File Commands
16. Permissions – important for sharing your
files and restricting access on your work
'chmod 755' => rwx rwx rwx (user
group all)
'chmod a+r' => (u/g/a) ( +/ -) (r/w/x)
‘file’ utility tells type of file like text,
word or pdf
(Helpful when extension is not given)
Important filters-
'grep word path/filename', grep find a
word in a file
pipes ' | ' : redirect output of one
command to other command
'more' or 'less' shows files pagewise
‘find’ and ‘locate’ utility help to find a
file by filename
‘find –r path –name filename’ will find
the location of file in given path.
Useful command as we can use wild
card pattern
File Commands
17. fast and easy
Basic modes- edit and
command,
‘esc’ for command mode
‘i, a’ for edit mode (insert or
append mode)
Other commands using colon-
:q,:w,:q!,:e
:q for quit, :w for write, :q! quit
without save
:e open another file for editing, :wq
write and quit
Searching using ‘/’
In command mode use ‘/’ then
write the word you want to search
‘n’ for forward search, ‘N’ for
backward search
Search and replace
:s/ram/mohan - will search string
“ram” and replace with “mohan”
Advanced vi – vim(vi improve)
and gvim(gnu vim)
VI EDITOR
18.
19.
20.
21. Discussed in Class in Detail(with
example and diagram):
User File descriptor table( per process)
File table(global kernel structure)
Inode table
Inode in detail:
Process access to data blocks.
Addressing scheme and Calculation.
22.
23. Discussed in Class in Detail (with algorithm)
File Input output.
Lseek
Other file system calls
Stat()
Fstat()
24.
25.
26.
27. Process:
Def
Process Control System
States : 1-9
Data structures ( with contents of each):
•Process table
•U area
Context of a process
(user context, register, system level)
Context switching and steps
28. „
System calls:
ƒ
fork() spawns new process
Called once, returns twice
ƒ
exit() terminates own process
ƒ
Called once, never returns
ƒ
Puts it into “zombie” status
ƒ
wait() for terminated children
ƒ
execl() run new program in existing process
ƒ
30. Redirection
Will use redirection to redirect standard input and standard output.
Operating system gets information from or sends information to:
Standard input
Standard output
Standard error
31. Redirection
I/O redirection tells OS you want information read from or written to a
device other than the standard ones.
Symbols used for redirection:
> (greater than)
< (less than)
>> (double greater than)
32. Redirection
Redirection works with commands that write their results to standard output
device (screen)
Using >
COPY can only copy files, not commands
Using <
Any input from keyboard ignored if redirection of input is from a file
Using > between files - first file overwrites second file
Using >> between files - first file appended to end of second file
33. Filters
Three filter commands:
SORT
FIND
MORE
Operating system creates temporary files while it “filters” data.
Operating system will not be able to execute filter commands on write-
protected disk.
34. Filters
SORT filter command:
Arranges lines of input in ascending order
Sends output to standard output unless redirected
SORT syntax:
SORT [/R] [/+N] [/M kilobytes] [/L locale] [/REC recordbytes]
[[drive:] [path1] filename1] [/T [drive2:] [path2]] [O [drive3:]
[path3] filename3]
35. Filters
FIND filter command:
Allows you to search a file for a specific character string by
enclosing it in quotation marks.
FIND syntax:
FIND [/V] [/C] [/N] [/I] [/OFF[LINE]]“string”
[[drive:] [path] filename[ …]]
FIND command is looking for exact match, therefore, is case sensitive
unless /I parameter
is used.
FIND parameters:
/I - ignores case
/V - search a file for anything except what is in quotes
/N - finds specific line number of each occurrence
/C - numeric count of number of times specific character string
appears in a file
36. PIPES
Pipes:
Standard output of one program used as standard input
to next program
Used with filter commands to further refine data
Not limited to two programs
Pipe symbol is the vertical broken bar | and is used
between two commands.
Location of the pipe symbol is not standard.
37. Signals
A signal is a small message that notifies a process that an
event of some type has occurred in the system.
•sent from the kernel (sometimes at the request of another process) to a
process
•signal type is identified by small integer IDs (1‐30)
•only information in a signal is its ID and the fact that it arrived
ID NAME Action Event
2 SIGINT Terminate Interrupt(Ctrl+C)
38. Sending Signals
Kernel sends (delivers) a signal to a destination process by
updating some state in the context of the destination process
Kernel sends a signal for one of the following reasons:
•ƒ
Kernel has detected a system event such as divide‐by‐zero
(SIGFPE) or
•the termination of a child process (SIGCHLD)
•ƒ
Another process has invoked the kill system call to explicitly request
•the kernel to send a signal to the destination process
39. A destination process receives a signal when it is forced by the kernel to react in some
way to the delivery of the signal
„Three possible ways to react:
•ƒ
Ignore the signal (do nothing)
•ƒ
Terminate the process (with optional core dump)
•ƒ
Catch the signal by executing a user‐level function called signal handler
ƒ
Akin to a hardware exception handler being called in response to an
asynchronous interrupt
Receiving Signals