Sie sind auf Seite 1von 43

6.

2
DBA Training Manual

UNIX & vi EDITOR

www.infosysinbanking.co m

Document number: Authorized by:

VersionRev: R N NAGARAJ Signature/Date:

1.01

Document revision list


Ver.Rev Date Author Description

1.00 1.01

02-062001 16-082001

Sameer Shirgurkar Balaji. S

Original version reviewed & Updated

2001 Infosys Technologies Limited, Bangalore, India All rights reserved by Infosys Technologies Limited, Infosys Towers, No. 27, J. P. Nagar, 3rd Phase Bannerghatta Road, Bangalore 560 076 India.

No part of this volume may be reproduced or transmitted in any form or by any means electronic or mechanical including photocopying and recording or by any information storage or retrieval system except as may be expressly permitted. This Training manual has been written and produced by the BBU -USER EDUCATION TEAM of Infosys Technologies Limited.

Infosys believes that the information in this publication is accurate as of its publication date. This document could include typographical errors, omissions or technical inaccuracies. Infosys reserves the right to revise the document and to make changes without notice. Infosys acknowledges the proprietary rights in the trademarks and product names of other companies mentioned in this document.

Infosys Document

BBU UET

Finacle Training

TABLE OF CONTENTS

1. SNAPSHOT...............................................................................................................................................1 2. SECTION OBJECTIVE.........................................................................................................................1 3. OPERATING SYSTEMS AN INTRODUCTION..........................................................................1 1.1 WHAT IS AN OPERATING SYSTEM? ...............................................................................................................1 4. THE UNIX OPERATING SYSTEM ...................................................................................................2 5. THE STRUCTURE OF UNIX...............................................................................................................2 5.1. THE KERNEL.............................................................................................................................................2 5.2. SWAPPING.................................................................................................................................................3 5.3. THE SHELL...............................................................................................................................................4 5.4. THE FILE SYSTEM.....................................................................................................................................6 6. THE UNIX FILE TREE.........................................................................................................................7 7. WORKING WITH UNIX.......................................................................................................................8 7.1. LOGGING IN..............................................................................................................................................8 7.2. DIFFERENT PRIVILEGES FOR DIFFERENT USERS .........................................................................................10 7.3. USING COMMANDS .................................................................................................................................11 8. SOME IMPORTANT UNIX COMMANDS.....................................................................................15 9. THE VI EDITOR...................................................................................................................................28 10. FLASHBACK........................................................................................................................................38

UNIX Fundamentals

Ver. 1.01

-i-

Infosys Document

BBU UET

Finacle Training

1.

SNAPSHOT
FiNACLE application works on UNIX platforms and hence some knowledge of UNIX is essential for the administration and maintenance of the application and the database. This document discusses the fundamentals of the UNIX Operating System.

2.

SECTION OBJECTIVE
The objective is to teach the user basic UNIX commands and make him aware of the structure of the UNIX operating system. This awareness of the commands and structure of UNIX would help the user a great deal in carrying out functions as the Database Administrator.

3.

OPERATING SYSTEMS AN INTRODUCTION

1.1 WHAT IS AN OPERATING SYSTEM?


An operating system is an integral part of a computer system. The computer system can be viewed as being built from three general components: the hardware, the operating system, and the applications. The hardware includes pieces such as a central processing unit called a CPU, a keyboard, a hard drive, and a printer. Applications are why we use computers; they use the rest of the system to perform the desired task. The operating system is the component that, on one side, manages and controls the hardware and on the other, manages the applications. When a computer system is purchased, it must have at least hardware and an operating system. The hardware is able to use one or more different operating systems. The operating system is necessary in order to manage the hardware and the applications.

UNIX Fundamentals

Ver. 1.01

Page 1

Infosys Document

BBU UET

Finacle Training

4.

THE UNIX OPERATING SYSTEM


Having looked at an operating system in general, the UNIX operating system in particular, will be discussed. UNIX, like other operating systems, is a layer between the hardware and the applications that run on the computer. It has functions that manage the hardware and functions that manage executing applications.

5.

THE STRUCTURE OF UNIX


The UNIX Operating System can be divided into three parts structurally, namely,

A core unit called the kernel that interacts with the hardware for low level
functions

An outer unit called the shell that interacts with the user to perform functions
desired by the user

The File System


The idea of such a structure was to keep the units related but still separate so that the entire program did not park itself in the memory and slow down the system.

5.1. THE KERNEL


The core unit that manages the hardware and the executing processes is called the kernel. When the computer is switched on, the program UNIX is loaded into the computer's main memory, where it remains until the computer is shut down. This program, called the kernel, performs many low-level and system-level functions. The kernel is responsible for interpreting and sending basic instructions to the computer's processor. The kernel is also responsible for running and scheduling processes and for carrying out all input and output. The kernel is the heart of a UNIX system and there is one and only one kernel. To list, the tasks of the kernel include

CPU Scheduling Allocating the necessary hardware Controlling the I/O operations

UNIX Fundamentals

Ver. 1.01

Page 2

Infosys Document

BBU UET

Finacle Training

UNIX is a multi-tasking, multi-user operating system, which implies that several users can work on the system at the same time and each user can submit several jobs for execution at the same time. In order to effectively manage the several tasks that run simultaneously, the kernel has to allot a tag that would enable the identification of any task, uniquely. The simplest form of identification for the kernel is the use of an integer. For every job that is initiated, the kernel assigns an identification number called the process id. The kernel maintains a table called the Process Tab that describes every running process, enabling the identification of the details of the running process by means of the process id of the process, which is also stored in the table along with several other details. When a process is initiated, the kernel creates an entry in the process table and this entry is discarded from the table once the process is completed or its execution ceases. Each entry in the process table also indicates the priority of the process. This priority is a factor that determines the fashion or order in which the CPU allots time to the processes. Once a process gains the attention of the CPU, the process runs for an interval and then the CPU moves on to execute another process that deserves allocation. The interval is the period of time for which the process runs. This concept of giving each process a particular interval of time ensures that all processes get a chance to run and no process starves without the allocation of the CPU. The operating system handles the allocation and reallocation at a mind boggling speed that the users can hardly make out that the CPU is not allotted to them and they only have the feeling that the system is responding to all their requests simultaneously.

5.2. SWAPPING
The memory space is as valuable a resource as the CPU time is. Needless to say, a valuable resource as always has too many users and too little of it is available. The program that is processed and the data of the program use the memory space. With a number of users working on the system, at any point of time, the memory space available is less than what is required. If a process has to be executed, all parts of the process have to be in memory. If a process is running, the other processes need not be present in the memory. Hence, the kernel moves these processes that are waiting, to the secondary storage, thereby ensuring that the running process has the memory it requires. This method adopted by the kernel is called swapping and this happens at too high a speed for the user to be aware of its occurrence.

UNIX Fundamentals

Ver. 1.01

Page 3

Infosys Document

BBU UET

Finacle Training

5.3. THE SHELL


As the shell of a nut provides a protective covering for the kernel inside, a UNIX shell provides a protective outer covering. As you might suspect from the critical nature of the kernel's responsibilities, the instructions to the kernel are complex and highly technical. To protect the user from the complexity of the kernel, and to protect the kernel from the shortcomings of the user, a protective shell is built around the kernel. The user makes requests to a shell, which interprets them and passes them on to the kernel. Once the kernel is loaded to memory, it is ready to carry out user requests. First, though, a user must log in and make a request. For a user to log in, the kernel must know who the user is and how to communicate with him. To do this, the kernel invokes two special programs, getty and login. For every user portusually referred to as a ttythe kernel invokes the getty program. This process is called spawning. When getty receives any input, it calls the login program. The login program establishes the identity of the user and validates his right to log in. The login program checks the password file. If the user fails to enter a valid password, the port is returned to the control of a getty. If the user enters a valid password, login passes control by invoking the program name found in the user's entry in the password file. This program might be a word processor or a spreadsheet, but it usually is a more generic program called a shell. For instance if four users have logged in, two can use the Bourne shell, one, the Korn shell and one can be logged into a spreadsheet. Each user has a copy of the shell to service his requests, but there is only one kernel. Using a shell does not prevent a user from using a spreadsheet or another program, but those programs run under the active shell. A shell is a program dedicated to a single user, and it provides an interface between the user and the UNIX kernel. Because any program can be executed from the loginand a shell is simply a programit is possible for you to write your own shell. In fact, three shells, developed independently, have become a standard part of UNIX. They are

The Bourne shell developed by Stephen Bourne The Korn shell developed by David Korn

UNIX Fundamentals

Ver. 1.01

Page 4

Infosys

BBU UET

Finacle Training

Document The C shell developed by Bill Joy


This variety of shells enables you to select the interface that best suits your needs or the one with which you are most familiar.

BOURNE SHELL
It is the most widely used UNIX shell and is evidently, named after its developer Stephen Bourne. The Bourne shell prompts the user with a $ symbol. The Bourne shell, by itself, is a program by name sh.

KORN SHELL
The Korn shell has more features than the Bourne shell and is named after its developer David Korn. It is also called ksh.

C SHELL
The C shell has still additional features and was developed by Bill Joy. It is also called csh.

5.3.1.

THE FUNCTIONS OF A SHELL

It doesn't matter which of the standard shells are chosen, for all three have the same purpose: to provide a user interface to UNIX. To provide this interface, all three offer the same basic functions:

Command line interpretation Program initiation Input-output redirection Pipeline connection Substitution of filenames Maintenance of variables Environment control Shell programming
Discussing the functions of the shell in detail is beyond the scope of this material.

UNIX Fundamentals

Ver. 1.01

Page 5

Infosys Document

BBU UET

Finacle Training

5.4. THE FILE SYSTEM


One of UNIX's greatest strengths is the consistent way in which it treats files. Although some operating systems use different types of files that each require unique handling, you can handle most UNIX files the same. For instance, the cat command, which displays a disk file on your terminal screen, can also send the file to the printer. That is, in UNIX, all devices are addressed as files. As far as UNIX is concerned, the printer and your terminal look the same, and they look like any other UNIX file. UNIX also doesn't distinguish between files that you create and the standard files that come with the operating systemas far as UNIX is concerned, a file is a file is a file. This consistency makes it easy to work with files because you don't have to learn special commands for every new task. Often, the same command can be used for several purposes. This makes it easy to write UNIX programs because the user usually doesn't have to worry whether hes communicating to a terminal, a printer, or an ordinary file on a disk drive. Besides, this ensures the effective control of the access to any device, which according to UNIX, is just another file.

5.4.1.

THE TYPES OF UNIX FILES

There are four types of UNIX files namely,

Regular files Directories Special or Device files FIFO files REGULAR FILES
Regular files hold executable programs and data. Executable programs are the commands (such as cat) that you enter. Data is information that you store for later use. Such information can be virtually anything and there is no specific order of format enforced in the way the information is stored. These files can be visualised as the leaves in the UNIX tree.

UNIX Fundamentals

Ver. 1.01

Page 6

Infosys Document DIRECTORIES

BBU UET

Finacle Training

Directories are files that contain other files and subdirectories, just as a filing cabinet's drawers hold related folders. Directories help you organise your information by keeping closely related files in the same place so you can find them later. For instance, the user might save all spreadsheets in a single directory instead of mixing them with other unrelated files. The kernel alone can write the directory file. When a file is added to or deleted from this directory, the kernel makes an entry. A directory file can be thought of as the branch of the UNIX tree.

SPECIAL OR DEVICE FILES


These files represent the physical devices. Files can also refer to computer hardware such as terminals and printers. These device files can also refer to tape and disk drives, CD-ROM players, modems, network interfaces, scanners, and any other piece of computer hardware. When a process writes to a special file, the data is sent to the physical device associated with it. Special files are not literally files, but are pointers that point to the device drivers located in the kernel. The protection applicable to files is also applicable to physical devices.

FIFO FILES
FIFO files are those that let unrelated files communicate with each other. These files are typically used in applications where the communication path is only in one way and where a number of processes have to communicate with a single process, often called the daemon process. Each message writes a message to the FIFO file and the UNIX system ensures that the other users do not overwrite a message written in the file.

6.

THE UNIX FILE TREE


The designers of UNIX used directories to organise the UNIX file system into a structure that is shaped like an upside-down tree. Directories enable the user to keep related files in one place, where they can be seen only when wanted. The figure that follows shows a part of the file tree for a typical UNIX system. In this drawing, which looks somewhat like an upside-down tree, names like home and

UNIX Fundamentals

Ver. 1.01

Page 7

Infosys Document

BBU UET

Finacle Training

jane are followed by a slash (/), which indicates that they are directories, or files of files. Note that ordinary files, such as cowboys and prufrock, are not followed by a slash. Such files are called leaves because they aren't connected to anything else. The connecting lines are the paths through the UNIX file tree. You can move around the tree by following the paths.

The file tree for a typical UNIX system.

Unlike some operating systems, UNIX offers great flexibility in naming files and directories. The slash character cannot be used because it is the pathname separator and the name of the file tree's root directory. However, almost everything else is legal. Filenames can contain alphabetic (both upper- and lowercase), numeric, and punctuation characters, control characters, shell wild-card characters (such as *), and even spaces, tabs, and newlines.

7.

WORKING WITH UNIX


This section discusses the process of logging into the UNIX operating system and the prerequisites for the same.

7.1. LOGGING IN
The user needs to have a user name for logging into the Unix operating system and using it.

USER ACCOUNT SETUP


After a UNIX system is booted, the user cannot simply start using it like any PC. Before the user can access the computer system, someoneusually the system administratormust configure the computer for use.

UNIX Fundamentals

Ver. 1.01

Page 8

Infosys Document

BBU UET

Finacle Training

The user must know two things before he can start using the system: his user name and password. The user name is a unique name that identifies the user to the system. The system administrator, before creating a user name, will verify that no one else on the system has the same name before allowing the new user to have it. The password that has been assigned to the user is a temporary string that allows him to initially access the computer system. The initial password isn't of any real importance because the user should change it to something of his choice the first time he logs in to the system. Whenever a new user is created by the system administrator or the super user, the following details have to be entered in the /etc/passwd file:

User Name Users Password User_Id Group_Id User Description Home Directory

UNIX Fundamentals

Ver. 1.01

Page 9

Infosys Document
a /etc/passwd file

BBU UET

Finacle Training

LOGGING IN TO THE SYSTEM


Once the system administrator has done the necessary groundwork required for a new user, the new user can log in. The system will prompt (ask) the new user for his user name by printing

login:
The user should then enter his user name. Next, UNIX will prompt him for his password by printing

Password:
The user should enter his password. As the password is being typed, the user will not be able to see the characters he typed, for obvious security reasons so that no one else can get to know his password by looking at the screen when the user logs in. If the user types everything correctly and the system administrator has everything set up correctly, the user should be able to log in and use the system. On logging in successfully, the system puts the user on to his home directory, the directory allotted by the super user for the user to work in. If the system displays a message saying Login Incorrect, then the user may have typed his user name or password incorrectly and hence the system rightfully denies access for working.

7.2. DIFFERENT PRIVILEGES FOR DIFFERENT USERS


UNIX systems have built-in security features. Most users cannot set up a new user account nor do other administrative procedures. The user root is a special user, sometimes called a super-user, which can do anything at all on the system. This high degree of power is necessary to fully administer a UNIX system, but it also allows its user to make mistakes and cause system problems. For this reason, the user should set up a personal account for himself that does not have root privilege. Then, his normal, day-to-day activities will affect only his personal environment and the user will be in no danger of causing system-wide problems. In a multi-user, non-personal environment, the user is most likely to have only user, and not super-user privileges. This security is even more important when

UNIX Fundamentals

Ver. 1.01

Page 10

Infosys Document

BBU UET

Finacle Training

more than one person is involved because one mistake by the root can affect every user and the entire system. UNIX also has security to help prevent different users from harming each other on a multi-user system. Each user owns his or her environment and can selectively let groups or all others have access to this work. If the user is doing private work in one area that no one else should be allowed to see, then he should restrict access to the owner (himself). If the user and his team members are working on a group project, he can restrict access to the owner (himself) and everyone in his group. If this work should be shared with many or all people on the system, then he should allow access to everyone.

LOGGING OUT
When the user is done using the system, he should log out to prevent other people from accidentally or intentionally getting access to his files. The normal way to log out from almost any shell is to type exit. This causes the shell to exit, or stop running. When the user exits from his login shell, he logs out. Some shells, depending on the configuration, will also log the user out when he types the end-offile character, typically Control + D.

7.3. USING COMMANDS


Logging in UNIX performs several actions that prepare the user and the system for each other. These include performing system accounting, initialising the user environment, and starting a command interpreter commonly called a shell. Commands are how the user tells the system to do something. The command interpreter recognises these commands and passes the information off to where it is needed. UNIX systems originally came with a command interpreter called the Bourne Shell (usually referred to as sh). This shell is still available on most UNIX computer systems. A newer shell that is common to most UNIX systems is the C Shell (referred to as csh). Another commonly used, but not as pervasive, shell is the Korn Shell (referred to as ksh). Among different shells, there is some variation of the commands that are available.

WHAT IS A COMMAND?
A UNIX command is a series of characters that the user types. These characters consist of words that are separated by whitespace. Whitespace is the result of

UNIX Fundamentals

Ver. 1.01

Page 11

Infosys Document

BBU UET

Finacle Training

typing one or more Space or Tab keys. The first word is the name of the command. The rest of the words are called the command's arguments. The arguments give the command information that it might need, or specify varying behaviour of the command. To invoke a command, the user can simply type the command name, followed by arguments (if any). To indicate to the shell that he is done with typing and is ready for the command to be executed, he should press Enter. For instance, the date command takes no arguments and hence, if the user enters date at the prompt and press Enter, he should see that the computer has printed the current date and time. The echo command takes arguments. The echo command writes, or echoes, these arguments out to the screen. UNIX commands use a special type of argument called an option. An option commonly takes the form of a dash made by using the minus sign key, followed by one or more characters. The options provide information to the command.

REDIRECTING INPUT AND OUTPUT


One very pervasive concept in UNIX is the redirection of commands' input and output. Before looking at redirection, though, it is a good idea to look at input and output without modification. UNIX uses the word standard in this subject to mean the default or normal mode. Thus, UNIX has the term standard input, which means input coming from the default setting, and the term standard output, which means output going to the normal place. When the user first logs in to the system, and the shell executes, the standard input is set to be what is typed at the keyboard, and the standard output is set to be the display screen. UNIX shells have special characters that signify redirection. Output redirection is signified by the > character and input redirection is signified by the < character. Output is commonly redirected to and input is redirected from a file. The syntax for using output redirection with the cat command is cat > <filename> where <filename> is a name of the users choice. Pipes are one of the ways UNIX allows users to combine several commands. The pipe is signified by the vertical bar (|) symbol. A pipe is a means of taking the output of one command and redirecting it as the input of another command. Assume that the user wants to know how many files exist in his current directory. The ls command will list all the files in the current directory and the number of files can be counted. But UNIX has a command that counts the number of characters,

UNIX Fundamentals

Ver. 1.01

Page 12

Infosys Document

BBU UET

Finacle Training

words, and lines of input and displays these statistics. Therefore, these two commands to give the number of files in the directory. One way of doing it would be ls -l | wc -l. Combining the two commands via a pipe takes the output of the first command (the long directory listing) and gives it to the input of the second command.

MANAGING THE PASSWORD


During login, UNIX asks the user to enter his password. If he logs in for the first time, his password is what the system administrator configured. One of the very first things he should do after logging in is change his password so that, none, including the system administrator, knows what it is. This can be done via the passwd command. If the user forgets his password, even the system administrator, cannot look it up. There is no alternative except to reset the password to a value.

CONFIGURING YOUR ENVIRONMENT


In order to make using the shell easier and more flexible, UNIX uses the concept of an environment. Your environment is a set of values. You can change these values, add new values, or remove existing values. These values are called environment variablesenvironment because they describe or define your environment, and variables because they can change.

VIEWING AND SETTING ENVIRONMENT VARIABLES


Every user's environment looks a little different. Type the env command with no arguments. The output formatting and variable names depend on which shell you are using and how your system is configured. A typical environment might include some of the following:

$ env

PATH=/usr/bin::/users/tng/services/bin:/users/tng/services/tools:/users/tng/agen ts/bin AGENTWORKS_DIR=/users/tng LOGNAME=trg20 SHELL=/bin/ksh HOME=/users/training/trg20 TERM=vt220 PWD=/users/training/trg20

Some Finacle Related variables

UNIX Fundamentals

Ver. 1.01

Page 13

Infosys Document
$ echo $TBA_PROD_ROOT /wd2/V6200 $ echo $TBA_MRT /wd2/V6200/cust/mrt $ echo $TBA_SCRIPTS /wd2/V6200/cust/scripts $ echo $TBA_COPT_FILE defaultcopt01.rip $ echo $B2K_SECURE_ID UET

BBU UET

Finacle Training

Sometimes the number of variables in your environment grows quite large, so much so that you don't want to see all of the values displayed when you are interested in just one. If this is the case, you can use the echo command to show an environment variable's current value. To specify that a word you type should be treated differentlyas a value of an environment variableyou immediately precede the variable name with a dollar sign ($). Be careful not to type any whitespace between the $ and the word. One of the variables in the example is HOME. You probably have this variable in your environment, too. Try to display its value using echo. You can create a new environment variable by simply giving it a value. If you give an existing variable a value, the old value is overwritten. One difficulty in setting environment variables is that the way you set them depends on the shell you are using. In order for your screen to display the output correctly, the environment variable TERM needs to have a reasonable value. This variable name comes from the times when terminals were used as displays (before PCs and graphics displays were common). Different terminals supported varying output control. Therefore, UNIX systems have various terminal types that they support. These are not standard, so you need to find out which terminal type to use from your support personnel. If you are using a PC to connect to a UNIX system, your PC is running a terminal emulation tool. Most of these tools have the capability to emulate several types of terminal. The important point here is to make sure that your emulator and your TERM variable are the same (or compatible). Start by seeing what your TERM variable is set to by entering echo $TERM.

SHELL STARTUP FILES


Where do all these environment variables come from? Well, the system sets up various ones for the user. And each user commonly sets up others during the login

UNIX Fundamentals

Ver. 1.01

Page 14

Infosys Document

BBU UET

Finacle Training

process. Yes, you may be doing this without even knowing it. During the startup, which happens at login, a shell is started. This shell automatically looks in a special place or two for some startup information. One of these places is the users home directory. The startup information in the users home directory is found in special files. The specific shell the user is using will determine the name of the particular file. When the shell starts up, it examines this file and performs whatever actions are specified. One of the common actions is to give values to environment variables. This action is called initialising or setting the values. One environment variable that is commonly set in a user's shell start-up file is the PATH variable (or lowercase path for C-shell users). This variable's value is a list of places (directories) on the system where the shell should look to locate a command. Each command the user types is physically located as a file somewhere on the UNIX file system. It is possible for the same command name to be located in different places (and to have either the same or different behaviour when executed). Say that you have a program called my_program that is stored in your home directory, and your friend has a program called my_program, which is in her home directory. If you type my_program at the prompt, the shell needs to know where to look to find the storage location of my_program. The shell looks at the value of the PATH variable and uses the list of directories as an ordered directory search list. The first directory that has a my_program stops the search, and the shell executes that file. Because all files within a single directory must be unique, this gives a straightforward and sufficient method for finding executables (commands).

8.

SOME IMPORTANT UNIX COMMANDS

GENERAL COMMANDS
banner Description : This command prints the argument supplied, in large letters so as to appear like a banner. Example:

UNIX Fundamentals

Ver. 1.01

Page 15

Infosys Document
$banner # # # # # # ####### # # # # # # HELLO ####### # # ##### # # ####### # # # # # # ####### # # # # # # #######

BBU UET

Finacle Training

####### # # # # # # # # # # #######

cal Description : The command can print the calendar for any year in the range 1 to 9999. The command, when given no arguments, generally prints the calendar for the previous, current and following months. Example:
$cal August 2001 S M Tu W 1 5 6 7 8 12 13 14 15 19 20 21 22 26 27 28 29

Th 2 9 16 23 30

F S 3 4 10 11 17 18 24 25 31

$ cal 8 1947 August 1947 S M Tu W Th 3 4 5 6 7 10 11 12 13 14 17 18 19 20 21 24 25 26 27 28 31

F S 1 2 8 9 15 16 22 23 29 30

An unusual calendar is printed for September 1752. That is the month 11 days were
skipped to make up for lack of leap year adjustments. To see this calendar, type:
$ cal 9 1752

date Description : This command is used to display the current system date or set the system date.

Example:

UNIX Fundamentals

Ver. 1.01

Page 16

Infosys Document
$ date Thu Aug 16 17:54:32 GMT 2001 $ date +%a Thu $ date +%A Thursday $ date +%b Aug $ date +%B August date +%d 16 $ date +%D 08/16/01

BBU UET

Finacle Training

try the output for other formats like x, X, c, C . An interesting option is j

echo Description : Displays the text supplied as argument or the contents of the variable that is supplied as argument. Example:
$echo Welcome to world of UNIX Welcome to world of UNIX

what is the output of echo * ?


passwd Description pg Description : This command displays the contents of the files specified, pagewise. : This command is used to change the users password or to create a new password. The argument is used by the super user alone.

Example:

UNIX Fundamentals

Ver. 1.01

Page 17

Infosys Document

BBU UET

Finacle Training

$pg /etc/passwd root:x:0:1:Super-User:/:/sbin/sh daemon:x:1:1::/: bin:x:2:2::/usr/bin: sys:x:3:3::/: adm:x:4:4:Admin:/var/adm: lp:x:71:8:Line Printer Admin:/usr/spool/lp: smtp:x:0:0:Mail Daemon User:/: uucp:x:5:5:uucp Admin:/usr/lib/uucp: nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico listen:x:37:4:Network Admin:/usr/net/nls: nobody:x:60001:60001:Nobody:/: noaccess:x:60002:60002:No Access User:/: nobody4:x:65534:65534:SunOS 4.x Nobody:/: ora734:x:1001:101::/oracle/ora734/app/oracle/product/7.3.4:/bin/sh op:x:1002:101:Backup Operator:/users/op:/bin/sh ccd:x:0:1:ROOT eqv:/users/ccd:/bin/sh balu1:x:1003:10:Balaji Srirangarajan:/users/balu1:/bin/ksh balu2:x:1004:10:Balaji Srirangarajan:/users/balu2:/bin/ksh balu:x:0:10::/users/balu:/bin/ksh sandhya2:x:1007:10::/users/sandhya2:/bin/ksh sam1:x:1008:10::/users/sam1:/bin/ksh

pipe | Description Example:


$ls /etc | pg 1 acct/ aliases@ asppp.cf* auto_home auto_master autopush@ b2k/ ca/ catngcampath* chroot@ clri@ crash@ cron@ cron.d/ csh.login.bakup datemsk dcopy@ default/ device.tab devlink.tab dfs/ dgroup.tab group grpck@ gss/ halt@ hostname.hme0 hosts@ http/ inet/ inetd.conf@ init@ init.d/ initpipe| inittab install@ ioctl.syscon iu.ap killall@ krb5/ labelit@ lib/ link@ log@ logindevperm nodename nscd.conf nsswitch.conf nsswitch.files nsswitch.nis nsswitch.nisplus opasswd openwin/ opt/ oshadow pam.conf passwd path_to_inst path_to_inst.old printers.conf profile profile.preaw protocols@ prtconf@ prtvtoc@ publickey pwck@ rc0@ rpld.conf saf/ security/ services@ setmnt@ shadow shutdown@ skel/ ski/ snmp/ sock2path@ sulogin@ swap@ swapadd@ sysdef@ syslog.conf syslog.pid system system.safe tar@ telinit@ termcap@ TIMEZONE@

Channels the output of command1 as input for command2.

sleep Description Example:


$sleep 30

This command is used to delay a process for a period of time.

wc

UNIX Fundamentals

Ver. 1.01

Page 18

Infosys Document
Description Example:
$ wc /etc/passwd 99 125 4461 /etc/passwd

BBU UET
:

Finacle Training

This command does a count operation on the file given as argument based on the options given.

try the options l, -w & -c

who Description : This command lists all the users who are currently logged in, along with the time of login and the terminal details. Example:
$who root balu1 bancs kvs1 kvs2 kvs1 console pts/13 pts/18 pts/19 pts/21 pts/22 Jul Aug Aug Aug Aug Aug 15 16 16 16 16 16 09:30 09:43 10:05 11:17 11:18 18:35 (:0) (192.168.83.145) (192.168.83.145) (192.168.83.217) (192.168.83.217) (192.168.81.141)

ls Description Example:
$ls /users

This command lists the files if the argument is a directory. If the argument is a file, it lists the details about the file.

The above command does not give much information about the files
$ls l /users drwxrwxr-x 3 drwxrwxr-x 8 -r-------1 -rw-r--r-1 -r--r--r-1 -r--r--r-1 -r--r--r-1 -rw-r--r-1 -rw-r--r-1 -rw-r--r-1 root root root root root root root root root root bin sys sys sys sys sys sys sys sys other 512 512 2985 1742 4461 3498 3498 190 1501 700 Dec Dec Aug Dec Aug Dec Dec Dec May Dec 1 2000 openwin 5 2000 opt 11 10:40 oshadow 5 2000 pam.conf 8 17:46 passwd 12 2000 path_to_inst 12 2000 path_to_inst.old 1 2000 printers.conf 17 11:42 profile 14 2000 profile.preaw

The above command lists the details of the files -rw-r--r-1 root other 700 Dec 14 2000 profile.preaw Indicates the file permissions Indicates the number of links is the user ID of the file's owner is the group ID of the group is the size of the file in bytes is the time stampthe date and time when the file was last modified is the name of the file

UNIX Fundamentals

Ver. 1.01

Page 19

Infosys Document

BBU UET

Finacle Training

The first and second columns require a bit more explanation. The first column is a ten-character field that indicates the file's modeits type and its permissions. In the first line of the list, the file's mode is rw-r--r. The first character tells the file type, which is a hyphen (-) for regular files, and d for directories. In this example, the first two items are directories and rest ordinary files. The next nine characters of the entry are the file's permissionsthree sets of three characters that control which users may access a file and what they can do with it. The first set of three characters controls what the file's owner can do; the second set of three characters controls what others in the group can do; and the third set of three characters controls what all other users can do. Each set of three characters shows read (r), write (w), and execute (x) permission, in that order. A hyphen (-) means that the permission is denied. The second column of the long listing is the number of links to this file.

cd Description : This command enables the user to change his current working directory and puts him in the directory supplied as argument. If no argument is given, it takes him to his home directory. Example:
$ cd $ cd /users $ cd ../trg1

pwd Description : This command prints the path name of the current working directory. Example:
$ pwd

head Description : This command displays the first n lines of the files specified as arguments

Example:

UNIX Fundamentals

Ver. 1.01

Page 20

Infosys Document
$ head $ head /etc/services -20 /etc/services

BBU UET

Finacle Training

tail Description : This command displays a part of the file, generally the last part, beginning at a designated place. Example:
$ tail $ tail /etc/services -20 /etc/services

finger Description : This command lists the users who are logged on and details about their terminal, time of login and so on. Example:
$ finger balu1 Login name: balu1 In real life: Balaji Srirangarajan Directory: /users/balu1 Shell: /bin/ksh On since Aug 17 09:55:37 on pts/24 from 192.168.83.145 No unread mail No Plan.

man Description : This command displays the reference manual pages related to the command given as argument.

Example:

UNIX Fundamentals

Ver. 1.01

Page 21

Infosys Document
$ man vi Reformatting page. User Commands NAME Wait... done

BBU UET

Finacle Training

finger(1)

finger - display information about local and remote users ] ] ]

SYNOPSIS finger [ -bfhilmpqsw ] [ username...

finger [-l ] [ username@hostname1[@hostname2...@hostnamen] ... finger [-l ] [ @hostname1[@hostname2...@hostnamen] ...

DESCRIPTION By default, the finger command displays in multi-column format the following information about each logged-in user: o user name o user's full name o terminal name (prepended with a `*' (asterisk) if write-permission is denied)

FILE MANAGEMENT
cat Description Example:
$ cat /etc/services $ cat -n /etc/services

This command can concatenates files or displays their contents.

cmp Description : This command is used to compare the contents of the two file supplied as arguments. Example:
$ cmp file1 file2

comm Description : This command is used to select or reject lines common to two sorted files. It produces a three columnar output where the columns contain lines only in file1, lines only in file2 and lines in both files respectively. Example:
$ comm file1 file2

cp Description : This command is used to copy files from the given source to the

UNIX Fundamentals

Ver. 1.01

Page 22

Infosys Document

BBU UET
specified destination.

Finacle Training

Example:
$ cp file1 file2

mkdir Description Example:


$ mkdir dir1

This command is used to create a directory.

mv Description Example:
$ mv file1 file2

This command moves or renames files and directories.

rm Description Example:
$ rm file1

This command is used to remove files or directories.

rmdir Description : This command removes the directory specified as argument provided it is empty. Example:
$ rmdir dir1

cut Description : This command is used to cut out columns from a table or fields from each line of one or more files. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option), or the length can vary from line to line and be marked with a field delimiter character like Tab (-f option). If no files are specified, cut reads from the standard input. Example:
$ cut -c 1-10 /etc/services

ln Description : A link is a directory entry referring to a file; a single file (together with its size, all its protection information, and so on) may have several links to it. There are two kinds of link: hard links and symbolic links. By default ln makes hard links. A hard link to a file

UNIX Fundamentals

Ver. 1.01

Page 23

Infosys Document

BBU UET

Finacle Training

is indistinguishable from the original directory entry; any changes to a file are effective independent of the name used to reference the file. Hard links may not span filesystems and may not refer to directories. This command is used to make a link to a file or directory. A symbolic link contains the name of the file to which it is linked; this file does not need to exist prior to the symbolic link. Example:
$ ln file1 file2 $ ln s file1 file2 $ ln n file1 file2

FILE SECURITY
chgrp Description : This command is used to change the group id of the files specified to the group id specified as argument. Example:
$ chgrp file1 dba $ chgrp R dir1 dba

chgrp can be restricted in Solaris platform based on the parameter set rstchown = 1 in
the /etc/system file. chown Description : This command is used to change the owner id of the files specified as arguments to the owner id specified. Example:
$ chown file1 dba $ chown R dir1 dba

chmod Description : This command changes the access permissions of a file or directory. Example:
$ chmod 755 file1 $ chmod R 755 dir1 $ chmod u+x file1 $ chmod u+rwx file1 $ chmod o-rwx file1

UNIX Fundamentals

Ver. 1.01

Page 24

Infosys Document MAIL RELATED COMMANDS


mail Description :

BBU UET

Finacle Training

mail provides a flexible environment for sending and receiving messages electronically. For reading messages, mail provides commands to allow saving, deleting, and responding to messages. For sending messages, mail allows editing, reviewing, and other modification of the message as it is entered.

Example:
$ mail trg1

mesg Description : This command is used to permit or deny messages sent to a terminal. write Description : This command is to copy lines from your terminal to that of another user. When first called, it sends the message: Message from your-logname your-tty ... talk Description : The talk utility is a two-way, screen-oriented communication program. When first invoked, talk sends a message similar to: Message from TalkDaemon@ her_machine at time ... talk: connection requested by your_address talk: respond with: talk your_addressto the specified address. At this point, the recipient of by typing: talk your_address the message can reply

SEARCH RELATED COMMANDS


find Description : The find command is used to find files matching a certain set of selection criteria.

UNIX Fundamentals

Ver. 1.01

Page 25

Infosys Document
$ find . name file1 print $ find . name core exec rm {} \;

BBU UET

Finacle Training

grep Description : This command is used to locate a particular string. Wild card characters can also be used for string specifications. Example:
$ grep unix *.txt $ grep i unix *.txt

DISK TOOLS
df Description : The df command displays the amount of disk space occupied by mounted or unmounted file systems, directories, or mounted and how resources, the amount of used and available space, much of the file system's total capacity has been used. Example:

UNIX Fundamentals

Ver. 1.01

Page 26

Infosys Document
$ df / /usr /proc /dev/fd /var /oracle /opt /users /wd /database2 /wd2 /database1 /wd1 /tmp $ df -k Filesystem /dev/dsk/c0t0d0s0 /dev/dsk/c0t0d0s3 /proc fd /dev/dsk/c0t0d0s4 /dev/dsk/c0t0d0s6 /dev/dsk/c0t0d0s5 /dev/dsk/c0t0d0s7 /dev/dsk/c1t1d0s0 /dev/dsk/c1t1d0s1 /dev/dsk/c1t1d0s3 /dev/dsk/c1t2d0s0 /dev/dsk/c1t2d0s1 swap

BBU UET

Finacle Training

(/dev/dsk/c0t0d0s0 (/dev/dsk/c0t0d0s3 (/proc (fd (/dev/dsk/c0t0d0s4 (/dev/dsk/c0t0d0s6 (/dev/dsk/c0t0d0s5 (/dev/dsk/c0t0d0s7 (/dev/dsk/c1t1d0s0 (/dev/dsk/c1t1d0s1 (/dev/dsk/c1t1d0s3 (/dev/dsk/c1t2d0s0 (/dev/dsk/c1t2d0s1 (swap

): ): ): ): ): ): ): ): ): ): ): ): ): ):

967332 779990 0 0 1190894 2264162 553948 8689026 391628 1208750 2414238 2266602 1498746 2828544

blocks blocks blocks blocks blocks blocks blocks blocks blocks blocks blocks blocks blocks blocks

330533 224501 7862 0 366000 322103 356316 1014784 828668 754741 397829 1508165 417826 171037

files files files files files files files files files files files files files files

kbytes used avail capacity 640967 157301 425979 27% 1018191 628196 328904 66% 0 0 0 0% 0 0 0 0% 721335 125896 537733 19% 3099287 1967206 1070096 65% 721335 444361 219268 67% 8572345 4227844 4258778 50% 8261393 8065579 113201 99% 6196234 5591859 542413 92% 2940743 1733624 1148305 61% 12390920 11257619 1009392 92% 5022314 4272941 699150 86% 1417912 3640 1414272 1%

Mounted on / /usr /proc /dev/fd /var /oracle /opt /users /wd /database2 /wd2 /database1 /wd1 /tmp

du Description : summarize disk usage The du command reports the number of disk blocks used for each directory and subdirectory, and the files found there. It has an option to display the number of blocks of just the "top level" directory.

Example:

UNIX Fundamentals

Ver. 1.01

Page 27

Infosys Document
$ du 2 22 174 244 828 836 14 16 18 14 2 2 6 974 32738 274 2 396 28 16 132258 ./tmp ./web/images/_vti_cnf ./web/images ./web ./index/temp ./index ./.fm/users/balu1 ./.fm/users ./.fm ./.bin ./database/utidb ./database/utiarch ./database ./sql ./gary ./TMP ./.wastebasket ./scripts ./tape ./menu .

BBU UET

Finacle Training

9.

THE VI EDITOR
A combination of << and cat can be used to add lines to a file, and sed and file redirection can be used to modify the contents of a file. These tools are rough and awkward, and when it's time to either create new files or modify existing ones, a screen-oriented editor is needed. In UNIX, the screen editor of choice is called vi. vi is Visual Editor, in short. There are a number of editors that may be included with the UNIX system, including ed, ex, vi, and EMACS. The latter two use the entire screen, a big advantage, and both are powerful editors. The vi is a modal editor. A mode is like an environment. Different modes in vi interpret the same key differently. For example, if the user is in insert mode, pressing the A key adds an a to the text, whereas in command mode, pressing the A key enters a, a single key abbreviation for the append command. Pressing Esc always returns the user to the command mode and if the system is already in command mode, it beeps to remind the user of that fact. The second important characteristic of vi is that it's a screen-oriented program. It must know what kind of terminal, computer, or system that the user is using to work with UNIX. This probably won't be a problem because most systems are set up so that the default terminal type matches the terminal or communications program that the user is using.

UNIX Fundamentals

Ver. 1.01

Page 28

Infosys Document

BBU UET

Finacle Training

The vi command by itself starts the editor, ready for the user to create a new file. The vi command with a filename starts vi with the specified file, so that the user can modify that file immediately. There are primarily two types of editors available under UNIX namely, 1 2 The ed line editor comparable to EDLIN IN DOS. The vi editor, a full screen editor.

CAUTIONS ABOUT VI The vi editor is very user unfriendly and offers no help facility. The same keystrokes can have more than on meaning depending on current mode
and the key combinations are in no way mnemonic.

The editor is fanatically case-sensitive The vi command does not lock a file while editing it. So it is possible that more
than one user can edit it at the same time. The version of the file saved last is the one that is retained.

SALIENT FEATURES OF VI vi is omnipresent and is available in all UNIX systems. vi is fast. vi has got powerful UNDO features. vi has got a lot of support . THE BASICS OF VI
vi and ex commands are compatible with each other but ex is a line editor only. All editing in vi is done in a buffer on a copy of the original until it is saved. vi works in 3 different modes :

Command mode
When in this mode, all keys are interpreted as commands.

Insert mode
When in this mode, the keys are echoed in the edit buffer.

The ex Escape or The Esc colon (:) mode

UNIX Fundamentals

Ver. 1.01

Page 29

Infosys Document

BBU UET

Finacle Training

When in this mode, the keys are interpreted as commands and are echoed at the command line at the bottom of vi screen. The bottom most line in vi is the command line where all commands in Esc : mode and messages are displayed. There are no error massages in vi - only beeps indicate the errors. Control or special keys cannot be used and the arrow keys cannot be used for cursor movement on most terminals.

IMPORTANT KEYS AND COMMANDS


KEY The Esc key The Return or MEANING Returns vi to the command mode and cancels partially formed commands. Executes commands entered in ex Esc mode and starts a new line in Ins mode. In command mode, it simply takes the cursor to next line. Specifies a string to be searched for in the existing file the string appears in the status line following the forward slash / and is echoed at the beginning of the command line. Same as the forward slash key but the search is done backwards. To enter ex Esc mode - the command appears at the command line preceded by :. Appears at the beginning of every line in vi.

Enter key Forward Slash / Question Mark ? Colon : Tilde ~

INVOKING VI
COMMAND vi vi <filename> FUNCTION Starts an empty edit buffer. Edits the file <filename> or creates the file <filename> if it does not vi +3 <filename> vi + /bye exist. Opens the file <filename> and goes to the third line. Searches for the first occurrence of bye in the file <filename>.

<filename>

CURSOR MOVEMENTS - NAVIGATING IN A FILE


The arrow keys should not be used to move, in vi though some terms do support them.

k or (Up arrow)
Ver. 1.01 Page 30

UNIX Fundamentals

Infosys Document

BBU UET

Finacle Training

h or Bkspc

vi
j or + or Enter

l or spc bar

All vi commands involve the use of alphabetical keys, alone or in combination with Shift and Control Keys.

MORE CURSOR CONTROL IN VI


Commands marked with # can be invoked with a number preceding them indicating repeat count. COMMAND #w #W #e #E f[character] F[character] t[character] T[character] #b #B 0 or ^ #$ #G L FUNCTION Moves forward by a word Moves forward by a word till next space Goes to the last character in the word Same as #e but ignores punctuation Upto specified character in current line right Same as above but - left Same as f[c] but one character before Same as F[c] but one character before Go back by a word Same as #b ,

but

ignores

punctuation Goes to the beginning of a line Goes to the end of the line Go to the line number # of the file Go to the last line

SCREEN COMMANDS
COMMAND Ctrl-F Ctrl-B Ctrl U Ctrl-D Ctrl R or Ctrl L FUNCTION Scrolls a screen forward except last two lines Scrolls a screen backwards Scrolls forward by half a screen Scrolls backwards by half a screen Re-draw and clear messages

UNIX Fundamentals

Ver. 1.01

Page 31

Infosys Document
Ctrl-G

BBU UET
Status of edit

Finacle Training

DELETING DATA
COMMAND #dd #dw #dW #x #X d$ or D d0 FUNCTION Delete current line where cursor is present Delete words from the cursor position Same as #dw but includes punctuation Delete character at the cursor position Delete character before the cursor Delete current line from the cursor position to the end of the line Delete current line from the position up to start of line cursor

TEXT INSERTION
COMMAND I I O o a A FUNCTION Invokes insert mode and inserts before character Same as i but insertion at

beginning of line Opens a blank line above current line Opens a blank line below the current line Same as i but inserts after cursor Same as a but appends at end of line

JOINING
The J command causes the lines of text below the current line to get joined with the current line.

LINE NUMBERING
In ex Esc mode the command : set nu sets line numbers and : set nonu removes them. Block moves - Colon Commands Copy 2 nd line after 5 th Multiple lines copy $ for last line, 1,3 is range :2co5 :1,3co$

UNIX Fundamentals

Ver. 1.01

Page 32

Infosys Document
Move to line 6

BBU UET

Finacle Training
:6 3dd

Delete three consecutive lines now (#dd) Yet another way Symbol . + - Means Current line

where cursor is Line after current line Line current line before

Delete 3 lines after current line Delete 3 lines below current line including current line , denotes range Move line 1 to after line 3 Lines 1,2 and 3 after line 5

: .+3d :.,+3d

: 1mo3 : 1,3mo5

SAVING AND EXITING


COMMAND :q! :wq :x ZZ FUNCTION Quit and abandon

changes Save and quit Replace old copy with new and quit Save and Quit command mode) (from

REPLACING EXISTING TEXT


COMMAND r R s S cw FUNCTION Replace a single c at current cursor position Invoke insert mode and go on replacing till Esc Replace a single c with text - insert mode - continues till Esc - $ appears after c to be replaced Replace current line with new text - blanks entire current line - invokes insertion mode Replaces a word - $ at end of word - replacement continues after end of $ if word size greater than current word

UNIX Fundamentals

Ver. 1.01

Page 33

Infosys Document
C cc

BBU UET

Finacle Training

Same as cw but acts on rest of line from current cursor position Same as C but entire line

CUT AND PASTE


COMMAND #yy p P FUNCTION Yank (cut !) specified number of lines into yank buffer Paste from yank buffer below current line Same as p but above current line

9 LIVES !
vi offers undo of upto 9 line deletions (each deletion may be a group of lines ) apart from the usual undo u . This follows the LIFO (Last In First Out ) rule #p or #P - # is 1 to 9

USER DEFINED REGISTERS


vi offers 26 registers (buffers) named a to z to the user into which text may be yanked and put anywhere else in the file using the put commands. These assignments are active during the entire current session a5yy - yank 5 whole lines including current and place in user defined buffer a ap - put contents of a below current line

All line, word and character commands can be used while yanking

MARKING AND YANKING


Marking the current cursor positionmk - m for mark , k is block name (In command mode) k flips cursor to mark k from anywhere else in file

dk - deletes block from mark k upto current cursor position ayk - yanks into register a ap - puts contents of a

PATTERN SEARCHING
Basic commands are : /g search for pattern g forwards

UNIX Fundamentals

Ver. 1.01

Page 34

Infosys Document
?g n

BBU UET
search for pattern g backwards repeat the last / or ? command

Finacle Training

SUBSTITUTION
These are : (colon) commands. To replace string by string1 on the current line :s/string/string1/ :s/string/string1/g - replaces only first occurrence - replaces all occurrences

Substitution can occur on multiple lines if range is specified :1,9s/string/string1/g For substituting throughout the file :1,$s/string/string1/g OR :g/string/s//string1/g - note the double slash.

MACROS
vi macros are created using the abbr command :abbr uo UNIX operating system In insert mode press u o and press Spc bar or Enter - the macro string is inserted at current cursor position. :abbr -lists the macros defined

Macros can be unabbreviated or deleted :una uo - deletes macro uo

MAPPING KEYS TO COMMANDS


The map command maps a user defined key to a specific function. The cursor movement keys j,k,l,h may be mapped by default to their respective cursor movement keys. To map the key ctrl-X to the wq command :map ^X :wq^M

- note that ^M signifies <CR> , in Vi ^ is typed by typing Ctrl-v

UNIX Fundamentals

Ver. 1.01

Page 35

Infosys Document

BBU UET

Finacle Training

Note : All characters typed with ctrl is taken as upper-case


An unmap command is available to cancel assignments :unmap ^X Mapping in insert mode done using the map! command :map! ^x Sam fox - In insert mode Ctrl-x will insert Sam fox in the editor An insert mode map cannot be unmapped unlike abbr :map displays only keys mapped to command mode functions

RUNNING SHELL COMMANDS FROM WITHIN


1 2 :sh temporarily shells out to $ and ctrl-d returns the shell : !<command> <command> ! stands for run which will directly run

READING COMMAND OUTPUT FROM WITHIN


This is done using :r! :r! date - reads in output of date at current cursor position

:r! banner Hi there

EDITING MULTIPLE FILES SIMULTANEOUSLY


vi can take multiple file arguments $ vi file1 file2 ..... $ vi f* :args [file1] file2 file3 - The bracketed file taken for display/edit :n :args file1 [file2] file3 :rew :args - Switches to next file in list OR metacharacters -

UNIX Fundamentals

Ver. 1.01

Page 36

Infosys Document

BBU UET

Finacle Training

[file1] file2 file3 -i.e. rew rewinds to file1 :rew! :e file - discards changes and coercively rewinds - edits file outside chosen list but :args will not show this file in list

READ AND WRITE ACROSS FILES


Write first five lines of text from file1 to file2:1,5 w! file2 Read same text from file2 to file1:1,5 r file2

THE SET OPTIONS


The set option helps customise the vi environment : set all - displays all set options available

The more common options are: SET COMMAND :set number,nu :set showmode :set autowrite,aw :set autoindent,ai :set beautify,bf :set directory,dir :set :set :set :set :set :set :set :set :set :set :set errorbells,eb ignorecase,ic magic mesg redraw scroll shell term terse warn window DEFAULT nonumber noshowmode noaw noai nobeautify dir-/tmp noeb noic magic nomesg noredraw scroll=half window sh=/bin/sh value of TERM noterse warn window speed ws wm=0 nowa DESCRIPTION Line numbers Display vi mode Save on n, rew, ! Indent as first line Control characters omitted Sets temporary

directory No error beep Uppercase as lowercase Allow all metacharacters Inhibit Write messages Act as intelligent terminal No. of lines to scroll Set which shell Set which terminal Error messages terse Warn save on Shell Esc No of lines in text window Wrap pattern on find Blank screen margin right Allow writes freely

dependent :set wrapscan,ws :set warpmargin,wm :set writeany, wa

UNIX Fundamentals

Ver. 1.01

Page 37

Infosys Document
The .exrc file

BBU UET

Finacle Training

vi reads .exrc before loading and all options like map,abbr and set can be entered here so that they are permanent for that vi session $ vi .exrc set nu set showmode abbr uo UNIX operating system map ^k :r! date^M :wq

10. FLASHBACK
This document discussed in brief, the fundamentals of the UNIX operating system. Some basic UNIX commands were also discussed apart from the vi Editor.

UNIX Fundamentals

Ver. 1.01

Page 38

Infosys Document

BBU UET

Finacle Training

QUIZ
TOPIC: UNIX AND vi EDITOR Srl.No. 1. 2. 3. 4. 5. 6. 7. Question
Operating system is an interface between user and computer Unix is a multiuser and non multitasking operating system Operating system takes care of housekeeping activities The unit which interacts with user is called KERNEL Shell is a core unit in unix system Unix treats all the devices as files Read the following and answer the questions a,b and c -rw-r--r-- 1 sam1 staff 540 Aug 22 15:10 test (a) test is a directory file (b) sam1 is the owner of the file test (c) owner of the file test has execute permissions ls is a list command vi is one of the editors in unix console is a monitor connected to server Whenever a new user is created in unix his/her details are entered in /etc/passwd file System administrator can see users password One general user can change another users password Users can change their passwords All the unix commands work on all platforms

True

False

8. 9. 10. 11. 12. 13. 14. 15.

QUIZ

Page 1

Infosys Document

BBU UET

Finacle Training

EXERCISES TOPIC :
Sl.No What is meant by multitasking? 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. What is the output of ls command? How to create a directory? What does rm <filename> do? How to remove a directory? What is the command used for copy? How to change the ownership? How to find out the users logged in? Which command is used for pattern matching? What is the prompt you get when you login as superuser(root)? How do you use mount command? What does tar command do? How do you find out the space occupied in the file systems? How do you find out the space available in all file systems? What are the roles of system administrator?

UNIX FUNDAMENTALS
QUESTION

EXERCISES

Page 1

Das könnte Ihnen auch gefallen