Академический Документы
Профессиональный Документы
Культура Документы
Objectives
1.1 Introduction
Unix being a multi-user operating system does not allow its users to directly interact
with the hardware unlike DOS. All user interactions in Unix are done via the shell and the
kernel. Shell is the program that acts as a bridge between the user and the kernel. It
interprets and also does input/output redirection. Kernel is the heart of the Unix operating
system. It is the kernel, which communicates with the hardware and sends back the required
data to the user via the shell.
USER
SHELL
KERNEL
HARDWARE
Every user, when logged on to Unix, works in a specific environment called the shell.
/(root)
uv trguser1 trguser2
/(root)
The directory denoted by a ‘/’ is the main/parent directory of the Unix operating
system. It is usually called ‘root’. All the other directories of Unix branch out from here.
bin
Contains system executable files. All commands in Unix have an associated file
with the same name. When a command is issued by a user the shell searches for a file with the same
name as that of the command and executes the file if found, else flashes an error message. These
executable files are usually found in this bin directory.
dev
Contains device files. Every thing in Unix is treated as a file. A file, a directory a
device such as hard disk, tape, floppy disk, keyboard etc are all treated as files. Every device that is
present as apart of the system has an associated file in the ‘dev’ directory.
etc
Contains admin-related files. There are a number of files that are required for the
administration of Unix. Such files are found under this directory. Some of the admin related files are
discussed further in this session.
usr
lib
In order for Unix to function, it needs a number of library files. These are like the .dll
files in Windows, which are required for the functioning of the operating system.
user
tmp
In order to login into the Unix system, at the login prompt, type your user name and
the password. Unix validates the user name and password. Once validated, you would be taken to a
protected environment called the ‘shell’ where you could perform any operation.
Following are some of the basic Unix commands. All these can be executed from the
Unix prompt.
pwd Print Working Directory. This tells you which directory you are in.
After ‘shelling’ to Unix, you will be in your home directory. In a
GLOBUS account, the home directory will be a run area e.g.
demo.run.
1 2 3 4 5 6 7 8 9
3.1.2 Directories
Unix files are stored in Directories that are like folders in a filing cabinet. The highest
directory is called the root directory (symbolized by /). The directory structure is then like a tree up
from this central point. Unlike a filing cabinet, a directory can have any number of subdirectories in it,
and they in turn can contain subdirectories.
When listing the contents of a directory, you can identify a directory by the ‘d’ at the
far left of the screen, when you run the ‘ls –l’ command.
After each command enter ‘pwd’ to see which directory you are now in.
$ cd Change Directory. On its own this goes to the user’s home directory.
(This should be the run account you log in to).
$ cd / Goes to the root directory.
$ rm –r dirname This removes a directory and all its contents. This command can be
very dangerous, so use it with extreme care.
3.1.4 Permissions
When you execute the command ls –l, you would let a detailed list of all the files and
directories under the current working directory. On the left hand side of the detailed list you can see
the permissions on each file and directory. This set of permissions is know as the FAP(File Access
Permissions).
There are only 3 permissions that can be granted/revoked to/from a file or directory.
They are
r Read
w Write
x Execute
The Read permission is required for any file or directory that requires a Write or an
Execute permission.
Unix has 3 different set of users namely,
Owner/User Owner of the file/Person who created a file
Group Every user in Unix needs to belong to a group(Just like employees in
an organisation belong to a department). Group signifies the other
members of the group to which the owner belongs to.
Others All the other users in the system
r w x r w x r w x
4 2 1 4 2 1 4 2 1
A B C
Figure 3.1 FAP of a file
Following are the various ways to grand and revoke permissions to files and directories.
Example 1
In the above command, ‘u’ denotes the user/owner of the file, ‘+’, denotes that a permission is to be
granted and ‘r’ denotes the read permission.
Example 2
In the above command, ‘g’ denotes the group, ‘-’, denotes that a permission is to be revoked and ‘w’
denotes the write permission.
Example 3
Grant Read and Execute permissions to the Others for a specific file
In the above command, ‘o’ denotes the ‘Others’, ‘+’, denotes that a permission is to be granted and ‘r’
and ‘x’ denote the read and execute permissions respectively.
Example 4
The –r option used along with chmod enables recursive granting/revoking of permissions.
Every user in Unix has a profile file called the “.profile” file. As the name denotes, it
When a user is created in Unix, the operating system prompts for the following
information
Once we supply the above information, Unix makes a copy of the .profile file under
the ‘root’(main) directory of Unix and places it under the home directory of the user.
The home directory of the user is the path where the user will be taken to when he
logs in. This is the protected environment where the user would work in.
The .profile file copied under the home directory of the user will contains the following
environmental variables
PS1 : Contains the user’s prompt that has to appear when he logs on to Unix.
HOME : Contains the path of the home directory that the use has to be taken to as
soon as he logs in
PATH : Contains the various paths to be searched for executable files in Unix.
LOGNAME : Contains the user’s login name.
Sample data that would be present in a .profile file.
PS1 : $
HOME : /globus1/train1/demo/demo.run
PATH : .:/bin:/usr/bin:/etc:/u1/uv/bin
LOGNAME : train1
Note :
Devices Codes
When the input comes from a device other than the standard input device then it is
termed input redirection.
Example 1
cat filename.
This command cat takes the input from a file and displays the contents of the file.
Here the input is from a file and not from the standard input device. The symbol ‘<’ is associated with
input redirection and it is optional.
When the output of a command, shell script etc go to any device other than the
standard output device, then it is termed as output redirection.
Example 1
ls –l > filename
ls –l 1> filename
Example 1
The above command will display the contents of the file with name ‘file1’ if found, else
redirect the error message to the file error.msg. The symbol associated with error redirection is also ‘>’
like output redirection. Therefore whenever error redirection has to be accomplished the code
associated with error redirection ‘2’ has to be attached else Unix will assume it as output redirection.
Note :
During output and error redirection, the output or the error gets written on to the file specified. If
the file mentioned does not exist, Unix will automatically create it and write onto it. In case the file
exists, the file will be overwritten .To prevent overwriting, ‘>>’ symbol can be used. This will
append the contents to the file.
Vi is the standard Unix text editor. It has 2 basic modes - Command mode and Insert
mode. It can be quite difficult to get used to at first. When you first enter Vi you are in command
mode. When you type a letter you will perform the command associated with that letter
To go into Insert mode select ‘i’. Now when you type letter they appear on screen as
text. Note that some functions like ‘Home’ and ‘Delete’ do not work in the conventional way
It is usually best to type in all you can in insert mode, then go back in Command
mode to delete any errors. See ‘General Guide to using Vi’ document for further information
An operating system is a software that controls the hardware and peripheral devices,
manages the memory, schedules, prioritizes, initiates and controls jobs, manages file creation
and interprets commands
Unix comprises of the shell and the kernel
Shell is an interface between the user and the kernel. It is a protected environment for every
user to work in
Kernel is the heart of the Unix operating system. It directly communicates to the hardware.
Bin, lib, etc, dev, user, usr, tmp are some of the system directories that get installed when
Unix is installed
pwd, mkdir, cd, cd .., rmdir, rm, ls etc are some of the basic commands in Unix
chmod is the command that is used to grant and revoke permissions to files and directories
.profile is a hidden file that holds the profile settings of a Unix user
HOME, PS1, PATH, LOGNAME are some of the environmental variables that are set in the
.profile file
The symbol for input redirection is ‘<’ and the id of the standard input device(Keyboard) is 0
The symbol for output redirection is ‘>’ and the id of the standard output device(Monitor) is 1
The symbol for error redirection is ‘>’ and the id of the standard error device(Monitor) is 2
vi is the Unix editor.