• No results found

Unix Shell Scripting

N/A
N/A
Protected

Academic year: 2021

Share "Unix Shell Scripting"

Copied!
130
0
0

Loading.... (view fulltext now)

Full text

(1)

UNIX SHELL SCRIPTING

Perhaps the most important achievement of UNIX is to demonstrate that a powerful operating system for interactive use need not be expensive either in equipment or in human effort: UNIX can run on hardware costing as little as $40,000, and less than two man-years were spent on the main system software.

The UNIX Time-Sharing System (1974) Dennis M. Ritchie and Ken Thompson

(2)

Tabel of Contents

Module 1. Introduction to Operating System 01

Module 2 Exploring the UNIX Shell 20

Module 3 Processes 41

Module 4 A Shell Script 45

Module 5 A Overview 49

Module 6 The vi Editor 54

Module 7 The variable 57

Module 8 Parameters 68

Module 9 Regular Expressions 71

Module 10 A Sample Shell Script 80

Module 11 Useful Utilities of Shell 93

Module 12 Arithmetic on Shell 103

Module 13 Functions 104

Module 14 Sed and AWK 107

Module 15 Database Using Shell Script 117

Module 16 Overview of Perl 123

Exercise for Lab Experience

(3)

Module 1

Introduction to Operating System:

In simple terms, an operating system is a manager. It manages all the available resources on a computer. These resources can be the hard disk, a printer, or the monitor screen. Even memory is a resource that needs to be managed. W ithin an operating system are the management functions that determine who gets to read data from the hard disk, what file is going to be printed next, what characters appear on the screen, and how much memory a certain program gets.

Note: An operating system (OS) is a collection of system programs that together control the operation of a computer system.

Operating systems may be classified by both how many tasks they can perform `simultaneously' and by how many users can be using the system `simultaneously'. That is: single-user or user and single-task or multi-tasking. A multi-user system must clearly be multi-multi-tasking.

Single User Operating System

 MS D O S /P C D O S w a s d e sig n e d sp e cifica lly to su it a sin g le u s e r‘s

requirements.

 The user can run only one program at a time.

 At any instance of time there is only one process going on in the CPU

Multi User Operating System

 Here the system is such that many users can work at a time. There is one large CPU and high capacity storage medium enclosed into what is called as the system unit and different terminals are attached to it. E a ch u se r w o rks o n a se p a ra te te rm in a l a n d u tilize s th e C P U ‘s

resources.

 Each users p ro g ra m a n d o th e r file s a re sto re d in th e s yste m u n its‘ storage media. Thus the CPU is one and many users are using it. Therefore there is a need of such an OS that will effectively divide the

(4)

Features of Multi User OS

1. Multi Processing

 As many users are working at a time, every user will run their own program. W hen one program is run by a user it is a process. When the same program is run by another user it is another process. If there are different users running different programs there are many processes undergoing execution. A u se r sh o u ld n o t w a it u n tilo th e r u se rs ‘p ro g ra m s fin ish e x e cu tio n .

 Same program can share by many users at a time and run that together. This ability of the OS to run several processing together is called multi-processing.

2. Time Sharing

 The CPU can execute only one instruction at a time. Since there are several users running their programs the OS divides the CPU time for each user. It allots a definite time interval called time slice w ith in w h ich th a t u se r‘s p ro g ra m is e xe cu te d . O n ce th e tim e slice is

o v e r th e C P U sw itch e s to th e n e xt u se r a n d e xe c u te s th a t u s e r‘s p ro g ra m . A fte r th e tim e slice o f th e u se r is o v e r th e n e xt u se r‘s program is executed.

Thus eve ry u se r‘s p ro g ra m is co n sta n tly b e in g in te rru p te d b y a n o th e r u se r‘s p ro g ra m b u t n o u se r re a lize s th is b e ca u se th e C P U

is very fast. Thus the OS effectively divides the CPU time between several users.

3. Memory Management

 A program can run only if it is loaded into the internal memory. So when many users are running their programs that all programs have to be loaded into the memory. So the CPU memory is divided logically such that all users programs get their share of the CPU m e m o ry. A lso w h e n a u se r‘s p rogram finishes execution it has to be

eliminated from the internal memory and that part of the memory sh o u ld b e u tilize d fo r sto rin g o th e r u se r‘s p ro g ra m .

4. Multi Tasking

 Many users work on a multi user environment each running their own process. Thus there is more than one process executing together. But a user can run more than one process or program for

(5)

tasking.

PARTS OF Operating System:

 Any Operating System consists of two parts.

o The Shell and

o The Kernel

The Shell: The shell acts as an interface between the user and the

machine and effectively interprets every command given by the user and advices the kernel to act accordingly.

A single user OS will have only one shell devoted entirely to the user whereas in a multi user OS every user will have a separate shell.

Kernel: The Kernel is the part of OS that interacts directly with the

hardware of the Computer system.

Why is UNIX Important?

During the past 25 years the UNIX Operating System has evolved into a powerful, flexible, and versatile operating system. It serves as the Operating System for all types of computers, including single user personal computers and engineering workstations, multi-user microcomputers, minicomputers, mainframes and supercomputers, as well as special purpose devices, with approximately 20 million computers now running UNIX and more than 100 million people using these systems. This rapid growth is expected to continue. The success of UNIX is due to many factors, including its portability to a wide range of machines, its adaptability and simplicity, the wide range of tasks that it can perform, its multi-user and multi tasking nature, and its suitability for networking, which has become increasingly important as the Internet has blossomed. W hat follows is a description of the features that have made the UNIX system so popular.

Understanding UNIX:

The UNIX operating system was designed to let a number of programmers access the computer at the same time and share its resources.

The operating system coordinates the use of the computer's resources, allowing one person, for example, to run a spell check program while another creates a document, lets another edit a document while another creates graphics, and lets another user format a document -- all at the same time, with each user oblivious to the activities of the others.

(6)

operating systems ever.

Although UNIX was developed by programmers for programmers, it provides an environment so powerful and flexible that it is found in businesses, sciences, academia, and industry. Many telecommunications switches and transmission systems also are controlled by administration and maintenance systems based on UNIX.

While initially designed for medium-sized minicomputers, the operating system was soon moved to larger, more powerful mainframe computers. As personal computers grew in popularity, versions of UNIX found their way into these boxes, and a number of companies produce UNIX-based machines for the scientific and programming communities.

The uniqueness of UNIX

The features that made UNIX a hit from the start are:

 Multitasking capability

 Multi-user capability

 Portability

 Cooperative Tools and Utilities

 Excellent Networking capability

 Open Source Code

Multitasking

Many computers do just one thing at a time, as anyone who uses a PC or laptop can attest. Try logging onto your company's network while opening your browser while opening a word processing program. Chances are the processor will freeze for a few seconds while it sorts out the multiple instructions.

UNIX, on the other hand, lets a computer do several things at once, such as printing out one file while the user edits another file. This is a major feature for users, since users don't have to wait for one application to end before starting another one.

Multi-user

The same design that permits multitasking permits multiple users to use the computer. The computer can take the commands of a number of users --determined by the design of the computer -- to run programs, access files, and print documents at the same time.

The computer can't tell the printer to print all the requests at once, but it does prioritize the requests to keep everything orderly. It also lets several users access the same document by compartmentalizing the document so that the changes of one user don't override the changes of another user.

Portability

A major contribution of the UNIX system was its portability, permitting it to move from one brand of computer to another with a minimum of code

(7)

changes. At a time when different computer lines of the same vendor didn't talk to each other -- yet alone machines of multiple vendors -- that meant a great savings in both hardware and software upgrades.

It also meant that the operating system could be upgraded without having all the customer's data inputted again. And new versions of UNIX were backward compatible with older versions, making it easier for companies to upgrade in an orderly manner.

Cooperative Tools and Utilities

UNIX comes with hundreds of programs that are divided into two classes:

Integral utilities that are absolutely necessary for the operation of the

computer, such as the command interpreter, and

Tools that aren't necessary for the operation of UNIX but provide the

user with additional capabilities, such as typesetting capabilities and e-mail.

DC Mail

Man

fsck nroff vi Calendar

Fig 1.1 UNIX Tools

Tools can be added or removed from a UNIX system, depending upon the applications required.

Excellent Networking Capability:

The UNIX system provides an excellent environment for networking. It offers programs and utilities that provide the services needed to build networked applications-the basis for distributed, networked computing. With networked computing, information and processing is shared among different computers in a network. The UNIX system has proved to be useful in client/server computing. The UNIX system also has been the base system for the development of Internet Services. UNIX provides an excellent platform for Web Servers.

(8)

Open Source Code:

UNIX has provision for protecting data and communicating with other users. The source code (Open Source) for the UNIX system has been made available to users and programmers.

History of UNIX:

1965 Bell Laboratories joins with MIT and General Electric in the

development effort for the new operating system, Multics, which would provide multi-user, multi-processor, and multi-level (hierarchical) file system, among its many forward-looking features.

1969 AT&T was unhappy with the progress and drops out of the Multics

project. Some of the Bell Labs programmers who had worked on this project, Ken Thompson, Dennis Ritchie, Rudd Canaday, and Doug McIlroy designed and implemented the first version of the Unix File System on a

PDP-7 along with a few utilities. It was given the name UNIX by Brian Kernighan as

a pun on Multics.

1971 The system now runs on a PDP-11, with 16Kbytes of memory, including

8Kbytes for user programs and a 512Kbyte disk.

Its first real use is as a text processing tool for the patent department at Bell Labs. That utilization justified further research and development by the programming group. UNIX caught on among programmers because it was designed with these features:

 Programmers environment  Simple user interface

 Simple utilities that can be combined to perform powerful functions  Hierarchical file system

 Simple interface to devices consistent with file format  Multi-user, multi-process system

 Architecture independent and transparent to the user.

1973 UNIX is re-written using C, a new language developed by Dennis Ritchie. Being written in this high-level language greatly decreased the effort

needed to port it to new machines.

1974 Thompson and Ritchie publish a paper in the Communications of the ACM describing the new Unix OS. This generates enthusiasm in the

Academic community which sees a potentially great teaching tool for studying programming systems development. Since AT&T is prevented from marketing the product due to the 1956 Consent Decree they license it to Universities for educational purposes and to commercial entities.

By 1977, the fifth and sixth editions had been released; these contained many new tools and utilities. The number of machines running the UNIX System,

(9)

primarily at Bell laboratories and Universities, increased to more than 600 by 1978. The seventh edition, the direct ancestor of the UNIX Operating System available today, was released in 1979.

UNIX System III, based on the Seventh edition, became A T & T ‘s first

commercial release of the UNUX System in 1982. However, after System III was released, AT&T, through its W estern Electric manufacturing subsidiary, continued to sell versions of the UNIX system. UNIX System III, the various research editions, and experimental versions were distributed to colleagues at universities and other research laboratories.

A UNIX System Timeline

The following timeline summarizes the development of UNIX from its beginning -Year 1969 1973 1975 1978 1979 1980 1980 1982 1983 1983

UNIX Variant or Standard

UNICS (later called UNIX)

Fourth Edition Sixth Edition 3BSD Seventh Edition Xenix 4BSD System III System V Release 1 4.1BSD Comments

A new operating system invented by Ken Thompson and Dennis Ritchie for the PDP-7

Written in C programming language; widely used inside Bell Laboratories First version widely available

outside of Bell Labs; more than 600 machines ran it

Virtual memory

Included the Bourne shell, UUCP, and C; the direct ancestor or modern UNIX

Introduced by Microsoft Introduced by UC Berkeley

First public release outside of Bell Labs

(10)

1984 1986 1987 1987 1988 1989 1990 1990 1991 1992 1992 1993 1993 1993 1994 1994 1995 1995 1995 1996 System V Release 2 HP-UX System V Release 3 4.3BSD POSIX System V Release 4 XPG3 OSF/1 Linux 0.01 SVR4.2 HP-UX 9.0 Solaris 2.3 4.4BSD SVR4.2MP Linux 1.0 Solaris 2.4 UNIX 95 Solaris 2.5 HP-UX 10.0 Linux 2.0

UC Berkeley release with many networking capabilities

Protection and locking of files, enhanced system administration, and job control features added First version of HP-UX released for HP Precision Architecture

STREAMS, RFS, TLI added Minor enhancements to 4.2BSD POSIX.l published

Unified System V, BSD, and Xenix X/Open specification set

Open Software Foundation release designed to compete with SVR4 Linus Torvalds started development of Linux

USL developed version of SVR4 for the desktop

Supported workstations including a GUI

POSIX compliant Final Berkeley release

Last version of UNIX developed by USL

First version of Linux not considered a "beta"

Motif supported

X/Open mark for systems registered under the Single UNIX Specification CDE supported

(11)

1997 1997 1997 1997 1997 1998 1998 1999 Solaris 2.6

Single UNIX Specification, Ver2 System V Release 5 (SVR5) (SCO) UnixW are 7 HP-UX 11.0 UNIX 98 Solaris 7 Linux 2.2

Specification and the Common Desktop Environment (CDE) Performance improvements and networking software added

UNIX 95 compliant, JAVA supported Open Group specification set

Enhanced SV kernel, including 64-bit support, increased reliability, and performance enhancements

SCO UNIX based on SVR5 kernel 64-bit operating system

Open Group mark for systems registered under the Single UNIX Specification, Version 2

Support for 64-bit applications, free for noncommercial users

Device drivers added

Versions of UNIX Today

With most things in life, where there is active competition the best will ultimately survive and triumph. This is the case with several different versions or flavors of UNIX. Although many different versions exist, a common design and/or code base is present in most of them. Also, two major kinds of UNIX operating system software markets exist today. The commercial market is where customers generally have to pay for the operating system software and generally may not get any source code (well, not for free anyway!). The other market is also commercial, but is considered open source. Open source means that you get full access to the source code of the system or programs and can make changes or modifications to that source code as long as you maintain the rights of the original software owner.

(12)

Why UNIX Is Popular?

Many people ask why UNIX is so popular or why it is used so much, in so many different ways and in so many computing environments. The answer lies with the very nature of UNIX and the model that was used to design, build, and continuously improve the operating system.

Availability of Source Code

One of the most significant points of UNIX is the availability of source code for the system. (For those new to software, source code contains the programming elements that, when passed through a compiler, will produce a binary program— which can be executed.) The binary program contains sp e cific co m p u te r in stru ctio n s, w h ich te lls th e s yste m ―w h a t to d o .‖ W h e n th e source code is available, it means that the system (or any subcomponent) can

be modified without consulting the original author ofthe program. Access to the source code is a very positive thing and can result in many benefits. For example, if software defects (bugs) are found within the source code, they can be fixed right away— without perhaps waiting for the author to do so.

Another great reason is that new software functions can be integrated into the source code, thereby increasing the usefulness and the overall functionality of th e so ftw a re . H a vin g th e a b ility to e xte n d th e so ftw a re to th e u s e r‘s requirements is a massive gain for the end user and the software industry as a whole. Over time, the software can become much more useful. One downside to having access to the source code is that it can become hard to manage, because it is possible that many different people could have modified the code in unpredictable (and perhaps negative) ways. However, th is p ro b le m is typ ica lly a d d re sse d b y h a v in g a ―s o u rce co d e m a in ta in e r,‖

which reviews the source code changes before the modifications are incorporated into the original version.

Another downside to source code access is that individuals may use this information with the goal in mind of compromising system or component security. The Internet W orm of 1988 is one such popular example. The author, who was a graduate student at Cornell University at the time, was able to exploit known security problems within the UNIX system to launch a software program that gained unauthorized access to systems and was able to replicate itself to many networked computers. The Worm was so successful in attaching and attacking systems that it caused many of the computers to crash due to the amount of resources needed to replicate. Although the W orm d id n ‘t a ctu a lly ca u se sig n ific a n t p e rm a n e n t d a m a g e to th e s yste m s it in fe cte d ,

it opened the eyes of the UNIX community about the dangers of source code access and security on the Internet as a whole.

(13)

UNIX was designed to be modular, which makes it a very flexible architecture. The modularity helps provide a framework that makes it much easier to introduce new operating system tools, applications, and utilities, or to help in the migration of the operating system to new computer platforms or other d e vice s. A lth o u g h so m e m ig h t a rg u m e n t th a t U N IX isn ‘t fle xib le e n o u g h fo r their needs, it is quite adaptable and can handle most requirements. This is evidenced by the fact that UNIX runs on more general computer platforms and devices than any other operating system.

GNU

The GNU project, started in the early 1980s, was intended to act as a counterbalance to the widespread activity of corporate greed and adoption of lice n s e a g re e m e n ts fo r co m p u te r so ftw a re . T h e ―GNU is not UNIX‖ p ro je ct

w a s re sp o n sib le fo r p ro d u cin g so m e o f th e w o rld ‘s m o st p o p u la r U N IX

software.

This includes the Emacs editor and the gcc compiler. They are the cornerstones of the many tools that a significant number of developers use every day.

Open Software

UNIX is open, which basically means that no single company, institution, or individual owns UNIX— nor can it be controlled by a central authority. However, the UNIX name remains a trademark. Anyone using the Internet may obtain open source software, install it, and modify it, and then redistribute the software without ever having to shell out any money in

the process. The open source movement has gained great

advances and has clearly demonstrated that quality software can, in fact, be free. Granted, it is quite true that certain versions of UNIX are not open, and you do indeed need to pay to use these operating systems in the form of an end-user licensing agreement. Generally speaking, vendors that charge for UNIX represent only

a portion of the total number of UNIX releases available within the UNIX community.

Programming Environment

UNIX provides one ofthe best development environments available by providing many of the important tools software developers need. Also, there are software tools such as compilers and interpreters for just about every major programming language known in the world. Not only can one write programs in just about any computer language, UNIX also provides additional

(14)

Availability of Many Tools

UNIX comes with a large number of useful applications, utilities, and p ro g ra m s, w h ich m a n y p e o p le c o n sid e r to b e o n e o f U N IX ‘s g re a te st strengths. They are collectively known or commonly referred to as UNIX

―to o ls,‖ a n d th e y co v e r a w id e ra n g e o f fu n ctio n s a n d p u rp o se s. O n e o f th e most significant aspects of UNIX is the availability of software to accomplish one or more very specific tasks. You will find throughout this text that the concept of tools is quite universal and is used repeatedly. This book not only discusses the subject of system administration but also provides detailed descriptions of UNIX-based tools. As a system administrator, you will come to depend on certain tools to help you do your job. Just as construction workers

rely on the tools they use, so too will the administrator rely on the software that permits them to handle a wide range of functions, tasks, issues, and problems.

There are tools to handle many system administration tasks that you might encounter. Also, there are tools for development, graphics manipulation, text processing, database operations— just about any user- or system-related re q u ire m e n t. If th e b a s ic o p e ra tin g s yste m v e rsio n d o e s n ‘t p ro v id e a p a rticular tool that you need, chances are that someone has already developed the tool and it would be available via the Internet.

System Libraries

A system library is a collection of software that programmers use to augment their applications. UNIX comes with quite a large collection of functions or routines that can be accessed from several different languages to aid the application writer with a variety of tasks. For example, should the need arise to sort data, UNIX provides several different sort functions.

Well Documented

UNIX is well documented with both online manuals and with many reference books and user guides from publishers. Unlike some operating systems, UNIX provides online main page documentation of all tools that ship with the system.

Also, it is quite customary that open source tools provide good documentation.

Further, the UNIX community provides journals and magazine articles about UNIX, tools, and related topics of interest.

(15)

ARCHITECTURE OF UNIX SYSTEM:

To understand how the UNIX System works, you need to understand its structure. The UNIX Operating System is made up of several major components. Those components include the Kernel, the shell, the file

system, and the commands or user programs.

UNIX is a layered operating system. The innermost layer is the hardware that provides the services for the OS. The operating system, referred to in UNIX as the kernel, interacts directly with the hardware and provides the services to th e u se r p ro g ra m s. T h e se u se r p ro g ra m s d o n ‘t n e e d to k n o w a n ything about the hardware. They just need to know how to interact with the kernel a n d it‘s u p to th e k e rn e lto p ro v id e th e d e sire d se rv ice . O n e o f th e b ig a p p e a ls

of UNIX to programmers has been that most well written user programs are independent of the underlying hardware, making them readily portable to new systems.

Note: The core of the UNIX system is the Kernel. The kernel controls the co m p u ter’s reso u rc es, allo ttin g th em to d ifferen t u sers an d to d ifferen t tasks.

User programs interact with the kernel through a set of standard system

calls. These system calls request services to be provided by the kernel. Such

services would include accessing a file: open close, read, write, link, or execute a file; starting or updating accounting records; changing ownership of a file or directory; changing to a new directory; creating, suspending, or killing a process; enabling access to hardware devices; and setting limits on system resources.

UNIX is a multi-user, multi-tasking operating system. You can have many use rs lo g g e d in to a s yste m sim u lta n e o u sly, e a ch ru n n in g m a n y p ro g ra m s. It‘s th e ke rn e l‘s jo b to ke e p e a ch p ro ce ss a n d u se r se p a ra te a n d to re g u la te access to system hardware, including CPU, memory, disk and other I/O devices.

UNIX utilities or commands are a collection of about 200 programs that

service the day-to-day processing requirements. These programs are invoked through the shell, which is itself another utility.

Apart from the utilities that are provided as part of the UNIX operating system, more than a thousand UNIX based application programs, like database management systems, word processors, accounting software etc.,

(16)

UNIX SHELLS

The Shell reads your commands and interprets them as requests to execute a program or programs, which it then arranges to have carried out. Because the shell plays this role, it is called a command interpreter. Besides being a command interpreter, the shell is also a programming language. As a programming language, it permits you to control how and when commands are carried out. For each user working with UNIX at any time different shell programs are raining. There may be several shells running in memory, but only one kernel.

UNIX shell, including three major variants of the shell. 1. The Bourne shell

2. The C Shell 3. The Korn shell

(17)

The original UNIX system shell, sh, was written by Steve Bourne, and as a result it is known as the Bourne shell.

The C shell, csh, was originally developed as part of BSD UNIX. csh

introduced a number of important enhancement to sh, including the concept of a command history list and job control.

The Korn shell, ksh, builds on the sh and extends it by adding many features from the C shell.

Each of these shells has their own respective prompts. The Bourne shell has the $ prompt. So when you login it is the bourn shell that is established for you and the stage is set for you to work on the machine.

Features of Shell:

Interactive Processing: It acts as an interface and provides

communication between the users and the system.

Background Processing: Time consuming; non-interactive tasks can

proceed while the user continues with other processing.

Input/Output redirection: Programs, which can interact with a user,

can be made to take their input from another source, such as a file and send their output to another destination, such as printers.

Shell Scripts: A frequently used sequence of shell commands can be

stored in a file. The name of the file can be later used to execute the stored sequence with a single command.

Shell Variables: The user can control the behavior of the shell, as well

(18)

The File System

The UNIX file system looks like an inverted tree structure. You start with the

root directory, denoted by /, at the top and work down through sub-directories

underneath it.

Sreedhar Solo STUD

Each node is either a file or a directory of files, where the latter can contain other files and directories. You specify a file or directory by its path name, either the full, or absolute, path name or the one relative to a location. The full path name starts with the root, /, and follows the branches of the file system, each separated by /, until you reach the desired file, e.g.:

/home/Sreedhar/source/xntp

A relative path name specifies the path relative to another, usually the current working directory that you are at. Two special directory entries should be introduced now:

● the current directory

● ● the parent of the current directory

S o if I‘m a t /h o m e /fra n k a n d w ish to sp e cify th e p a th a b o ve in a re la tive fashion I could use:

(19)

This indicates that I should first go up one directory level, then come down through the Sreedhar directory, followed by the source directory and then to

xntp.

Unix Directories, Files and Inodes

Every directory and file is listed in its parent directory. In the case of the root directory, that parent is itself. A directory is a file that contains a table listing the files contained within it, giving file names to the inode numbers in the list. An inode is a special file designed to be read by the kernel to learn the information about each file. It specifies the permissions on the file, ownership, date of creation and of last access and change, and the physical location of the data blocks on the disk containing the file.

The system does not require any particular structure for the data in the file itself. The file can be ASCII or binary or a combination, and may represent text data, a shell script, compiled object code for a program, directory table, junk, or anything you would like.

T h e re ‘s n o h e a d e r, tra ile r, la b e l in fo rm a tio n o r EOF character as part of the file.

Unix Programs

A program, or command, interacts with the kernel to provide the environment and perform the functions called for by the user. A program can be: an executable shell file, known as a shell script; a built-in shell command; or a source compiled, object code file.

The shell is a command line interpreter. The user interacts with the kernel through the shell. You can write ASCII (text) scripts to be acted upon by a shell.

System programs are usually binary, having been compiled from C source code. These are located in places like /bin, /usr/bin, /usr/local/bin, /usr/ucb, etc.

(20)

Module 2

Exploring the UNIX Shell:

The shell is a rather unique component of the UNIX operating system since it is one of the primary ways to interact with the system. It is typically through the shell that users execute other commands or invoke additional functions. The shell is commonly referred to as a command interpreter and is responsible for executing tasks on behalf of the user. Figure 2-1 shows a pictorial view of how the shell fits with the UNIX system. As you can see, the shell operates within the framework just like any other program. It provides an interface between the user, the operating system functions, and ultimately the system Kernel.

The UNIX Shell

Another powerful feature of the UNIX shell is the ability to support the development and execution of custom shell scripts. The shell contains a mini programming language that provides a lightweight way to develop new tools and utilities without having to be a heavyweight software programmer. A UNIX shell script is a combination of internal shell commands, regular UNIX commands, and some shell programming rules.

UNIX supports a large number of different shells, and also many of the popular ones are freely available on the Internet. Also, many versions of UNIX come with one or more shells and as the system administrator, you can install

(21)

additional shells when necessary and configure the users of the system to use different shells, depending on specific preferences or requirements. The table below lists many of the popular shells and a general description of each. Once a user has logged into the system, the default shell prompt appears and the shell simply waits for input from the user. Thus, logging into a Solaris system as the root user for example, the standard Bourne shell prompt will be #

The system echoes this prompt to signal that it is ready to receive input from the keyboard. At this point, this user is free to type in any standard UNIX command, application, or custom script name and the system will attempt to execute or run the command. The shell assumes that the first argument given

Shell Name General Description

sh Standard Bourne shell, which is one of the most popular shells around.

csh Standard shell with C like language support

bash GNU Bourne-Again shell that includes elements from the Korn shell and C shell.

tcsh Standard C shell with command-line editing and filename completion capabilities.

ksh The Korn shell combines the best features of the Bourne and C shells and includes powerful programming tools

zsh Korn shell like, but also provides many more features such as built-in spell correction and programmable command completion.

Accessing a UNIX System

The configuration you use to access your UNIX System can be based on one of two basic models: using multi-user computer or single user computer. On a multi-user system, you use your own terminal device to access the UNIX system. The computer you access can be a workstation, a microcomputer, a mainframe computer, or even a super computer.

(22)

Your display can be character-based, or it can be bit mapped. It may display a single window or multiple windows, as in the X-W indows system.

Before You Start

UNIX System from a PC: Many different application packages, called

terminal emulators, run on a PC and enable you to connect to a UNIX system. Terminal emulators all function the same basic way, in that they act as terminal attached to the UNIX machine. This allows you to enter commands the same way that you would if you were using a terminal.

UNIX System from a Terminal: If your terminal has not been set to work with

a UNIX System, you must have its options set appropriately. Setting options is done in different ways on different terminals.

Selecting a LOGIN : Every UNIX System has at least one person, called the

System Administrator, whose job is to maintain the system, and make it available to its users. The system administrator is also responsible for adding new users to the system and setting up their initial work environment on the computer.

Login name should created by the system administrator. In general, login name (logname) can be almost any combination of letters and numbers, but the UNIX System places some constraints on logname selections:

 Login name must be more than two characters long, and if it is longer than eight, only the first eight characters are relevant.

 It can contain any combination of lowercase letters and numbers and must begin with a lowercase letter. If you log in using uppercase letters, a UNIX system will assume that your terminal can only receive uppercase letters, and will only send uppercase letters for the entire session.

Your logname should not have any symbols or spaces in it, and it must be unique for each user. Some lognames are reserved customarily for certain uses. For example, the root normally refers to the system administrator or superuser who is responsible for the whole system.

Connecting to a UNIX System:

Direct Connect: W ith single user workstations and personal computers, and

with the primary administration terminal on a multi-user system (console), a cable permanently connects the terminal with the computer. After booting your PC and invoking your terminal emulator or turning on your terminal, hit the carriage return and you should see the UNIX System prompt that says

(23)

login:

Dial in Access: You may have to dial into the computer using a modem

before you are connected. Use your emulator or dial function to dial the UNIX System access number. W hen the system answers the call, you will hear a high-pitched tone you should see some characters appear on screen. Then you getting UNIX system login prompt.

Local Area Network: Another means of connecting your PC or terminal to the

UNIX System is via a local I network. A local area network (LAN) is a set of communication devices and cables t connects several PCs or terminals and computers. A number of LAN environments are in use today, such as LAN Manager and NetW are. Each LAN environment provides a set of software that can be used in conjunction with a specialized hardware card at each end of the network, called a NIC (network interface card) or a LAN card; that enables you to connect a client machine to a server machine. The clients and servers may be running Windows or UNIX, or both. The protocol most frequently used to connect a client machine to a UNIX server is TCP/IP, with other protocols such as IPX and SPX also widely used on LANs.

An example of this environment would be a group of W indows PCs connected to a common UNIX server running a UNIX operating system such as UnixW are 7, Solaris, or Linux. This type of environment usually is maintained by a LAN administrator, a person who knows how local area networks work. This is often the same person like system administrator.

In accessing a UNIX System on a LAN, you first need to configure your PC to be able to recognize the system you wish to connect to.

IP Network: If PC is connected to an IP network, such as the Internet or an

intranet, you can use the telnet command to access any computer on this network that allows such connections. The computer you access may be a UNIX computer, or a computer running some other Operating system, and it may be a local computer or one located thousands of miles away. A variety of

telnet commands can help you manage a telnet session with the computer

you accessing.

Logging In:

As a multi-user system, the UNIX System first requires that you identify yourself before you access to the system.

(24)

Changing Your Password:

When you first log into a UNIX System, you will have either no password at all (a null password) or an arbitrary password assigned by the system administrator. These are only intended for temporary use. Neither offers any real security. A null password gives anyone access to your account; one assigned by the system administrator is likely to be easily guessed by someone. Officially assigned passwords often consist of simple combinations of your initials and your student, employee, or social security number. If your password is simply your employee number and the letter X, anyone with access to this information has access to all of your computer files. Sometimes random combinations of letters and numbers are used. Such passwords are difficult to remember, and consequently users will be tempted to write them down in a convenient place. (Resist this temptation!)

The passwd Command :

You change your password by using the passwd command. When you issue this command, the system checks to see if you are the owner of the login. This prevents someone from changing your password and locking you out of your own account. passwd first announces that it is changing the password, and then it asks for your (current) old password, like this:

$ passwd

passwd: changing password Old password:

New password:

Re-enter new password: $

The system asks for a new password and asks for the password to be verified (you do this by retyping it). The next time you log in, the new password is effective. Although you can ordinarily change your password whenever you want, on some systems after you change your password you must wait a specific period of time before you can change it again.

How to pick a password?

When choosing a password, it is important that it be something that could not be guessed -- either by somebody unknown to you trying to break in, or by an acquaintance who knows you. Suggestions for choosing and using a password follow:

(25)

Don't . Use a word (or words) in any language  Use a proper name

 Use information that can be found in your wallet

 Use information commonly known about you (car license, pet name, etc)

 Use control characters. Some systems can't handle them  Write your password anywhere

 Ever give your password to *anybody*

Do . Use a mixture of character types (alphabetic, numeric, special)

 Use a mixture of upper case and lower case  Use at least 6 characters

 Choose a password you can remember  Change your password often

 Make sure nobody is looking over your shoulder when you are entering your password

Caution: If you do forget your password, there is no way to retrieve it. Because it is encrypted, even your system administrator cannot lookup your password. If you cannot remember it administrator will have to give you a new password.

Changing a Password at Initial Login

On some systems, you will be required to change your password the first time you log in. This will work as described previously and will look like this:

login: sreedhar Password:

Your password has expired. Choose a new one.

Old password: New password:

Re-enter new password: Password Aging

To ensure the secrecy of your password, you will not be allowed to use the same password for long stretches of time. On UNIX Systems, passwords age. When yours gets to the end of its lifespan, you will be asked to change it. The length of time your password will be valid is determined by your system administrator. However, you can view the status of your password on most UNIX systems. Generally, the s option to the passwd command shows you

(26)

$ passwd -s

rayjay PW 04/01/99 7 30 5 name

passwd status date last changed

min days between changes max days between changes

days before user will be warned to change password

The first field contains your login name; the next fields list the status of your password, the date it was last changed, and the minimum and maximum days allowed between password changes; and the last field is the number of days before your password will need to be changed. Note that this is simply an example-Km your system, you may not be allowed to read all of these fields.

An Incorrect Login

If you make a mistake in typing either your login or your password, the UNIX System will respond this way:

login: sreedhar Password: Login Incorrect login:

You will receive the "Password:" prompt even if you type an incorrect or nonexistent login name. This prevents someone from guessing login names and learning which one is valid by discovering one that yields the

"Password:" prompt. Because any login results in "Password:" an intruder

cannot guess login names in this way.

If you repeatedly type your login or password incorrectly (three to five times, depending on how your system administrator has set the default), the UNIX System will disconnect your terminal if it is connected via modem or LAN. On some systems, the system administrator will be notified of erroneous login attempts as a security measure. If you do not successfully log in within some time interval (usually a minute), you will be disconnected.

If you have problems logging in, you might also check to make sure that your CAPS LOCKkey has not been set. If it has been set, you will inadvertently enter an incorrect logname or password, because in UNIX uppercase and lowercase letters are treated differently. (Note that unlike in some other environments, your account will not get locked if you enter your password incorrectly some number of times, you will just get disconnected.)

(27)

When you successfully enter your login and password, the UNIX System responds with a set of messages, similar to this:

login: sreedhar Password:

UNIX System V/386/486 Release 4.0 Version 3.0 minnie

Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T Copyright (C) 1987, 1988 Microsoft Corp.

Copyright (C) 1990, NCR Corp. All Rights Reserved

Last login: Mon January 29 19:55:17 on term/17

You first see the UNIX System announcement that tells you the particular version of UNIX you are using. Next you see the name of your system, minnie in this case. This is followed by the copyright notice.

Finally, you see a line that tells you when you logged in last. This is a security feature. If the time of your last login does not agree with when you remember logging in, call your system administrator. This discrepancy could be an indication that someone has broken into your system and is using your login. After this initial announcement, the UNIX System presents system messages and news.

Message of the Day (MOID)

Because every user has to log in, the login sequence is the natural place to put messages that need to be seen by all users. W hen you log in, you will first see a message of the day (MOTD). Because every user must see this MOTD, the system administrator (or root) usually reserves these messages for comments of general interest, such as this:

Attention ALL Users !!!

minnie will be coming down on Sunday Feb. 5, 2007 from 8:00am until 12:00pm (noon) for system maintenance. Please schedule your work accordingly. Thank you.

The UNIX System Prompt

(28)

$

This $ is the indication that the UNIX System is waiting for you to enter a command.

In the examples in this book, you will see the $ at the beginning of a line as it would be seen on the screen, but you are not supposed to type it.

The command prompt is frequently changed by users. Users who have accounts on different machines may use a different prompt on each one to remind them which computer they are using. Some users change their prompt to tell them where they are in the UNIX file system or you may simply find the $ symbol unappealing and wish to use a different symbol or set of symbols that you find more attractive. It is simple to do this.

The UNIX System enables you to define a prompt string, PS1, which is used as a command prompt. The symbol PS1 is a shell variable (see Chapter 7) that contains the string you want to use as your prompt. To change the command prompt, set PS1 to some new string. For example,

$ PS1 = "UNIX:> "

changes your primary prompt string from whatever it currently is to the string "

UNIX:> ". From that point, whenever the UNIX System is waiting for you to

enter a command, it will display this new prompt at the beginning of the line. You can change your prompt to any string of characters you want. You can use it to remind yourself which system you are on, like this:

$ PS1="MyUnix-> MyUnix->

or simply to give yourself a reminder:

$ PS1="Leave at 4:30 PM> " Leave at 4:30 p.m.>

If you redefine your prompt, it stays effective until you change it or until you log off. Later in this chapter, you will learn how to make these changes automatically when you first log in.

Some Basic UNIX Commands

Entering Commands on UNIX Systems

The UNIX System makes a large number of programs available to the user. To run one of these programs you issue a command. For example, when you type news or passwd, you are really instructing the UNIX System command interpreter to execute a program with the name news or passwd, and to display the results on your screen.

(29)

Some commands simply provide information to you; news works this way. An often-used command is date, which prints out the current day, date, and time. There are hundreds of other commands, and you will learn about many of them in this book. Different variants of the UNIX system share a large common set of commands (sometimes different names are used for the same command in different UNIX variants) and provide other commands that are unique for that particular version of UNIX.

Unix Command Line Structure

The UNIX system offers several file and directory related commands which the user can use according to his requirement.

A command is a program that tells the Unix system to do something. It has the form:

command [options] [arguments]

where an argument indicates on what the command is to perform its action, usually a file or series of files. An option modifies the command, changing the way it performs.

Commands are case sensitive. command and Command are not the same.

Options are generally preceded by a hyphen (-), and for most commands,

more than one option can be strung together, in the form:

command -[option][option][option]

e.g.: ls – alR

will perform a long list on all files in the current directory and recursively perform the list through all sub-directories.

For most commands you can separate the options, preceding each with a hyphen, e.g.:

command -option1 -option2 -option3

as in:

ls -a -l – R

Some commands have options that require parameters. Options requiring parameters are usually specified separately,

(30)

These are the standard conventions for commands. However, not all Unix co m m a n d s w ill fo llo w th e sta n d a rd . S o m e d o n ‘t re q u ire th e h yp h e n b e fo re o p tio n s a n d so m e w o n ‘t le t yo u g ro u p o p tio n s to g e th e r, i.e . th e y m a y re q u ire that each option be preceded by a hyphen and separated by white space from other options and arguments.

Options and syntax for a command are listed in the man page for the command.

UNIX Commands:

UNIX comes with a large number of commands that fall under each of the categories listed above for both the generic user and the system administrator. It is quite hard to list and explain all of the available UNIX functions and/or commands in a single book. Therefore, a review of some of the more important user-level commands and functions has been provided and subsequent modules provide a more in-depth look at system-level commands. All of the commands discussed below can be run by generic users and of course by the system administrator. However, one or more subfunctions of a command may be available only to the system administrator.

The standard commands are listed bellow, which are available across many different versions of UNIX. For example, if we wanted to get a listing of all the users that are currently logged into the system, the who command can be used. UNIX cat date hostname find grep ls more ps who Command Meaning

Show the content of file. Show system date and time. Display name of system. Search for a specific file.

Search a file for specified pattern. List files in a directory.

Another command to show content of file. Show status of processes.

(31)

Metacharacters and Wildcards

The metacharacters have special meaning to the shell; they should not normally be used as any part of a file name.

The "-" symbol can usually be used in a filename provided it is not the first character. For example, if we had a file called -l then issuing the command ls

-l would give you a long listing of the current directory because the ls

command would think the l was an option rather than -l being a file name argument. Some UNIX commands provide facilities to overcome this problem. The shell offers certain special characters called a wild card character that helps us to specify certain patterns. The shell will then match the pattern in the file names and select all the files whose name matches the pattern and will apply the specified file command. The wild card characters are as follows

 This wild card character matches any number of characters.

 Therefore any pattern which contains the  symbol it will be replaced by any number of any characters.

(32)

The wildcard ? is expanded by the shell to match any single character in a file name. The exception is that the ? w ill N O T m a tch a d o t ―.‖ a s the first character of a file name (for example, in a hidden file).

The wildcard * is expanded by the shell to match zero to any number of characters in a file name. The single * will be expanded to mean all files in the current directory except those beginning with a dot. Beware of the command

rm * which could cause serious damage removing all files! Specifying a Multiple File Names

Multiple filenames can be specified using special pattern-matching characters. The rules are:

 '?' matches any single character in that position in the filename.  '*' matches zero or more characters in the filename. A '*' on its

own will match all files. '*.*' matches all files with containing a '.'.  Characters enclosed in square brackets ('[' and ']') will match

any filename that has one of those characters in that position.  A list of comma separated strings enclosed in curly braces ("{"

and "}") will be expanded as a Cartesian product with the surrounding characters.

For example:

(33)

2. ?ell? matches any five-character filenames with 'ell' in the middle.

3. he* matches any filename beginning with 'he'.

4. [m-z]*[a-l] matches any filename that begins with a letter from 'm' to 'z' and ends in a letter from 'a' to 'l'.

5. {/usr,}{/bin,/lib}/file expands to /usr/bin/file /usr/lib/file /bin/file and /lib/file.

Note that the UNIX shell performs these expansions (including any filename matching) on a command's arguments before the command is executed.

Example

*c

includes all files ending with '.c' because * stands for any number of any characters, e.g new.c, ptr.c, str.c etc.

A command like rm *.c will therefore delete all files ending with '.c' The other files which do not end with '.c' will be retained. The pattern specifies that the files must neccessarily end with '.c'.

? ▬ T h is w ild ca rd sp e cifie s a n y o n e ch a ra cte r. T h e re fo re in a p a tte rn if th e

wild card ? appears then it will be replaced by any one character.

Example

cat ab?xy

The above command will display the contents of all files whose name starts with ab followed by any one character followed by xy.

This wild card specifies any one of the character listed out within the [ ].

Example

rm ab[efg]yz

The above command will delete all the files that begin with ab followed by either e, f, or g followed by xy.

PIPES  UNIX offers a provision whereby the output of one program can be

made the

input of another program. Both the programs are separated by the | symbol.

Example

(34)

The above command will display the contents of the file fll.c page by page because the output is piped to a program called pg which displays the output only one screenful at a time.

UNIX Standard Files:

There are three files are automatically opened for each process in the system. These files are referred to as standard input, standard output and standard

error.

Standard input, sometimes abbreviated to stdin is where a command expects to find its input, usually the keyboard.

Standard out (stdout) and standard error (stderr) is where the command expects to put its output, usually the screen.

(35)

Note: Remember that in AIX, not all file names refer to real data files!

S o m e file s m a y b e ―sp e cia lfile s‖ w h ich in re a lity a re a p o in te r to so m e of the devices on the system (for example /dev/tty0).

(36)
(37)
(38)

Two or more commands can be separated by a pipe on a single command line. The requirement is that any command to the left of a pipe must send output to standard output.

Any command to the right of the pipe must take its input from standard input. The example on the visual shows that the output of who is passed as input to

(39)

A command is referred to as a filter if it can read its input from standard input, alter it in some way, and write its output to standard output. A filter can be used as an intermediate command between pipes.

A filter is commonly used with a string of piped commands, as in the example above. The ls -l command lists all the files in the current directory and then pipes this information to the grep command. The grep command will be covered in more detail later in the course, but in this example, the grep command is used to find all lines beginning with a d (directories).

The output of the grep command is then piped to the wc -l command. The result is that the command is counting the number of directories. In this example, the grep command is acting as a filter.

Placing multiple commands separated b y a ― ; ‖ o n a sin g le lin e p ro d u ce s th e same result as entering each command on a separate command line. There need be no association between the two commands.

(40)

The \ must be the last character on the line and immediately followed by pressing Enter.

Do not confuse the continuation prompt > with the redirection character >. The secondary prompt will not form part of the completed command line. If you require a redirection character you must type it explicitly.

Module 3

Processes:

(41)

a process.

UNIX can run a number of different processes at the same time as well as many occurrences of a program (such as vi) existing simultaneously in the system.

The process ID (PID) is extracted from a process table.

In a shell environment, the process ID is stored in the variable $$.

To identify the running processes, execute the command ps, which will be covered later in this course. For example, ps -u team01 shows all running processes from user team01.

(42)

ps prints information only about processes started from your current terminal.

Only the Process ID, Terminal, Elapsed Time and Command are displayed. The -e option displays information about EVERY process running in the system.

The -f option in addition to the default information provided by ps, displays the User Name, PPID, start time for each process (that is, a FULL listing).

The -l option displays the User ID, PPID and priorities for each process in addition to the information provided by ps (that is, a LONG listing)

(43)

Processes that are started from and require interaction with the terminal are called foreground processes. Processes that are run independently of the initiating terminal are referred to as background processes.

Background processes are most useful with commands that take a long time to run.

A process can only be run in the background if: 1. It doesn't require keyboard input, and

2. It is invoked with an ampersand & as the last character in the command line.

Notes: The <ctrl-c> may not always work. A Shell script or program can trap

(44)

You can stop a foreground process by pressing <ctrl-z>. This does not terminate the process; it suspends it so that you can subsequently restart it. To restart a suspended processes in the background, use the bg command. To bring a suspended or background process into the foreground, use the fg command.

To find out what suspended/background jobs you have, issue the jobs command.

The bg, fg, kill commands can be used with a job number. For instance, to kill job number 3, you can issue the command: kill %3 The jobs command does not list jobs that were started with the nohup command if the user has logged off and then logged back into the system. On the other hand, if a user invokes a job with the nohup command and then issues the jobs command without logging off, the job will be listed.

(45)

Module 4

Shell Script:

A shell script is a simple text file that contains UNIX commands.

When a shell script is executed, the shell reads the file one line at a time and processes the commands in sequence.

Any UNIX command can be run from within a shell script. There are also a number of built-in shell facilities which allow more complicated functions to be performed. These will be illustrated later.

(46)

A shell script is a collection of commands in a file. In the example a shell script hello is shown.

To execute this script, start the program ksh and pass the name of the shell script as argument:

$ ksh hello

This shell reads the commands from the script and executes all commands line by line.

The .profie file

A fte r a u se r lo g s in a n d a s p a rt o f sta rtin g u p th e u se r‘s sh e ll, two profile files are executed. The first is the system profile /etc/profile, which is run by every user, and the second is the .profile in the user home directory, which is only run by the user who owns it.

The .profile contains a sequence of commands that help you customize your environment. Because the .profile is read each time you start a new Korn shell, the commands you put in this file to customize your environment will be executed each time you start a new ksh.

(47)

1. aliases

2. terminal control characteristics

3. creation/definition of shell environment variables (including your prompt)

The first file that the operating system uses at login is the /etc/environment file. This file contains variables specifying the basic environment for all processes and can only be changed by the system administrator.

The second file that the operating system uses at login time is the /etc/profile file. This file controls system-wide default variables such as the mail messages and terminal types.

/etc/profile can only be changed by the administrator.

The .profile file is the third file read at login time. It resides in a user's login directory and enables a user to customize their individual working environment. The .profile file overrides commands run and variables set and exported by the /etc/profile file.

Ensure that newly created variables do not conflict with standard variables such as MAIL, PS1, PS2 and so forth.

(48)

At startup time the shell checks to see if there is any new mail in /usr/spool/mail/$LOGNAME. If there is then MAILMSG is echoed back. In normal operation, the shell checks periodically.

The ENV="$HOME/.kshrc" variable will cause the file $HOME/.kshrc to be run every time a new Korn shell is explicitly started. This file will usually contain Korn shell specifics.

The .profile file is read only when the user logs in.

Be aware that your .profile file may not be read if you are accessing the system through CDE (the Common Desktop Environment). By default, CDE instead uses a file called .dtprofile. In the CDE environment, if you wish to use the .profile file, it is necessary to uncomment the DTSOURCEPROFILE variable assignment at the end of the .dtprofile file.

(49)

Module 5

Overview

The tilde (~) Expansion:

The C shell provides an easy way to abbreviate the pathname of your home directory. When the tilde symbol (~) appears at the beginning of a word in your command line, the shell replaces it with the full pathname of your login directory.

Example:

% mv file ~/newfile

Is the abbreviated way of typing this

% mv file $home/newfile The whence Command

The whence command can be used to determine exactly where the command you specify is located. For instance, it may be a command located on the disk drive, it may be an alias, or it may be built-in to the Korn shell. whence reports the proper location.

whence

$ whence ls <works with basic commands>

/bin/ls

$ whence dir <works with aliases>

/bin/ls -al | more

$ whence echo <works with built-in commands>

(50)

Aliases

Aliases in the Korn shell allow you to create your own commands. You can simply rename existing commands, or you can group commands together to create entirely new commands. This feature is also available in the C shell, but the command syntax is slightly different.

The ksh syntax for alias commands: alias name='value'

(51)

The ENV variable specifies a Korn shell script to be invoked every time a new shell is created. The shell script in this example is .kshrc (which is the standard name used), but any other filename can also be used.

The difference between .profile and .kshrc is that .kshrc is read each time a subshell is spawned, whereas .profile is read once at login.

You can also set the following variable in $HOME/.profile:

EDITOR=/usr/bin/vi export EDITOR

It will do the same thing that the set -o vi command does as shown in the example.

(52)

The Korn shell sets up a number of aliases by default. Notice that the history and r commands are in fact aliases of the fc command. Once this alias is established, typing an r will reexcute the previously entered command.

To carry down the value of an alias to subsequent subshells, the ENV variable has to be modified. The ENV variable is normally set to $HOME/.kshrc in the .profile file (although you can set ENV to any shell script). By adding the alias definition to the .kshrc file (by using one of the editors) and invoking the .profile file, the value of the alias will be carried down to all subshells, because the .kshrc file is run every time a Korn shell is explicitly invoked.

The file pointed to by the ENV variable should contain Korn shell specifics.

The unalias command will cancel the alias named. The names of the aliases specified with the unalias command will be removed from the alias list.

(53)

The /etc/environment file contains default variables set for each process. Only the system administrator can change this file. PATH is the sequence of directories that is searched when looking for a command whose path name is incomplete.

TZ is the time zone information.

LANG is the locale name currently in effect.

LOCPATH is the full path name of the location of National Language Support information, part of this being the National Language Support Table. NLSPATH is the full path name for messages.

(54)

Module 6

The vi Editor

It is important to know vi for the following reasons:

• It is th e only editor available in maintenance mode on RISC System/6000 • S ta n d a rd e d ito r a cro ss a llU N IX s yste m s

• C o m m a n d -line editing feature

• U se d a s d e fa u lt e d ito r fo r so m e p ro g ra m s

This unit covers only a subset of the vi functions. It is a very powerful editor. Refer to the online documentation for additional functions.

vi does its editing in a buffer. W hen a session is initiated, one of two things

happens:

• If th e file to b e e d ite d e xists, a co p y o f th e file is p u t in to a b u ffe r in /tmp by default.

• If the file does not exist, an empty buffer is opened for this session. Tildes represent empty lines in the editor.

(55)
(56)

References

Related documents

Before you can access subscription phone services on your phone, you need to subscribe to them by using your computer to access the User Options web pages. See the “Logging In to

Regardless of your operating system (Windows, Linux, or UNIX) or clus- ter configuration, you can collectively manage your entire system by using one management server, and

[r]

The current study will contribute to the field of international schooling, human resource management of schools, school recruitment, teachers‟ turnover and retention

If you have only one LDAP directory and all your user accounts are stored in one single subdirectory, you can re-use “Common LDAP Settings” for client LDAP configuration and

“Inheritance and mapping of resistance to anthracnose fruit rot in highbush blueberries for marker-assisted selection” Michigan State University GREEEN 2011. Investigator:

The project study was created to address a gap in the research on practice by exploring rural Title I charter school educators’ perspectives on benefits of, barriers to,

You can use your computer to log in to your Cisco Unified Communications Manager User Options web pages, where you can control features, settings, and services for your wireless