2. CONTENTS
INTRODUCTION TO
UNIX:
History
Features of UNIX
UNIX System Architecture
UNIX Session
Linux System
UNIX Command Format
Types of UNIX Commands
General Purpose Commands.
3. WHY TO STUDY THIS SUBJECT ?
You could be required to learn it as part of a course
requirement. Especially, if you are pursuing a degree in
Computer Science or Information Technology.
Sometimes UNIX is the only operating system installed in
certain lab computers in universities.
Other reasons to learn UNIX are to create and store files for
World Wide Web pages.
For some issues, a UNIX command is much faster and
easier.
There are a lot of things that a GUI tool does not allow. In
these cases UNIX could be your saviour!.
Another reason could be the ability to view invisible files
and copying music to your hard drive from a popular mp3
player :-)
But the most important reason to learn UNIX is the simple
fact that it is a powerful tool!
4. WHAT IS AN OPERATING SYSTEM?
o The operating system (OS) is the program which starts up when
you turn on your computer and runs underneath all other
programs - without it nothing would happen at all.
In simple terms, an operating system is a manager. It manages
all the available resources on a computer, from the CPU, to
memory, to hard disk accesses.
Tasks the operating system must perform:
Control Hardware - The operating system controls all the parts of the
computer and attempts to get everything working together.
Run Applications - Another job the OS does is run application
software. This would include word processors, web browsers, games,
etc...
Manage Data and Files - The OS makes it easy for you to organize
your computer. Through the OS you are able to do a number of things
to data, including copy, move, delete, and rename it. This makes it
much easier to find and organize what you have.
5. WHAT IS UNIX?
An Operating System (OS)
Mostly coded in C
Machine independence
It provides a number of facilities:
management of hardware resources
directory and file system
loading / execution
6. 1.1 HISTORY
The UNIX was originated in Bell Laboratory of AT & T in
1969 by Ken Thompson and Dennis Ritchie.
In 1960, the Massachusetts Institute of Technology, AT &
T Bell Labs, and General Electric company worked on
an experimental Operating system called Multics.
(Multpexed Information and Computing Service). Since
the progress was not sufficient, AT & T pull out of the
Multics project in 1969.
In 1969, Ken Thompson and Dennis Ritchie developed
an OS called UNICS(Uniplexed Information and
Computing System). Later the name Unics was changed
to UNIX.
• Result- Designed completely in assembly language
• Was not portable.
7. HISTORY (CONTD…)
Thompson- implemented-high level language-by B
Result: was not satisfied.
Dennis Ritchie developed high level language- “C”
Both developed a new multi-tasking OS, now known
as UNIX.
In 1973, unix was rewritten by C Language and
licensed version was made available to Universities
and commercial firms
In 1980s companies began to offer commerical
versions of UNIX system for their own mini-
computers and workstations.
8. HISTORY (CONTD…)
In 1982, Microsoft developed its first UNIX system
for 16-bit microcomputer called Xenix.
In 1991 the Linux was developed, which was based
on UNIX.
Linux is an open source program. Its source code
are available freely. Red Hat Linux is one of the
most popular flavors of Linux.
In 2005, Sun Microsystems released OpenSolaris.
Which is based on UNIX System V.
11. 1.3 UNIX SYSTEM COMPONENTS
The Three major components of UNIX system is:
1. Kernel
2. Shells and GUIs
3. File Sytem
12. 1.3.1 KERNEL
Kernel is the Hub of the OS.
It has complete control over everything that occurs in
the system.
Interacts directly with the hardware through device
drivers.
The kernel itself does not interact directly with the user,
but rather interacts with the shell and other programs as
well as with the hardware devices on the system,
including the processor (also called the central
processing unit or CPU), memory and disk drives.
When the system is booted, the Kernel gets loaded into
memory and communicates directly with the hardware.
13. 1.3.1 KERNEL
The functions of kernel are:
File management
Process management
Memory management
Converting data from user level to machine level
CPU scheduling
Dealing with hardware devices
Programs interact with the kernel through system calls--
a request for the operating system to do something on
behalf of the user's program. The system calls are
functions used in the kernel itself.
For example, open system call can open both file and a
device
14. 1.3.2 SHELLS AND GUIS
The shell acts as an interface between user and the
kernel.
Even though there’s only one kernel running on the
system, there could be several shells in action-one for
each user who is logged in.
The shell acts as a command interpreter, which
interprets the user commands and transfer them to the
kernel for execution.
There are several types of shells available.
The most popular are:
Bourne shell(sh)
C shell (csh)
Korn shell (ksh)
Bourne Again shell (bash)
15. Linux supports two forms of command inputs:
1. Through textual command line shells such as Bourne
shell, bash, C shell.
2. Through Graphical User Interface(GUIs)such as the
KDE( K Desktop Environment) and GNOME window
manager.
16. FEATURES OF UNIX
Multi-User: more than one user can use the machine at a
time supported via terminals.
There are several terminals that can be connected to the
server:
1)Dumb Terminal:-only keyboard and mouse, no hard disk or
memory.
2)Terminal Emulator:-Consists of own memory, microprocessor
and disk drive.
3) Dial-in Terminal:-connect to server with telephone lines.
Multi-tasking: more than one program can be run at a time.
Communication: The communication may be within the
network of a single main computer or between two or more
such computer networks. The users can easily exchange mail,
data programs through such networks. Distance posses no
barrier for passing information or messages to and fro.
17. FEATURES OF UNIX
SECURITY: Unix has 3 inherent provisions for
protecting data.
i) Assign passwords and login name to users area.
ii)Provide read, write and execute permission to each
file.
iii)Encrypt files into an unreadable format, and
decrypting the file is also possible.
o PORTABILITY: Unix is a highly portable OS. It can
be ported to a variety of hardware platforms with
little or no modification.
20. GRAPHICAL USER INTERFACES (GUIS)
When you logon locally, you are presented with
graphical environment.
You start at a graphical login screen. You must
enter your username and password. You also the
have the option to choose from a couple session
types. Mainly you have the choice between Gnome
and KDE.
Once you enter in your username and password,
you are then presented with a graphical
environment that looks like one of the following...
23. COMMAND LINE INTERFACE
You also have access to some UNIX servers as
well.
You can logon from virtually any computer that has
internet access whether it be Windows, Mac, or UNIX
itself.
In this case you are communicating through a
local terminal to one of these remote servers.
All of the commands actually execute on the remote
server.
It is also possible to open up graphical applications
through this window, but that requires a good bit
more setup and software.
25. The Built-in System Utilities - are programs that allow
a user to perform tasks which involve complex actions.
Utilities provide user interface functions that are basic to
an operating system, but which are too complex to be
built into the shell. Examples of utilities are programs
that let us see the contents of a directory, move & copy
files, remove files, etc...
For example grep command finds the matching text in
files, wc counts the number of words, lines, and bytes
inside a file.
Application Software & Utilities – these are not part of
the operating system. They are additional programs
that are bundled with the OS distribution, or available
separately like an image viewer, c++ compiler, ms office
package and so on….
26. 1.3.3 FILE SYSTEM
The UNIX file system is a major components and is
organized in a hierarchical manner.
In Unix, everything including hardware devices is
treated as a file. It may be a program, a file, a
directory or a sub-directory.
Unix file system can be local or distributed.
Local file system can store and manage their data
directly through the system.
27. 1.4 UNIX SESSION
Unix is security-conscious, and can be used only by
the persons who maintain an account with the
computer system.
The system administrator is the person who grants
user the authority to use the UNIX by providing
username and password.
Enter username and password, then your system
will show the $ prompt.
28. WHEN YOU BOOT THE UNIX MACHINE,
A background process called init is started along with
other background processes.
Init, in turn starts another process called getty (get
terminal) for every terminal.
The getty in turn start the login process and presents
the login prompt on the user terminal.
Once the user has given the correct username and
password, a program called the shell starts to run at
your terminal and keeps running until you terminate the
session. The shell displays the prompt and accepts all
input from the keyboard.
When the UNIX session is completed, the user logs
out. The init process, starts a new getty on that
terminal, so that a new user can login into the system.
29. 1..4.1 SHELL PROMPT
On logging in successfully into a UNIX system, a
prompt called shell prompt appears on the terminal.
The character of the prompt depends on the shell
used.
$ --- Bourne, Bourne again and Korn shells (sh,
bash, ksh)
% --- C shell (csh).
# --- Any shell as root.
30. 1.4.2 LOGGING INTO AND OUT OF UNIX
SYSTEMS
Text-based(TTY) terminals
When you connect to a UNIX computer remotely
(using telnet): login prompt will be seen:
login:
you should be then prompted for your password.
login: student
password:
Once it is successful, you will be presented with a
shell prompt which looks like: $
To logout, type “exit” or try “logout” or press ctrl-d
Graphical terminals
31. 1.4.3 CHANGING YOUR PASSWORD
The UNIX command to change the password is
passwd.
$passwd
The system will prompt to,
--old password
-- new password
-- reconfirm
To be Remembered:
1) Avoid character which will not appear on all
keyboard.
2) Avoid dictionary words or words related to personal
details.
3) Make it atleast 7 to 8 character long and try to use a
mix of letters, numbers and punctuation.
32. 1.5 LINUX SYSTEM
Linux is a free open source UNIX OS that was
developed in 1991 by Linus Torvalds, a Finnish
undergraduate student.
Open source means that the source code of Kernel
is freely available.
As linux became popular, different streams have
emerged like Redhat, Fedora, SUSE Linux..
33. 1.6 UNIX COMMAND FORMAT
A UNIX command line consists of the name of the UNIX
command followed by its arguments.
$ command -option targets
where,
command – is the name of the built-in shell commands.
option – is a special argument normally preceded by a
minus sign to differentiate it from file names.
targets – are the filenames and/or expressions which are
part of the argument list.
34. GENRAL FEATURES OF UNIX COMMAND/ RULES APPLIED TO
UNIX COMMAND
1. All unix commands must be entered in lower case letters.
2. Between the command name and options, there must be a space.
However, there should not be a space between – and option.
3. A format specifier can be associated with a unix command by using
the + character.
4. A UNIX command can contain zero, one or more number of
arguments.
5. Most of the UNIX command are short forms. Example:
cat command – concatenation
ls command – listing
6. To abandon a command, press ctrl+D
7. Multiple options can be used with a command, they can be
combined with a single – sign
$ls –l –a –t
$ls -lat
35. 8. When a unix command contains more than 80
characters and overflows to the next line, it is indicated
by a special prompt >, which appears at the beginning of
the next line. This special prompt is known as
secondary prompt.
9. multiple commands can be given on a single line by
separating the commands with semicolon.
EX: $wc note; ls –l note
10. Unix allows users to type a command at any time, even
though the system is already executing an earlier
command in the background.
36. 1.7 TYPES OF UNIX COMMAND
External Command:
These commands exists independently as a separate file.
The shell searches for command files using a system variable
called the PATH variable and executes it.
Most UNIX command are external in nature.
Example: cat or ls
Internal Command/ Built-in commands:
These commands do not exists independently. They are part
of another program.
For example, echo command is an internal command built
into the shell.
37. 1.8 GENERAL PURPOSE COMMANDS
echo:--- To Display A Message
It is used in shell scripts to display messages on the
terminal or as a message prompt for user input.
It takes zero, one or more arguments.
The arguments can be series of individual symbols
or a string within double quotes(“ “).
38. Command Output Details
$echo Displays a blank line.
$echo $shell /bin/bash Displays the name of
the shell being used
$echo UNIX PROGRAMMIG UNIX
PROGRAMMING
$echo UNIX PROGRAMMING UNIX
PROGRAMMING
$echo ”unix programming” Unix programming
39. PRINTF – FORMATTED OUTPUT
Syntax : printf “format_string”
It is an alternative to echo and used to write
formatted output.
It is an external command.
The “format_string” is a combination of textual
message, escape sequence and format
specifications.
It does not insert a blank line automatically until and
unless the n is used explicitly.
$printf “Invalid inputn”
$printf “two separaten linesn”
$printf “curren shell is %s n”$shell
40. UNAME
uname command displays features of the operating
system running on you machine.
By default, it displays the name of operating
system.
Syntax: uname [options]
Option Purpose
-m Prints the machine hardware name.
-n It tells hostname
-r Print the operating system release level
-s Print the name of the operating system
-v Print the operating system version
41. WHO
Who command provides the login details of all the
current users in 3 column format
The first column shows the login name.
The second column shows the device names of the
terminals, and
The third column shows the login date and time.
Editor's Notes
Multics was an interactive operating system with many new capabilities, like enhanced security.