The UNIX Operating System:
UNIX is a popular operating system, developed by AT&T in 1969 and it has been very important to the development of the Internet. It is a multi-processing, multi-user, family of operating systems that run on a variety of architectures. UNIX allows more than one user to access a computer system at the same time.
The UNIX system is mainly composed of three different parts:
1 The Kernel
2 The File System and
3 The Shell.
The kernel is that part of the system which manages the resources of whatever computer system it lives on, to keep track of the disks, tapes, printers, terminals, communication lines and any other devices.
The file system is the organizing structure for data. The file system is perhaps the most important part of the UNIX operating system. The file system goes beyond being a simple repository for data, and provides the means of organizing the layout of the data storage in complex ways.
The shell is the command interpreter. Although the shell is just a utility program, and is not properly a part of the system, it is the part that the user sees. The shell listens to your terminal and translates your requests into actions on the part of the kernel and the many utility programs.
One can imagine the UNIX system as a series of three concentric circles, with the inner circle representing the kernel, the second circle representing the programming shell, and the last one representing application programs.
The Connection between Unix and C:
At the time the first Unix was written, most operating systems developers believed that an operating system must be written in an assembly language so that it could function effectively and gain access to the hardware. Not only was Unix innovative as an operating system, it was ground-breaking in that it was written in a language (C) that was not an assembly language. The C language itself operates at a level that is just high enough to be portable to variety of computer hardware. A great deal of publicly available Unix software is distributed as C programs that must be complied before use. Many Unix programs follow C's syntax. Unix system calls are regarded as C functions. What this means for Unix system administrators is that an understanding of C can make Unix easier to understand.
Why Use Unix?
One of the biggest reasons for using Unix is networking capability. With other operating systems, additional software must be purchased for networking. With Unix, networking capability is simply part of the operating system. Unix is ideal for such things as world wide e-mail and connecting to the Internet.
Unix was founded on what could be called a "small is good" philosophy. The idea is that each program is designed to do one job well. Because Unix was developed different people with different needs it has grown to an operating system that is both flexible and easy to adapt for specific needs.
Unix was written in a machine independent language. So Unix and unix-like operating systems can run on a variety of hardware. These systems are available from many different sources, some of them at no cost. Because of this diversity and the ability to utilize the same "user-interface" on many different systems, Unix is said to be an open system.
Basic Characteristics of Unix:
Unix is, at its base level, a multi-user, multitasking, virtual memory operating system that runs on a wide variety of hardware platforms. This means that Unix is able to do many things at the same time, for many different users, and using more memory than it really has physically installed. From a user's perspective this is very nice, and from an operating systems point of view, it is very interesting. But UNIX really is much more than just an operating system; it is a philosophy of using and programming a computer that gets its power from the relationships between programs rather than the programs themselves. This is evident from many of the design points of UNIX, which will be
mentioned later.
Let's look at each of the three characteristics of Unix listed above.
a) Unix is a multi-user system. This means that inherent to Unix is the idea that there are different users of the system, and that different users may have different sorts of privileges and types of access to different parts of the system. It allows for the idea that some users may want to protect some of their data from being accessed by other users on the system. So, in being a multi-user system, the basic ideas of system security and data privacy come up. Likewise, there must be some way to identify one user from another in a multi-user system. Unix uses a system of login names to identify users and passwords to authenticate that a user is, in fact, who she claims to be.
b) Unix is a multitasking system. This means that Unix has the ability to handle
more than one task at a time. These tasks might be several programs that any particular user wants to run, or they may be programs run by several users at once. Multitasking, combined with being a multi-user system, makes it possible for more than one person to be logged in and using a Unix system at once. This is true for any Unix system, not just large timesharing systems. Even small, desktop systems have the capability to support multiple concurrent users. Additionally, some of the tasks that the system could be doing, and probably is doing, can be system tasks related to keeping the system going and providing the services needed by the users.
c) Unix is a virtual memory operating system. The concept of virtual memory and
memory management is a bit beyond the scope of this seminar, but a few key concepts are important to note. In a virtual memory system, the system behaves as if it has much more memory than is physically installed. Some portion of the disk is used to simulate extra memory. This idea makes it possible to run large programs on a smaller system. Some tradeoff exists between the amount of memory that a program uses and how fast it will run, since if it is very large, it must access the disk a lot, but it will eventually run. In a multitasking environment, tasks that are not currently running can be moved out of memory and onto disk to free up memory for tasks that more urgently need it. The overall result is better use of the system resources for all involved.
The Unix operating system :
Unix is a time sharing operating system (OS), which consist of kernel, filesystem, shell and a collection of tools and
utilities.
The characteristic features of the Unix OS:
1. Written in C - easy understanding and portability of code i.e., can run on micros to mainframes
2. Interactive - has a consistently good user interface
3. Based on the philosophy of primitives to build complex programs
4. Easy to implement and maintain - hierarchical file system incorporating de-mountable volumes -
5. Easy application development - consistent format for byte streams/files
6. Simple and consistent interface to peripheral devices (treated as files ) - compatible file, device and interprocess I/O
7. Supports multi-user and multi-processor modes
8. Easier to write portable programs - hides machine architecture from the user -
9. Support any language that has an interpreter or compiler
10. Can initiate asynchronous processes
In general, like any OS, Unix provides the following two classes of services:
1. User services - shell, mail, text-processing, source code control system (SCCS)etc.
2. System calls - Operating system services for application development
Unix system architecture
Unix follows a layered approach that facilitates easy interaction between the different modules of the OS
Layer 1: This layer is the hardware over which the OS layers are built. This layer is not a part of Unix OS
Layer 2: This layer is the kernel part of OS which interacts directly with the hardware providing common services to programs and insulating them from hardware idiosyncrasy. It is a program that monitor and controls the resources of a computer and allocates them among its users in an optimal manner.
Layer 3: This layer contains programs that interact with the kernel by invoking a well-defined set of system calls. Typically, these programs are Unix commands like ex, wc, grep etc., and may include certain user-developed programs also.
Layer 4: This layer contains other application programs that have built on the lower levels like SCCS.
Basic Unix Commands
BASIC COMMANDS:
Date Command :
Displays the current day’s date and time
Syntax: date [option]
Output: Tue Jan 22 12:05:31 IST 2005
Who command :
Who command displays all list of users who have logged on
the systems.
Syntax: who [option]
Output: m04ee01 pts/48 Feb 22 11:16 <192.168.2.21>
m04ee02 pts/48 Feb 22 11:16 <192.168.2.21>
Who am I :
It shows the details of the user who have logged on the particular
machine
Syntax : whoami
Output : m04ee02 pts/48 Feb 22 11:16 <192.168.2.21>
echo command :
The command is used to display the output on the screen
Syntax : echo [option] string
Example: echo Unix Programming
Output : Unix Programming
Cal Command :
The command displays the calender details
Syntax: cal [month] [year]
Output: cal 2 2005
February 2005
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28
To Create a File:
Syntax: $ cat [option] >
Ex: $ cat > file1
Hello..
This is my first File
Have a Nice Day
Bye
Ctrl+d (Save)
To View an already existing File:
Syntax: $ cat
Ex: $ cat file1
To append data to an existing file:
Syntax: $ cat >>
Ex: $ cat >> file1
To Create a Multiple file with help of cat command:
Syntax: $ cat
Ex: $ cat >f1 >f2 >f3 >f4
Hello....
This is file number f4
We create multiple files
Ex: $ cat file1 file2>file3
File1 and file2 are concaténated in file3
Display the record number to the particular file:
Syntax: $ cat [option]
Ex: $ cat -n file1
To ignore the blank Records:
Syntax: $ cat [option]
Ex: $ cat -b file1
Create a Hidden file:
Syntax: $ cat [option]
Ex: $ cat >.file1
Create a Directory:
Syntax: $ mkdir [option]
Ex: $mkdir raju
To Display present working Directory:
Syntax: $ pwd
Ex: $ pwd
/home/m08cs272
To Change the Directory
Syntax: $ cd
Ex: $ cd raju
To Move parent Directory (root):
Syntax: $ cd /
Ex: $ cd /
To Create a Hidden Directory
Syntax: $ mkdir [option]
Ex: $ mkdir .venkat
To Remove a file:
Syntax: $ rm [option]
Ex: $ rm kiran
To Remove Multiple Files:
Syntax: $ rm [option]
Ex: $ rm f1 f2 f3 f4
To Remove Directory:
Syntax: $ rmdir [option]
Ex: $ rmdir sagar
To Remove all file:
Syntax: $ rm *
Ex: $ rm *
List Commends:
$ ls : It is a command to list the files and directories in
the present working Directory
$ ls - a : It is a command to display all files and
Directories including hidden files and Directories
$ ls * : List information about the Files (the current
directory by default). Sort entries alphabetically
$ ls -s : It Displays the sizes in blocks (Files &
Directories)
$ ls -l : It Displays the long listing files and
directories in present working directory
$ ls -m : It Displays all files and Directories with
separated by comma (,)
$ ls -ls : It Displays all long listing Directories
$ ls --full-time : It Displays files and Directories
with total information date and time
$ ls -nl : It Displays the long listing files and
Directories according to modification Time
$ ls -rtl : It Displays the file and Directories
with reverse order
$ ls -r : It Displays the all files and Directories
Regressively (order by order)
$ ls -l : It Displays the files and Directories in a
single column (vertical)
$ ls -x : It Displays the files and Directories with
multiple columns
Copy Commends :
1. File to a File
2. File to a Dictionary
3. Directory to Directory
1.File to File
Syntax : $cp