Unix and Shell Programming - : Semester - Iii
Unix and Shell Programming - : Semester - Iii
15CS35
SEMESTER – III
04-08-2016
Syllabus and course outcomes
As a user, you normally interact with the operating system through a set
of commands.
For example, the DOS operating system contains commands such as
COPY and RENAME for copying files and changing the names of files,
respectively
The commands are accepted and executed by a part of the operating
system called thecommand processor or command line interpreter.
Graphical user interfaces allow you to enter commands by pointing and
clicking at objects that appear on the screen.
System
An operating system (OS)
Is system software that manages computer hardware and
software resources and provides common services for
computer programs.
Application programs usually require an operating system
to function.
Types of operating systems
Distributed
A distributed operating system manages a group of distinct
computers and makes them appear to be a single computer.
Embedded
Embedded operating systems are designed to be used in
embedded computer systems. They are designed to operate
on small machines
Clear picture on what we understood
Memory Management
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other software's and users
Components of Unix System
The UNIX operating system is a set of programs that act as a link between the
computer and the user.
The computer programs that allocate the system resources and coordinate all the
details of the computer's internals is called the operating system or kernel.
Users communicates with the kernel through a program known as the shell.
The shell is a command line interpreter; it translates commands entered by the user
and converts them into a language that is understood by the kernel.
Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs,
including Ken Thompson, Dennis Ritchie
Continued…
What is a shell?
A command interpreter
“protects you from the kernel”
It really protects the kernel from you
UNIX commands:
– Internal (builtin) and external command
Some commands are internal, built into the shell.
cd command is built-in. (the shell interprets that command and changes your
current directory).
ls command is an external program stored in the file /bin/ls. • The shell does not
start a separate process to run internal commands.
External commands require the shell to fork and exec a new sub process; this
takes some time, especially on a busy system.
Check a command is internal or external: – $type cd – cd is a shell builtin
Internal and External Commands
Unix commands are grouped into two categories-Internal and External.
Internal
There is a set of commands which are part of the shell and to execute
them the shell does not need to search the given path in the PATH
variable.
These are also called shell builtins or Internal Commands.
External
Commands that are available as independently compiled C programs
usually located in the /bin or the /usr/bin directory are called External
Commands.
37
Internal and External Commands
Internal commands
built into the shell
the shell performs the command
E.g. chdir or cd
External commands
Require the shell to fork and exec and a subprocess
will start
E.g. ls
To log in
Have your userid (user identification) and password ready. Contact your system
administrator if you don't have these yet.
Type your userid at the login prompt, then press ENTER. Your userid is case-
sensitive, so be sure you type it exactly as your system administrator instructed.
Type your password at the password prompt, then press ENTER. Your password
is also case-sensitive.
If you provided correct userid and password then you would be allowed to enter
into the system. Read the information and messages that come up on the screen
something as below.
UI
to check calendar you need to type cal
command as follows −
Change Password
All Unix systems require passwords to help ensure that your files
and data remain your own and that the system itself is secure from
hackers and crackers.
Here are the steps to change your password −
To start, type passwd at command prompt as shown below.
Enter your old password the one you're currently using.
Type in your new password. Always keep your password complex
enough so that no body can guess it. But make sure, you remember
it.
You would need to verify the password by typing it again.
UI
Listing Directories and Files
$echo “ this is
>a three line
>text message”
o/p
This is
A three line
Text message
About tty
Print the file name of the terminal connected to standard input.
tty syntax
tty [OPTION]...
Options
-s, --silent, --quiet Print nothing, only return an exit status.
--help display this help and exit.
--version output version information and exit.
Continued….
tty examples
$tty
Running tty by itself will display the current tty session as
shown below:
/dev/pts/0
stty
About stty
$Stty
changes and prints terminal line settings.
Description
stty displays or changes the characteristics of the terminal.
displaying its characteristics and setting characteristics
Root
root is the user name or account that by default has access to all commands and files on a
Linux or other Unix-like operating system.
The root directory, which is the top level directory on a system That is, it is the
directory in which all other directories, including their subdirectories
and files reside. The root directory is designated by a forward slash ( / ).
Root privileges are the powers that the root account has on the system.
root's powers are the ability to modify the system in any way desired and to grant and
revoke access permissions
Login in terminal
Su: Acquiring superuser status
$su
Password:******
#pwd
/home/sh
Prompt changes but directory dosen’t
Ulimit
Restricts the size
As super user we can also modify the same.
Continued…
user management