Выбрать главу

IV. GETTING STARTED

A system administrator supervises the working of UNIX on any installation. In UNIX, there are different types of accounts. The root account is the administrator user account. It has the most privileges available to the system. Then are individual user accounts having far fewer privileges. Access to many user accounts can also be controlled at once by assigning users to groups. UNIX is case sensitive and is strongly oriented towards devices with lower case. The system administrator configures every individual on the system and supplies them with credentials (username and password).

1. Logging-in

Given that your terminal is connected to the host computer and is powered on, the display prompts you for your login name.

login:

When you get the login: message, type your login name. Follow it by pressing RETURN, after which you receive the password prompt.

password:

At this stage, you must type in your password.

You get three to five attempts to get the login — password combination right before your terminal is disconnected. Once you successfully login, you get a prompt, usually a single character, indicating that the system is ready to accept commands from you. The prompt is most likely to be a dollar sign ($) (for Bourne Shell), or a percent sign (%) (for C Shell), but you can change it to anything you like.

2. Typing Commands

On receiving the prompt, commands can be typed. When you see the prompt ($), type who am I and press RETURN.

$ who am i

tom tty 3a Jul 18 10:10

The system should reply with your user name, system’s name, and when the user logged on. If you make a mistake typing the name of a command, you will be told that no such command exists:

$ today’s date

today’s date: not found

You have two ways to recover from your typing mistakes, provided you see them before you press RETURN:

(i) You type the line kill character (@). It kills the whole line and you can type the whole line again.

(ii) Use erase characters one at a time using #. Each # erases the last character typed. For example,

$ who a i@

who am i

tom tty3a Jul 18 10:10

$ www##ho aa#mi# i

tom tty3a Jul 18 10:10

3. Some Special Keys

RETURN key — The RETURN key signifies the end of a line of input. On any terminal, RETURN has a key of its own, or return may be typed by holding down the control key and typing a ‘m’.

DELETE: The DELETE key stops a program/command immediately, without waiting for it to finish. DELETE can be achieved equivalently with ctrl-c.

Ctrl-s: Ctrl-s pauses the output and the program is suspended until you start it again.

Ctrl-q: Ctrl-q resumes the program paused by ctrl-s.

Ctrl-g: rings a bell on the terminal.

Ctrl-h: can be used for backspace.

Ctrl-I: can be used for tab (eight spaces on UNIX system).

4. Logging out

Logout marks the end of a UNIX session. A user can log out by either typing ctrl-d or exit at the prompt.

V. UNIX ARCHITECTURE

Figure below shows the three layers of UNIX operating system. On the outermost layer sits the user with application programs and other utilities. The kernel interacts with the actual hardware. The shell acts as the command interpreter between the user and the kernel.

The Kernel

At the center of the UNIX onion is a program called the kernel. The kernel of UNIX is the hub of the operating system. The kernel has various functions. It manages files, carries out all the data transfer between the file system and the hardware, and also manages memory. It allocates time and memory too.

The Shell

The shell acts as an interface between the user and the kernel. Shell is an intermediate program that accepts the commands, typed at the terminal and executes them to obtain kernel understandable command set. Important features are given below:

Programming Language Constructs: Shell provides powerful constructs using which exiting commands can be used to frame the job sequences or develop new utilities.

Shell Scripts: Shell commands and constructs are stored in a file, which can later be used to execute these commands like a program. This file is generally called shell script.

Shell Variables: Like other programming language one can define variable in shell program also. These variables are identified by prefixing their names with ‘$’ sign.

Variables can be classified into four categories:

Standard Variables: These are predefined in the system and therefore called built-in-variables. They hold certain system information related to particular user environment.

These are also called environmental variables.

PS1 : Represent the first prompt of the user, Default is ‘$’.

$echo $PS1

[\u@\h \W]\$

$PS1=#

#

PS2 : Represent the second prompt of the user, Default is ‘>’.

$echo $PS2

>

$

Logname: User’s login name

$logname

root

$

Positional Parameters: These are variables which receives their values from command-line as an argument. These are identified by their position on the command line as $0, $1, $2,… where $0 holds name of program and others denote another command-line argument.

Special Shell Variable: These are the variables that hold certain other information such as $$ stores process ID of the current shell, $! Stores process ID of last back ground process.

User Defined Variables: Users may define their own variables either in shell script or at the shell prompts. These variables can have any name except for those described above.

UNIX supports different types of shells. Some of these shells are:

Bourne Shell (sh)

C Shell (csh)

Korn Shell (ksh)

Job Shell (jsh)

VI. UNIX BASIC COMMANDS

A text editor is a program for storing and manipulating information in the computer. Three of the most popular editors in UNIX system are ed, vi and emacs. The ed editor works on any terminal as it takes no advantage of special terminal features.

Vi. Editor

Vi, (stands for Visual Editor,) is one of the most significant tools provided by UNIX and is used to create and edit text files. It is a screen-oriented editor that is extremely fast when scrolling through large documents. It does not support any document formatting like bold/italics, spell checking or any views of a document, as it will look when printed.

Table: Commands for quiting vi

Commands

Functions

  ZZ

Write the buffer to the file and quits vi.

  :wq

Write the buffer to the file and quits vi.

  :w filename

Write the buffer to the file filename (new).

  :q

Quits vi if changes made to the buffer were written to a file.

  :w!

Overwrites the existing file filename with the contents of the buffer.

  :q!

Quits vi whether or not change made to the buffer were written to a file. Does not incorporate changes made to the buffer since the last write (:w) command.

For example, addition of two numbers Steps to write a program

Step-1:

vi prg1

clear

echo “Input Value of a & b :”

read a

read b

c=‘expr $a + $b’

echo $c

Step-2:

(

i

). press Esc

(

ii