Introduction
In this article you can read and understand about UNIX.Every IT or CSE Student know that a typical operating system manages the resources of our computer system effectively and efficiently. It receives commands from the keyboard/mouse and displays the result of commands on VDU/Printer.
History of UNIX
Unix operating system was developed by Ken Thompson at AT&T's Bell Laboratories of USA in late 1960's. Initially Unix was developed focusing on a single user system. Above all it was initially written in the machine language of the specific system. Later on when Ken Thompson was joined by Dennis Ritchie, they rewrote Unix completely in C in 1973.Unix was the first operating system that was written in any high level language. And after some time Unix was made for multi user environment.
Finally Unix is a multi user multitasking time sharing operating system which can run on a wide variety of personal computers, mini computers and main frame. After all Unix is portable because it is written in C.
Unix has evolved as a kind of large freeware product, with many extensions and new ideas provided in a variety of versions of Unix by different universities, companies and individually. There are many versions of Unix. The most popular being AT&T's Bell laboratories Unix, University of California, Berkeley’s, SCO's Unix, Microsoft XENIX. Actually Unix was not a proprietary operating system owned by any one of the leading computer companies, like DOS.
That's why standardization was an issue which was largely resolved when Unix system 5th of AT&T was declared as a standard and further version needed to be compatible. A composite of the C language and shell interfaces from different version of Unix were standardized under ANSI and IEEE standard as the portable operating system interfaces (POSIX). Due to the efforts of a number of bodies, unified Unix standards were announced in 1993 and there is also a more recent Unix 1998 standard.
Due to later development by new technology, such an Internet, the Unix environment and the Client/Server program model plays an important role.
Characteristics of Unix Operating System
Unix provides a number of features to its users. In this section you will see some important ones.
Portable – Unix system can be used on a variety of machines because it is written almost entirely in C language. Only a small portion depends on the actual hardware of the underline machine. Therefore only a small part of Unix needs to be changed while installing it on a new user’s system. Thus the portability to a wide range of computers makes it possible to move application from one system to another.
Multi-user – Unix is a multiuser operating system, which can be run on a wide variety of platforms. In multi-user system the resource of the computer are acceptable to many users.
Hierarchical File System – Unix provides a hierarchical file system so that a user can organize his/her file in a structured way. In hierarchical file system user can even share files.
Command Interpreter – Unix interprets various commands typed by the user and executes them. Additionally it provides shell script to store a sequence of shell commands in a file a later execute that file. It also acts as programming language that allows shell scripts to be programmed for complex functions.
I/O Redirection and Piping – The Unix operating system is particularly well known for its strong redirection and piping facility. By I/O Redirection, a user can alter the flow of information from terminal to file or vice -versa. And piping provides the facility of offering the output of one command as the input to another.
Security – Unix provides security to restrict unauthorized users to the information in three different ways - personal security, file security and file encryption.
Tools and Utilities - Unix provides a large number of useful tools and utilities programs that are already written by different people that can be used to perform an amazing variety of jobs. Some of these tools are simple commands, while others are really small programming languages that you can use to build scripts to solve your own problems.
Multitasking – Unix also provides the facility of executing more than one task, called a process, at a time. It means that a single user can run second command in background while executing another commands in foreground. For instance, you can run a program that checks the spelling of words in a text file while you are simultaneously reading your electronic mail.
Networking Environment – The Unix system provides an excellent environment for networking as it offers programs and utilities that provide sufficient services needed to build networked applications.
Unix System Architecture
The Unix operating system has following major components – the kernel, the shell, the file system, and the commands or usr programs. Figure 1 shows the relationship among the user, the shell, the kernel and the underlying hardware.
The Shell – The shell is a command interpreter that reads your commands and interprets them as requests to execute a program or programs, which it then arranges to have carried out. Another plus point of using the shell is that it also acts as a programming language. It means that a shell permits you to control how and when commands are carried out.
There are actually several different shell programs, but they all provide the same basic capabilities. In this article you will study the Bourne shell (sh), the original Unix system shell written by Steven Bourne. Other common shells are C shell (csh) and Korn shell (ksh). To find out which shell your system gives you, check the documentation or the system manual page for sh.
The Kernel – The Kernel is a master program that interacts with the hardware of a computer through device drivers that are built into the kernel. It is also the major duty of the kernel to manage computer memory, to control access to the computer, to maintain the file system, to handle interrupts, to handle errors, to perform input and output services, and to allocate the resources of the computer system among users.
Programs interact with the kernel through various system calls. These system calls tell the kernel to carry out various tasks for the program, such as opening a file, reading from a file, writing to a file, executing a program, and so on.
Application and Utility Programs – User can use applications built by using the commands, tools and programs in order to carry out many different types of tasks. Some performs general applications, such as word processors, spreadsheets, DBMS, compilers, etc., that can be used by users of government, industry and education. Others are industry specific, such as management of hostel, bank application, etc.
As far as networking environment is concerned, it provides a wide range of services available on Internet, such as Web browsers for World Wide Web (WWW), such as Netscape Navigator, as well as Web server applications. It also provides the applications that deal with multimedia.
The Unix system also contains several hundreds utilities or user programs. You can execute these utilities by invoking them by name through the shell. Commands are also called as tools because they can be used separately or put together in various ways to carry out useful tasks.
Getting Started With Unix
In Unix every user is given a special "user-name" to use the system. However if several users work on related things then they can be grouped together on the system, and the group can be allocated a group name or group identity. There is one main user, called superuser who has administrative duties of assigning new user names, and generally looking after the system. The super-user can also have the name "root" as the user name.
When you start up your computer system, it goes through a process usually known as "logging in " or sometimes "logging on'. So the very first line that you see on your system is
login:
So you simply type your user name, and then press the return key on the keyboard of your terminal. When you type your username it would be displayed on your terminal screen, such as
login: shrey
Unlike other operating system such as DOS, Unix distinguishes between uppercase and lowercase letters. Thus if you type "Shrey" instead of the correct login name "shrey", the system treats it as a different name like username. Each user is given a password that allows him to use the system. Your password may be related either by you or by system administrator. This password is supposed to be known to you only, and is generally kept secret from others. Thus after entering your log in name, the Unix system prompts you to enter the password as:
login: shreyPassword:
Since the password is private to yourself, therefore it is not echoed as you type in, so nothing appears on the screen .If you don't have a password, the system would not ask for it, simply press the return key in that case. If you type your login and password correctly, the Unix system displays the command prompt $, which indicates that, it is waiting for further instructions from you as:
Login: shreyThe default system prompt (for most Unix system) is the dollar sign ($). This dollar sign ($) is the indication that the Unix system is waiting for you to enter a command. One should remember that the Unix system will not log you in if you do not type the login name or password correctly .So it refuses any usage of the system to you by displaying the message:Password:
$
login incorrect
and will displays login again as:
login:
Here one should remember that the Unix system does not inform which one is typed wrong either the login name or the password. It will still display the password prompt when you do not type your log in name correct. So you must type login name and password correctly to gain access to the system. Unfortunately if you are not still getting "$" prompt then there is some problem in your system.
Some Simple Unix Commands
You have already studied that there are several programs that are available to the user. To run one of these programs you type a command. When you type a command and press Enter key, the Unix command interpreter executes that program and displays the result on the screen.
You should apply a standardized command syntax while using any command. The command prompt ‘$’
after any Unix command has following three parts:
Command name - it tells the shell what to do
Options - they control how the command will work
Argument - it identifies the object the command will work on.
Command may have more than one option. The command is submitted to the shell by pressing the Enter key. One main point to note is that Unix commands are case sensitive. It means that del, Del and DEL are treats as three different things. Thus while using Unix commands one should be very careful.
Now let us read some simple Unix commands.
date Command – The date command is used to display today's date and the correct time. The date command is used as:
$ dateTue Oct 12 07:10:17 IST 1999
$
Remind that the exact format of the date and time can very from one system to another.
who Command – The who command is used to display the login names of the user usually logged in. The who command is used as:
$whouser1 tty2a Jan 15 07 : 20
user4 tty2d Jan 15 07 : 31
user2 tty2b Jan 15 08 : 12
amit tty4 Jan 15 10 : 11
user6 tty8 Jan 15 11 : 42
$
The first column is the user’s logname, second is terminal ID number and remaining columns tells when the user logged in. Another command work trying out would be who am i as:
$ who am iuser2 tty2b Jan 15 08 : 12
$
When you type this command on your terminal, this command displays information about you, your terminal ID number and your logged in time. You can execute several commands by typing them in the same line by typing a semicolon (;) between them as:
$ date ; whoTue Oct 12 07:10:17 IST 1999
user1 tty2a Jan 15 07 : 20
user4 tty2d Jan 15 07 : 31
user2 tty2b Jan 15 08 : 12
amit tty4 Jan 15 10 : 11
user6 tty8 Jan 15 11 : 42
$
There can be space on either side of the semicolon. The system responds you with its prompt, $, after completion of all the commands on the line. An opposite of the facility is also provided by Unix. It provides a backslash (\) if your command is too long and may not fit in a single line. The backslash is typed before the end of the line.
$ who \am \
i
user2 tty2b Jan 15 08 : 12
$
There can be any number of blank spaces before the backslash character but the enter key should immediately be pressed after the backslash.
echo Command – The echo command echoes whatever you type after it .The echo command is used as:
$ echo Honesty is the best policyHonesty is the best policy
$
Here you should remember that every time the system has finished executing the command and is waiting for you to enter something at command prompt ($).