Features of Unix Shell?: Link

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

Link : http://wiki.answers.

com/Q/Features_of_unix_shell

Features of unix shell?


In: College Degrees [Recategorize] [Edit]

[Edit]

Unix has two main sets internal implementation and the interface that is seen and used by users. i.e. Kernal and Shell. Kernal takes care of hardware interface and shell communicates with Kernal.

Shell works as interpreter of user commands and translates them into action. The shell forms the outer part of the operating system and forms the interface between the user and the kernel. For each user logged in, there is shell in action. When a command is given by the user, it is examined by the shell and communicated to the kernel for execution. The functions used to communicate with the kernel are called system calls and are built into the kernel. The system calls are in all the flavors of UNIX are the same. Hence, software developed on one UNIX system can be easily run on another UNIX system. shell also has some internal commands, e.g. CD. External commands are saved in file system, when you enter such commands shell searches for them and runs them in new sub-process. application developed on unix communicates with shell and not kernal, this engables single application to be executed on various types of computer hardware without being modified
Dell PowerEdge Servers High Performance T 105 Servers at Rs 21,900. AMD Dual-Core Processor www.dell.com/servers Backup& Recovery Solution EMC Avamar- Data deduplication,Fast & Secure Backup. Know more www.Emcindia.co.in/superbusiness Unix Systems for Sale Save up to 99% off orig list price! The 'net runs on Unix. And you? UnixHQ.com

Link : http://www1.cs.columbia.edu/~sauce/tutorial/features.html

Main Features of UNIX


multi-user more than one user can use the machine at a time supported via terminals (serial or network connection) multi-tasking more than one program can be run at a time hierarchical directory structure to support the organisation and maintenance of files portability only the kernel ( <10%) written in assembler tools for program development a wide range of support tools (debuggers, compilers)

The UNIX Operating System Consists of

kernel schedules tasks manages data/file access and storage enforces security mechanisms performs all hardware access shell presents each user with a prompt interprets commands types by a user executes user commands supports a custom environment for each user utilities file management (rm, cat, ls, rmdir, mkdir) user management (passwd, chmod, chgrp) process management (kill, ps) printing (lpr)

Multi-User Operating Systems A multi-user operating system allows more than one user to share the same computer system at the same time. It does this by time-slicing the computer processor at regular intervals between the various users.

In the above example, there are five users which share the processor hardware and main memory on a time basis. We start off by giving the first user (which we will call Sophia) the processor hardware, and run Sophia's program for 1/5th of a second. When the time is up, we intervene, save Sophia's program state (program code and data) and then start running the second users program (for 1/5th of a second). This process continues till we eventually get back to user Sophia. To continue running Sophia's program, we restore the programs code and data and then run for 1/5th of a second. This switching between user programs is done by part of the kernel. To switch from one program to another requires,

a regular timed interrupt event (provided by a clock) saving the interrupted programs state and data restoring the next programs state and data running that program till the next timed interrupt occurs

Main system memory is divided into portions for the operating system and user programs.

As you can see in the above diagram, the kernel space is kept separate from user programs. In UNIX systems, each user is presented with a shell. This is a program which displays the users prompt, handles user input and displays output on the terminal. The shell program provides a mechanism for customizing each user's setup requirements, and storing this information for reuse (in a file called .profile). When the UNIX system starts up, it also starts a system process which monitors the state of each terminal input line. Whenever a user logs in and their password is validated the UNIX system associates the shell program with that terminal.

Multi-Tasking OperatingSystems Multi-tasking operating systems permit the use of more than one program to run at once. It does this in the same way as a multi-user system, by rapidly switching the processor between the various programs. OS/2 and Windows 95 are examples of multi-tasking single-user operating system. UNIX is an example of a multi-tasking multi-user operating system. A multi-user system is also a multi-tasking system. This means that a user can run more than one program at once, using key selection to switch between them. Multi-tasking systems support foreground and background tasks. A foreground task is one that the user interacts directly with using the keyboard and screen. A background task is one that runs in the background (it does not have access to the keyboard). Background tasks are usually used for printing or backups. The role of the operating system is to keep track of all the programs, allocating resources like disks, memory and printer queues as required.

Link : http://www.serc.iisc.ernet.in/user/UserEdu98/aspe/tsld003.htm

Salient features of Unix.

Multi-user - Support more than one user session, simultaneously, on the same system, at a time. Multiprogramming - Support more than one program, in memory, at a time. Amounts to multiple user processes on the system. Multitasking - A single process can initiate multiple threads of execution. Exploiting concurrency in a process. Supports virtual memory, programs larger than the physical RAM of the system, can be executed.

Unix features continued ...

Supports hierarchical file system to hold user data organised in the form of directories and files. Identifies a user with a userid and groupid and allows access permissions to resources to be specified using these ids. Supports a command language selectable on a per user basis. (Example: csh, sh, and ksh) Supports a large number of tools, libraries and utilities to aid software development.

PPT Slide
Architecture of Unix
KERNEL Machine Hardware Database Packages Internet Tools

Compilers UNIX Commands Other Application System SW shell shell Shell User User Shell shell

PPT Slide

SHELL is the Command Language Interpreter. Users interact with the system through the shell. APPLICATIONS are user created software and third party purchased software. UTILITIES are executable programs for the users to perform a variety of standard functions supplied with the system. To use a Unix system, the user has to perform login process.

User Login Process.

On power-on, a Unix system boots and if successful, displays a user login screen. On the login screen, the user is expected to type his/her userid and password against the respective fields and hit return on the keyboard.

On successful login, a shell is opened in the users name and the filesystem access is set to the users home directory, the place where the user is allowed store data.

The shell

Unix command interpreter that acts as an interface between the user and the Unix system. The shell is first invoked as a user's initial process by the login process. The shell is governed by a set of shell and environment variables which can be declared in shell setup files. Setup files can also be used to define command aliases, and execute Unix commands during login and logout.

Previous slide

Next slide

Back to first slide

View graphic version

Shells continued ...

Commonly used shells - csh (C-shell), sh (Bourne shell), ksh (Korn shell), bash (cross between csh and sh), etc. Shells are associated with a shell prompt, which is a character echoed by the shell to indicate its readiness to accept the next command. Default for csh - %, sh, ksh, bash - $; is configurable. Each shell has its own set of setup files, from where it initialises the shell and environment variables.

Shells setup files.

sh: .profile in your home directory.

csh: .cshrc, .login and .logout in your home directory. ksh: .profile in your home directory and any file defined by $ENV variable. bash: .bash_profile, .bash_login, .profile, .bashrc and .bash_logout in your home directory.

Setup files contents.


Search path. Terminal type. Command aliases. Shell and environment variable definitions. Creating a custom prompt. Run few commands whenever you log in.

Basic Unix commands.


Ownership related. File and directory related. Process related. File operations related. Commands for networked environments. Windowing system related. Miscellaneous.

Ownership commands.

w - System uptime, who is logged in and what they are doing. who - Who is logged on. whoami - Print current userid. id - Print the uid and gid of the current user. logname - Print the userid. passwd - Command for changing the password.

File and Directory commands.


cd - Change current directory. ls - List contents of the current directory. pwd - Print working directory. mkdir - Make a new directory. rm - Remove a file/s.

rmdir - Remove a directory. file - Identify the type of file. wc - Gives the word count of a file.

chmod - Change permissions of the file or directory.


chmod - Change permissions of the file or directory. chown - Change the ownership of the file or directory. chgrp - Change the group ownership of the file or directory.

Process commands.

ps - Print the processes status. kill - Kill a currently executing process. bg - Make an executing process run in background or batch mode. jobs - Show processes running in batch. fg - Bring back the process to foreground. nohup - Execute in batch without hangups.

File Operations commands.


head - Print the first 10 lines of a file. tail - Print the last 10 lines of a file. cat - Concatenate files. cp - copy files. mv - move files.

find - Find files. diff - Compare files/directories. ln - Link one file name to another. sort - Sort files; grep - search for a pattern. more - Display a file one screen at a time.

Commands for networked environments.


telnet - Login to a host in a n/wed setup. rlogin - Remotely login to a system. ftp - Simple file transfer program. rsh - Execute a remote shell. rcp - Remote copy of files.

Windowing System commands.


set DISPLAY - Set the DISPLAY shell variable. xhost - Controls/maintains X host access control list.

Miscellaneous Commands.

umask - Set file creation permissions. whatis - List short man page entry for a command. whereis - Show where executable is located. which - Show the complete path of executable.

PPT Slide

finger - User information lookup program. ping - Find network response status of a host. date - Print the current system date. cal - Calender command. touch - modify the access date of a file. clear - Clears screen. stty - display terminal characteristics. stty sane - Restores terminal characteristics to default values. du - Print disk usage statistics.

Unix Online help.

Man command: Provides reference information on topics, such as commands, subroutines, and files. The man command provides online help. MANPATH variable defines the search path for man pages on a system. Man pages information is organized under the following heads: purpose, syntax, description, flags, examples, implementation specific, Standards compliance and related information.

Files in Unix.

Files in Unix are entities that contain data and normally occupy disk space. Typically a file can be a directory, an executable program or simply a readable text file. The notion of owner in Unix has three variations: the user himself identified by userid, or a group of users identified by group id, or others. Access rights to a file are determined by the ownership rights. Each file will have these rights defined by way of read, write and execute permissions.

Access Permissions

UNIX is a multi-user system. Every file and directory in your account can be protected from or made accessible to other users by changing its access permissions. Every user has responsibility for controlling access to their files. Permissions for a file or directory may be any or all of:
r - read w - write x - execute = running a program

PPT Slide

Each permission (rwx) can be controlled at three levels:


u - user = yourself g - group = can be people in the same project o - other = everyone on the system

File access permissions are displayed using the ls -l command. The output from the ls -l command shows all permissions for all levels as three groups as -rwxrwxrwx

Accessing the machines.

Valid user account at SERC.


o o o

Application form duly signed by your Advisor/Research Supervisor Proof of studentship and payment of fees. Valid Institute ID Card.

Application form is normally available at SERC #104 during office hours on all working days.

Accessing the machines.

Valid user account at SERC.

o o o

Application form duly signed by your Advisor/Research Supervisor Proof of studentship and payment of fees. Valid Institute ID Card.

Application form is normally available at SERC #104 during office hours on all working days.

Organization of Users/Machines

Research Pool (Generally II floor) Course Pool (Generally III floor) Common Pool (Generally I floor)

NIS -> Running for each pool of machines at SERC to give single sign-on feature for the user. Hence, every user at SERC will have minimum two passwords.

http://www.serc.iisc.ernet.in/user/UserEdu98/aspe/sld003.htm

http://unixhelp.ed.ac.uk/shell/oview1.1.html

Summary of shell facilities


Bourne C TC Korn BASH ________________________________________________________ command history command alias shell scripts filename completion command line editing job control No No Yes No No No Yes Yes Yes Yes* No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes* Yes* Yes Yes Yes Yes Yes Yes Yes

Bourne shell (sh)


This is the original Unix shell written by Steve Bourne of Bell Labs. It is available on all UNIX systems. This shell does not have the interactive facilites provided by modern shells such as the C shell and Korn shell. You are advised to to use another shell which has these features. The Bourne shell does provide an easy to use language with which you can write shell scripts.

C shell (csh)
This shell was written at the University of California, Berkeley. It provides a C-like language with which to write shell scripts - hence its name.

TC shell (tcsh)
This shell is available in the public domain. It provides all the features of the C shell together with emacs style editing of the command line.

Korn shell (ksh)


This shell was written by David Korn of Bell labs. It is now provided as the standard shell on Unix systems. It provides all the features of the C and TC shells together with a shell programming language similar to that of the original Bourne shell. It is the most efficient shell. Consider using this as your standard interactive shell.

Bourne Again SHell (bash)


This is a public domain shell written by the Free Software Foundation under their GNU initiative. Ultimately it is intended to be a full implementation of the IEEE Posix Shell and Tools specification. This shell is widely used within the academic commnity. bash provides all the interactive features of the C shell (csh) and the Korn shell (ksh). Its programming language is compatible with the Bourne shell (sh). If you use the Bourne shell (sh) for shell programming consider using bash as your complete shell environment.

http://www.ee.surrey.ac.uk/Teaching/Unix/unixintro.html

UNIX Introduction
What is UNIX?
UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multitasking system for servers, desktops and laptops. UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which provides an easy to use environment. However, knowledge of UNIX is required for operations which aren't covered by a graphical program, or for when there is no windows interface available, for example, in a telnet session.

Types of UNIX
There are many different versions of UNIX, although they share common similarities. The most popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X. Here in the School, we use Solaris on our servers and workstations, and Fedora Linux on the servers and desktop PCs.

The UNIX operating system


The UNIX operating system is made up of three parts; the kernel, the shell and the programs.

The kernel
The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls. As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.

The shell
The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems). The adept user can customise his/her own shell, and users can use different shells on the same machine. Staff and students in the school have the tcsh shell by default. The tcsh shell has certain features to help the user inputting commands. Filename Completion - By typing part of the name of a command, filename or directory and pressing the [Tab] key, the tcsh shell will complete the rest of the name automatically. If the shell finds more than one name beginning with those letters you have typed, it will beep, prompting you to type a few more letters before pressing the tab key again. History - The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands.

Files and processes


Everything in UNIX is either a file or a process.

A process is an executing program identified by a unique PID (process identifier). A file is a collection of data. They are created by users using text editors, running compilers etc. Examples of files:

a document (report, essay etc.) the text of a program written in some high-level programming language instructions comprehensible directly to the machine and incomprehensible to a casual user, for example, a collection of binary digits (an executable or binary file); a directory, containing information about its contents, which may be a mixture of other directories (subdirectories) and ordinary files.

The Directory Structure


All the files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root (written as a slash / )

In the diagram above, we see that the home directory of the undergraduate student "ee51vn" contains two sub-directories (docs and pics) and a file called report.doc. The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc"

Starting an UNIX terminal


To open an UNIX terminal window, click on the "Terminal" icon from the drop-down menus.

An UNIX Terminal window will then appear with a % prompt, waiting for you to start entering commands.

You might also like