Functions of an Operating System.

1) Process management and Scheduling:
The operating system manages various peripherals and resources of the computer, user’s requests and commands, and schedules the job for the CPU to carry out in a sequence. It also handles sudden interrupt requirements and reschedules it accordingly.

2)Device Management:
There are two kinds of devices connected to a computer:
(1) Sharable devices such as discs, tapes and main memory enable many users simultaneously and dynamically to use them.
(2) Non-Shareable devices are printers, monitors, keyboards, card readers and other input/output devices such as mouse, scanner, plotter etc Non-shareable is so called because the device is for the exclusive use of one user at any given point of time.
The operating system monitors the availability and working conditions or status of these devices, as sharable or non-shareable and takes care of illegal instructions or commands and reports errors accordingly. The device management software, which forms a part of the operating system is called the BIOS (Basic Input Output Control System). For example, if the printer is not switched on or is not working the operating system reports, ‘Printer not ready’ and similar messages for discs or tape errors.

3) File and Data Management:
A user can have two kinds of files stored in the disc. It can be Programs and data or packages as files. In managing user programs and data files the operating system performs the following activities:
(1) Sets up directories and stores user files.
(2) Blocks and stores records
(3) Transfers main memory contents in specific filenames to discs and vice versa.
(4) Displays the name of files stored their size requests permission for overwriting or erasing and warnings such as space not available etc.
4) File Directory:
This refers to a table created by the operating system, where the list of filenames and their location in the floppy, hard disc, tape along with their size is stored for reference. The user needs to know only the name of the file and not its actual or physical location in the disc/tape or floppy.

5) Blocking and storing records:
The operating system logically partitions a media into blocks and then stores the records instead of allocating records to tracks and sectors serially. The operating system, stores records block by block and allocates physical location by dynamic blocking. The records are not stored serially from track 1 to the last track or from sector 1 to the last sector of a track. It stores randomly, but maintains the storage information in the lookup tables.

6) File Management:
In a multiuser system the access to the files are protected against tampering by unauthorized users. The hard disc, tapes and backup media, end users and system files storage and retrieval are all taken care of by the operating system.

7) Memory Management:
The available memory for processing such as accepting the keyboard and media inputs, storing intermediate results or output are all managed by the operating system. The operating system partitions the memory for different users and programs. In single user systems such as PC’s or workstations memory address and allocation is fixed but in a multiuser system memory allocation is dynamic.

8) Handling Users:
The operating system stores user passwords, access permissions provided for any files and directories and allocates disc space, execute commands, and manage single or multiple users simultaneously.

9) Command Interpretation and Execution:
The operating system reads the commands entered by the user, checks for errors, interprets and translates them to machine instructions and gets them executed by the hardware. Any error status is reported at the terminal. Every Operating System accompanying the hardware, has provision for executing user commands like copying, printing, renaming, deleting, listing etc.,

10) Job Accounting and Log Maintenance:
The operating system with the help of an internal time clock computes the time each resource (peripherals and CPU) is used by different users. It computes the lines printed, cards read , disc space, memory used, CPU time utilized etc. It also maintains a log and keeps track of the login and logout time of a particular user the commands entered by the user, files used and jobs carried out such as compiling, saving on hard disc or any other media printout etc.

11) Security:
In a single user system, the security generally provided is to physically lock up the system and media, to protect it from unauthorized access. The working files are saved in floppies or cartridge tapes and locked. Recently and of late add-on cards and software’s are available even for single user systems to incorporate password protection and security to prevent access.
In a multiuser environment, security protects one user from other by encrypting passwords and access permissions. File security and access permissions for owner, group and others, can be fixed at different modes such as read only , write only, execute only, etc., to enable access or non-access of file by various levels of users.

12) Communication:
Communication refers to the provision and facility provided to users to communicate with each other in the same system, or in another system, by sharing, transferring or downloading of programs and data files.
Multiuser systems provide interaction among different authorized users by forwarding and storing mails.
The console operator or system manager can send mail or messages to all the users currently logged in the system, either as general instructions or to warn users while shutting down the system, switching to single user mode etc., as the case may be.

13) Fault Tolerance Management:
In critical applications, fault tolerance management is built-in with the operating system, providing replication and dual hard discs. In the event of any interface or peripheral device failure, the system automatically switches over to the substitutes and keeps the process on without causing a breakdown. Instructions as to the nature of fault, and faulty devices is also displayed. This is achieved by incorporating parallel or duplicate devices redundantly. Disc mirroring for example, copies all files and programs in two discs and switches to one disc, if the other disc fails.

Functions of an Operating System

3) FUNCTIONS OF AN OPERATING SYSTEM:
Any kind of operating system has to carry out a variety of functions fundamentally an operating system is to:

• Transfer input from the keyboard to memory
• Display messages, be it input or output on the screen
• Store data or programs in external storage devices
• Output data on the printer from the memory
• Control the printer and other peripherals
• Load programs and packages from storage and media to the main memory
• Copy data or programs from one device to another
• Communicate, control and provide error message giving the status of peripherals and processes
• Execute user programs and commands
• Protect working storage from overwriting by another program
• Store details of data and location stored for all media and devices
• Security and protection to the user data program and files.
The functions and much more in the case of multiuser systems can be grouped and classified as:

1. Processor management and Scheduling
2. Device management
3. File and data management
4. Memory management
5. Handling Users
6. User Commands execution
7. Job accounting and log maintenance
8. Security
9. Communication
10. Fault tolerance management

Types of Operating Systems

2) KINDS OF OPERATING SYSTEMS
There are different types of operating systems in use, and they have been evolved in phases, parallel to computer generations and models. Different systems enable different types of computer operations. The type of system, depends on the way the system handles various data processing jobs. The types of operating systems are:
1. Batch Processing
2. Multitasking
3. Time Sharing
4. Real time and online
5. Operator dependent system
6. Interactive Processing
7. Distributed data processing and networking
8. Multi-user Systems
9. Multiprocessing and parallel processing
Batch Processing:
This type of operating system, was used for a long time with early computers, known as mainframes. Routine jobs like data processing were carried out in a batch, one after other. Data was punched in a punch card. Along with punch cards. Job control cards which carried the instructions were also used. This was one of the earliest forms of operating system. In this Primitive operating system, the CPU and the peripherals remained idle most of the time while the cards were being read, the printer was not in use. The throughput and utilization of the system resources was very low.
Multitasking:
In multitasking, the resources are made to work continuously. The card reader reads one job after another, and is stored in the main or auxiliary memory, depends on the volume of transactions. Similarly, the processed output of various jobs are stored in the main or auxiliary memory , and the outputted one by one to the printer. The CPU switches from one task to another for reading, processing and outputting. Thus the idle time of the peripherals are maintained drastically. The main memory is partitioned and many jobs are handled simultaneously. This enables more programs to reside in the central memory at the same time and instructions are executed by CPU. Multiprogramming and multitasking is the capability of this kind of operating system, which can executed multiple programs. This is possible because many programs can reside in the memory simultaneously, and the CPU can switch from one portion of a program to another. Many users and user terminals can also be connected and facilitated by these operating systems.
Time Sharing:
Many users are connected to the computer using an operating system called as “time sharing”. In time sharing the CPU switches from one user job to another user at a faster rate. After processing a user job, Operating system proceeds to the second, third, fourth user and so on, processing a job in a short interval of time and thus goes in a cycle continuously. If there are thousand users, the CPU can execute more than 2,50,000 instructions of every user with an average speed of 250 MHz.
Real Time/Online Operating System:
In a real time or an online operating system, all the resources are accessible 24 hours (online). The computer processes immediately, one or all the inputs, and delivers the outputs instantaneously, as for example, in process control, supermarkets or banking are some of the other examples of real time/online operating system. These operating systems are generally single application oriented; users are not permitted to prepare or modify programs, but allowed only to input data, make enquiries and get reports. These are dedicated systems meant for one specific application.
Operating Dependent System:
Earlier systems such as IBM 1620 DEC SYSTEMS and so on, required a computer operator to operate the system. His job was to stack manually, punched cards prepared by various users, along with specific job control cards, load the tapes, replace cartridge discs depending on the user’s need Operate the computer identify outputs from the line printer and provides them to the respective individuals. Debugging and obtaining correct results by each user involved lot of time, since they did not have direct access to the computer.
Interactive processing:
With the advent of PC’s, the computer is completely at the disposal of and dedicated to the user (single). The operating systems, in this case, like MS-DOS, WINDOWS, etc, enables direct interaction with the compiling process and errors are displayed on the screen minimizing the duration of getting the result.
Application packages can also be loaded through simple commands by non-programmers. Users can comfortably use the computer with ease. Interactive processing is also facilitated in multiuser systems, using dumb or intelligent terminals.
Distributed Data Processing and Networking:
In a single user system as detailed above, the peripheral resources, such as the hard disc and printers are not fully utilized. The printer remains idle, when the computer is used for data entry, and this happens most of the time. An application packages used by different users, have to be copied to various PC’s. Data updating, editing becames cumbersome with single user systems, since the data in the system is to be correct one by one. An application package on inventory . For example can be used stores accounts, purchase sections etc.
Multiuser Systems:
The principle of multiprogramming and multitasking and the need for interactive processing led to the development of multiuser systems. Mainframes, super minis and mini systems, were designed to serve the needs of multiple users incorporating the concepts of multiprogramming and time sharing. A mini system serves 10 to 15 users, a super mini serves 30 to 40 users, and a mainframe 100 to 1000 users. These systems provide each user a terminal (consisting of monitor and keyboard). The size configuration and cost of the computer is decided not noly on the software needed but also on the number of users, and the speed with which the processing is to be carried out.
With the development of communication technologies embracing microwave and satellite communication and optical fiber systems, large computers are networked across continents and a terminal connected to a computer in a particular location, can downloaded files, programs and data from a computer located thousands of kilometers away and can send mail to another user, even if he is not logged on to the system when the mail is sent. Such developments in computer and communication technologies demand standardization of operating systems communication protocols networking software and interfaces.
Multiprocessing and parallel Processing Operating Systems:
As the number of users increased the response time had to be kept up and when the volume of data to be processed increased like in the case of weather forecasting terrain mapping, nuclear research, image processing, simulation etc., just one processor or increasing the clock speed of the processor did not suffice. In the cases, the speed of the computer had to be enhanced by adding few more processors.
Two approaches evolved in this technique. Both incorporated multiple processors. One was to route different jobs to different processors and another was to route each statement in the program to different processors. This was called parallel programming. The functions of an operating system and design in such environments became more complex. Fault tolerance of processor, interfaces and peripherals had also to be built into such operating systems like disc mirroring and replication.
Current trends towards multiprocessor and parallel processing systems and these operating systems and techniques are associated with super mini and super computers.

Operating System

1) Operating System:
Operating System in an interface between the user and hardware. The operating system is a complicated set of instructions data which is required to make the computer perform to its optimum level. This software along with certain other software’s can be grouped as system software’s. The system software’s, such as editors, compilers, utilities, Operating system and application software, all forms various layers well integrated within themselves, around the hardware

Operating Systems and Software layers


System Software’s is so-called because it deals with the ‘system’ or hardware directly. Hence these software’s are powerful and efficient. Besides the Operating System software’s comprise of:




1. Assemblers: The hardware, functions only on two levels of pulses, ‘ON’ or ‘OFF’. The processor is designed to execute instructions in binary form only. Coding instructions for the CPU is difficult, because the entire coding is to be done by using a combination of ‘0’ (represents ‘OFF’) and ‘1’ (represents ‘ON’). This is also known as machine code/language. The system programmer codes instructions in assembly language, which is covered to machine code by the assembler.
2. Compilers and Interpreters: For scientific and commercial applications, programs (a set of instructions) using high level languages, such as languages/codes by the concerned compiler or interpreter, which generate executable files (in the case of compilers), or execute each statement one by one (in the case of interpreters).
3. Utilities: Specific jobs such as sorting, merging, setting up databases, crating tabular form of data, word processing etc. can be carried out straight away in the computer without any programming, with the help of certain utilities designed for specific purposes.
4. Debugging Tools: Any error or bugs in the user- prepared source programs can be debugged using debugging tools. Debuggers save time in interpreting and rectifying the errors easily.
5. Editors: Programs and data can be created by using editors. These software’s offer the advantage of storing data in the form of files in permanent storage media, such as tapes or discs. There are various editors- simple and complex, and the type of editor, depends on the Operating System.

Unix Commands

Access Control

exit - terminate a shell (see "man sh" or "man csh")
logout - sign off; end session (C shell and bash shell only;)
passwd - change login password
rlogin - log in remotely to another UNIX system
ssh - secure shell
slogin - secure version of rlogin
yppasswd - change login password in yellow pages
Communications

mail - send and receive mail
mesg - permit or deny terminal messages and talk requests
pine - send and receive mail
talk - talk to another logged-in user
write - write to another logged-in user
Programming Tools

as - assembler, specific to each machine architecture
awk - pattern scanning and processing language
bc - online calculator
cc - C compiler
csh - C shell command interpreter
dbx - source-level debugging program
f77 - Fortran compiler
gdb - GNU Project debugger
gprof - display profile of called routines
kill - kill a process
ld - the UNIX loader
lex - generate lexical analysis programs
lint - check C source code
make - maintain large programs
maple - symbolic mathematics program
math - symbolic mathematics program
nice - run a command at low priority (see "man nice" or "man csh")
nohup - run a command immune to hangups
pc - Pascal compiler (xlp on ADS)
perl - Popular script interpreter
prof - display profile data
python - Python programming language
sh - Bourne shell command interpreter
yacc - generate input parsing programs
xcalc - graphical calulator under x
Documentation

apropos - locate commands by keyword lookup
find - locate file (i.e. find . -name *.tex -print)
info - start the info explorer program
man - find manual information about commands
whatis - describe what a command is
whereis - locate source, binary, or man page for a program
Editors

emacs - screen-oriented text editor
pico - screen-oriented text editor (renamed called nano)
sed - stream-oriented text editor
vi - full-screen text editor
vim - full-screen text editor ("vi-improved")
File and Directory Management

cd - change working directory
chmod - change the protection of a file or directory
chown - change owner (or group) of a file or directory
chgrp - change group of a file or directory
cmp - compare two files
comm - select/reject lines common to two sorted files
cp - copy files
crypt - encrypt/decrypt files (CCWF only)
diff - compare the contents of two ASCII files
file - determine file type
grep - search a file for a pattern
gzip - compress or expand files
ln - make a link to a file
ls - list the contents of a directory
lsof - list of open files
mkdir - create a directory
mv - move or rename files and directories
pwd - show the full pathname of your working directory
quota - display disk usage and limits
rm - delete (remove) files
rmdir - delete (remove) directories
stat - status of file (i.e. last access)
sync - flush filesystem buffers
sort - sort or merge files
tar - create or extract archives
tee - copy input to standard output and other files
tr - translate characters
umask - change default file protections
uncompress - restore compressed file
uniq - report (or delete) repeated lines in a file
wc - count lines, words, and characters in a file
File Display and Printing

cat - show the contents of a file; catenate files
fold - fold long lines to fit output device
head - show first few lines of a file
lpq - examine the printer spooling queue
lpr - print a file
lprm - remove jobs from the printer spooling queue
more - display a file, one screen at a time
less - like more with more features
page - like "more", but prints screens top to bottom
pr - paginate a file for printing
tail - show the last part of a file
zcat - display a compressed file
xv - show print, manipulate images
gv - show ps and pdf files
xpdf = shopw pdf files (use gv)
File Transfer

ftp - transfer files between network hosts
rsync - fast and flexible sync between computers
scp - secure version of rcp
Miscellaneous

alias - define synonym commands
chquota - change disk quota on ACITS UNIX systems
chsh - change default login shell
clear - clear terminal screen
echo - echo arguments
pbm - portable bitmap manipulation programs
popd - pop the directory stack (C shell only)
pushd - push directory on stack (C shell only)
script - make typescript of terminal session
setenv - set an environment variable (C shell only)
stty - set terminal options
News/Networks

netstat - show network status
rsh - run shell or command on another UNIX system
ssh - secure-shell version of rsh
Process Control

bg - put suspended process into background
fg - bring process into foreground
jobs - list processes
^y - suspend process at next input request
^z - suspend current process
Status Information

clock - determine processor time
date - show date and time
df - summarize free disk space
du - summarize disk space used
env - display environment
finger - look up user information
history - list previously issued commands
last - indicate last login of users
lpq - examine spool queue
manpath - show search path for man pages
printenv - print out environment
ps - show process status
pwd - print full pathname of working directory
set - set shell variables (C shell, bash, or ksh)
spend - lists year-to-date ACITS UNIX charges
stty - set terminal options
time - timing programs
top - list top cpu processes
uptime - show system load, how long system has been up
w - show who is on system, what command each job is executing
who - show who is logged onto the system
whois - Internet user name directory service
whoami - who owns the shell
Image Processing

gimp - photoshop type image processing program
xfig - drawing program
xv - image viewer
xvscan - scan picture
xpaint - paint program
kpaint - kde paint program
Sound

mplayer - mpg player
realplay - realaudio player
timidity - midi to wav converter and player
xmms - mp3 player
Text Processing

abiword - open source word processor
addbib - create or extend bibliographic database
col - filter reverse line feeds
diction - identify wordy sentences
diffmk - mark differences between files
dvips - convert TeX DVI files into PostScript
explain - explain phrases found by diction program
grap - pic preprocessor for drawing graphs
hyphen - find hyphenated words
ispell - check spelling interactively
latex - format text in LaTeX (based on TeX)
pdfelatex - latex with pdf output
latex2html - Latex to html
lookbib - find bibliography references
macref - make cross-reference listing of nroff/troff macro files
ndx - create a subject-page index for a document
neqn - format mathematics with nroff
nroff - format text for simple display
pic - make simple pictures for troff input
psdit - filter troff output for Apple LaserWriter
ptx - make permuted index (not on CCWF)
refer - insert references from bibliographic databases
roffbib - run off bibliographic database
sortbib - sort bibliographic database
spell - find spelling errors
ispell - interactive spell checker
style - analyze surface characteristics of a document
tbl - format tables for nroff/troff
tex - format text
tpic - convert pic source files into TeX commands
wget - grab webpage
X windows

grabmode - info on screen: i.e. "1152x864" 51.213kHz/56.59Hz
import - grab window (i.e. import ppm:- >out.ppm)
xdpyinfo - number of colors
xkill - kill xwindow
xlock - lock screen
xterm - xterminal
xwininfo - information on open window
Web

html2ps - html to ps
latex2html - latex to html translator
lynx - text based webbrowser
netscape - webbrowser
sitecopy - sitecopy is for easily maintaining remote web sites.
weblint - html sytax and style checker

Unix

What is Unix ?
The UNIX operating system is a set of programs that act as a link between the computer and the user.

The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.

Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.

Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.

There are various Unix variants available in the market. Solaris Unix, AIX, UP Unix and BSD are few examples. Linux is also a flavour of Unix which is freely available.

Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system.

A user can also run multiple programs at the same time; hence UNIX is called multitasking.

Unix Architecture:
Here is a basic block diagram of a UNIX system:

Korn Shell

Korn Shell Programming


Basics of Korn Shell.
Shell is a user interface between computer and a user. Windows-95, Dos, Os/2 are all Shells as well as operating systems. Unix is an operating systems while Korn shell, Bourne Shell, C shell are the user interface to the Unix operating systems. Shells are means and ways to communicate with computer through command line.
If I want to e-mail me a calander of current month at the beginning of each month, I will use
cal | mail sateesh
In this command, I am telling computer to throw the current calandar at output and them I am piping (|) that output to mail which is sending it to user sateesh.

Unix Commands

Unix commands

Misc commands
man,banner,cal, calendar,clear,nohup, tty .
Man ual command.
man man This is help command, and will explains you about online manual pages you can also use man in conjunction with any command to learn more about that command for example.
• man ls will explain about the ls command and how you can use it.
• man -k pattern command will search for the pattern in given command.

Banner command.
banner prints characters in a sort of ascii art poster, for example to print wait in big letters. I will type
banner wait at unix command line or in my script. This is how it will look.


Cal command
cal command will print the calander on current month by default. If you want to print calander of august of 1965. That's eightht month of 1965.
cal 8 1965 will print following results.
August 1965
S M Tu W Th F S
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
29 30 31


Clear command
clear command clears the screen and puts cursor at beginning of first line.

Calendar command
calendar command reads your calendar file and displays only lines with current day.
For example in your calendar file if you have this
12/20 Test new software.
1/15 Test newly developed 3270 product.
1/20 Install memory on HP 9000 machine.
On dec 20th the first line will be displayed. you can use this command with your crontab file or in your login files.

Nohup command.
nohup command if added in front of any command will continue running the command or process even if you shut down your terminal or close your session to machine. For exmaple, if I want to run a job that takes lot of time and must be run from terminal and is called update_entries_tonight .
nohup update_entries_tonight will run the job even if terminal is shut down in middle of this job.

Tty command
Tty command will display your terminal. Syntax is
tty options
Options
• -l will print the synchronous line number.
• -s will return only the codes: 0 (a terminal), 1 (not a terminal), 2 (invalid options) (good for scripts)


File Management commands.
cat,cd, cp, file,head,tail, ln,ls,mkdir ,more,mv, pwd, rcp,rm, rmdir, wc.

Pwd command.
pwd command will print your home directory on screen, pwd means print working directory.
/u0/ssb/sandeep
is output for the command when I use pwd in /u0/ssb/sandeep directory.

Ls command
ls command is most widely used command and it displays the contents of directory.
options
• ls will list all the files in your home directory, this command has many options.
• ls -l will list all the file names, permissions, group, etc in long format.
• ls -a will list all the files including hidden files that start with . .
• ls -lt will list all files names based on the time of creation, newer files bring first.
• ls -Fxwill list files and directory names will be followed by slash.
• ls -Rwill lists all the files and files in the all the directories, recursively.
• ls -R | more will list all the files and files in all the directories, one page at a time.

Mkdir command.
mkdir sandeep will create new directory, i.e. here sandeep directory is created.

Cd command.
cd sandeep will change directory from current directory to sandeep directory.
Use pwd to check your current directory and ls to see if sandeep directory is there or not.
You can then use cd sandeep to change the directory to this new directory.

will restore all files whose name contain "save"
• find . -depth -print | cpio -padm /mydir will move a directory tree.

Dump command is useful to backup the file systems.
dump command copies all the files in filesystem that have been changed after a certain date. It is good for incremental backups. This information about date is derived from /var/adm/dumpdates and /etc/fstab .
syntax for HP-UX dump is
/usr/sbin/dump [option [argument ...] filesystem]
Options
• 0-9 This number is dump level. 0 option causes entire filesystem to be dumped.
• b blocking factor taken into argument.
• d density of tape default value is 1600.
• f place the dump on next argument file instead of tape.
• This example causes the entire file system (/mnt) to be dumped on /dev/rmt/c0t0d0BEST and specifies that the density of the tape is 6250 BPI.
o /usr/sbin/dump 0df 6250 /dev/rmt/c0t0d0BEST /mnt
• for more info type man dump at command line.

Pack command.
pack command compacts each file and combine them together into a filename.z file. The original file is replaced. Pcat and unpack will restore packed files to their original form.
Syntax is
Pack options files
Options
• - Print number of times each byte is used, relative frequency and byte code.
• -f Force the pack even when disk space isn't saved.
• To display Packed files in a file use pcat command
pcat filename.z
• To unpack a packed file use unpack command as unpack filename.z .

Tar command.
tar command creates an archive of files into a single file.
Tar copies and restore files to a tape or any storage media. Synopsis of tar is
tar [options] [file]

Examples:
tar cvf /dev/rmt/0 /bin /usr/bin creates an archive of /bin and /usr/bin, and store on the tape in /dev/rmt0.
tar tvf /dev/rmt0 will list the tape's content in a /dev/rmt0 drive.
tar cvf - 'find . -print' > backup.tar will creates an archive of current directory and store it in file backup.tar.
Functions:
• c creates a new tape.
• r append files to a tape.
• t print the names of files if they are stored on the tape.
• x extract files from tape.
Options:
• b n use blocking factor of n.
• l print error messages about links not found.
• L follow symbolic links.
• v print function letter (x for extraction or a for archive) and name of files.
________________________________________

Mt command
Mt command is used for tape and other device functions like rewinding, ejecting, etc. It give commands to tape device rather than tape itself. Mt command is BSD command and is seldom found in system V unix versions.
syntax is
mt [-t tapename] command [count]
mt for HP-UX accept following commands
• eof write count EOF marks.
• fsf Forward space count files.
• fsr Forward space count records.
• bsf Backward space count files.
• bsr Backward space count records.
• rew Rewind tape.
• offl Rewind tape and go offline.
• eod Seek to end of data (DDS and QIC drives only).
• smk Write count setmarks (DDS drives only).
• fss Forward space count setmarks (DDS drives only).
• bss Backward space count setmarks (DDS drives only).
• Examples
o mt -t /dev/rmt/0mnb rew will rewind the tape in this device.
o mt -t /dev/rmt/0mnb offl will eject the tape in this device.


System Status
at, chmod,chgrp, chown,crontab,date, df,du, env, finger, ps,ruptime, shutdwon,stty, who.

At command.
at command along with crontab command is used to schedule jobs.
at options time [ddate] [+increment] is syntax of at command.
for example if I have a script named usersloggedin which contains.
#!/bin/ksh
who | wc -l
echo "are total number of people logged in at this time."
and I want to run this script at 8:00 AM. So I will first type at 8:00 %lt;enter>
usersloggedin %lt;enter>
I will get following output at 8:00 AM
30
are total number of people logged in at this time.
Options:
• -f file will execute commands in a file.
• -m will send mail to user after job is completed.
• -l will report all jobs that are scheduled and their jobnumbers.
• -r jobnumber will remove specified jobs that were previously scheduled.

Chmod command.
chmod command is used to change permissions on a file.
for example if I have a text file with calender in it called cal.txt.
initially when this file will be created the permissions for this file depends upon umask set in your profile files. As you can see this file has 666 or -rw-rw-rw attributes.

ls -la cal.txt
-rw-rw-rw- 1 ssb dxidev 135 Dec 3 16:14 cal.txt
In this line above I have -rw-rw-rw- meaning respectively that owner can read and write file, member of the owner's group can read and write this file and anyone else connected to this system can read and write this file., next ssb is owner of this file dxidev is the group of this file, there are 135 bytes in this file, this file was created on December 3 at time16:14 and at the end there is name of this file. Learn to read these permissions in binary, like this for example Decimal 644 which is 110 100 100 in binary meand rw-r--r-- or user can read,write this file, group can read only, everyone else can read only. Similarly, if permissions are 755 or 111 101 101 that means rwxr-xr-x or user can read, write and execute, group can read and execute, everyone else can read and execute. All directories have d in front of permissions. So if you don't want anyone to see your files or to do anything with it use chmod command and make permissions so that only you can read and write to that file, i.e.
chmod 600 filename.

Chgrp command.
chgrp command is used to change the group of a file or directory.
You must own the file or be a superuser.
chgrp [options] newgroup files is syntax of chgrp.
Newgroup is either a group Id or a group name located in /etc/group .
Options:
• -h will change the group on symbolic links.
• -R recursively descend through directory changing group of all files and subdirectories.

Chown command.
chown command to change ownership of a file or directory to one or more users.
Syntax is
chown options newowner files
Options
• -h will change the owner on symbolic links.
• -R will recursively descend through the directory, including subdirectories and symbolic links.

Crontab command.
crontab command is used to schedule jobs. You must have permission to run this command by unix Administrator. Jobs are scheduled in five numbers, as follows.
Minutes 0-59
Hour 0-23
Day of month 1-31
month 1-12
Day of week 0-6 (0 is sunday)
so for example you want to schedule a job which runs from script named backup_jobs in /usr/local/bin directory on sunday (day 0) at 11.25 (22:25) on 15th of month. The entry in crontab file will be. * represents all values.
25 22 15 * 0 /usr/local/bin/backup_jobs
The * here tells system to run this each month.
Syntax is
crontab file So a create a file with the scheduled jobs as above and then type
crontab filename .This will scheduled the jobs.

Date command.
Date displays todays date, to use it type date at prompt.
Sun Dec 7 14:23:08 EST 1997
is similar to what you should see on screen.

Df command.
df command displays information about mounted filesystems. It reports the number of free disk blocks. Typically a Disk block is 512 bytes (or 1/2 Kilobyte).
syntax is
df options name
Options
• -b will print only the number of free blocks.
• -e will print only the number of free files.
• -f will report free blocks but not free inodes.
• -F type will report on an umounted file system specified by type.
• -k will print allocation in kilobytes.
• -l will report only on local file systems.
• -n will print only the file system name type, with no arguments it lists type of all filesystems

Du command.
du command displays disk usage.

Env command.
env command displays all the variables.

Finger command.
finger command.

PS command
ps command is probably the most useful command for systems administrators. It reports information on active processes.
ps options
options.
• -a Lists all processes in system except processes not attached to terminals.
• -e Lists all processes in system.
• -f Lists a full listing.
• -j print process group ID and session ID.

Ruptime command.
ruptime command tells the status of local networked machines.
ruptime options
options.
• -a include user even if they've been idle for more than one hour.
• -l sort by load average.
• -r reverse the sort order.
• -t sort by uptime.
• -i sort by number of users.

Shutdown command.
Shutdown command can only be executed by root. To gracefully bring down a system, shutdown command is used.
options.
• -gn use a grace-period of n seconds (default is 60).
• -ik tell the init command to place system in a state k.
o s single-user state (default)
o 0 shutdown for power-off.
o 1 like s, but mount multi-user file systems.
o 5 stop system, go to firmware mode.
o 6 stop system then reboot.
• -y suppress the default prompt for confirmation.

Stty command
stty command sets terminal input output options for the current terminal. without options stty reports terminal settings.
stty options modes < device options • -a report all options. • -g report current settings. Modes • 0 hang up phone. • n set terminal baud. • erase keyname, will change your keyname to be backspace key. Who command who command displays information about the current status of system. who options file Who as default prints login names of users currently logged in. Options • -a use all options. • -b Report information about last reboot. • -d report expired processes. • -H print headings. • -p report previously spawned processes. • -u report terminal usage. Advance unix command concepts Put advance commands utilities, redirection, etc here. cal > cal.txt To create a new file called cal.txt that has calendar for current month. > sign redirects output from stdout (screen) to a file.

Unix fundamentals

System V Unix operating systems was developed by AT&T bell labs and it is the most widely used Unix operating systems. An operating system is that piece of software which lets you interact with hardware in your computer. For example, when to call CPU, when to store in Memory, when to read from Disk , how to connect to outside world is all being done on any Operating systems in any computer at all the time, oblivious to the user. Then this operating systems is put in a package before selling to us, just like when you buy chocolates. The package around which this operating systems is wrapped is called User Interface in computing terminology. Some developers like Microsoft spend more time on developing this user interface than the real operating systems, like Windows 95, others like Sun solaris had spend more time on reliability and strength of the operating systems rather then how user interacts with it. That's the big difference between Unix and Windows 95 (and all the other microsoft products). Unix is more powerful, more reliable, can do much more work, much faster and you do not need to reboot your computer everyday. Only problem is that many people get put off by the command line user interface. But things are changing now and even unix has its own version of X windows. Learning different command on Unix is quite an experience. Unix operating systems uses many different user interfaces depending upon the user, different command line interfaces are called Shells, you can use Ksh (korn shell), Bash, (bourne Again Shell), csh (C shell), etc.
The core of unix is called kernel. Kernel interacts with hardware, software and user interface (i.e. Shell). When you enter a command to add two numbers, kernel converts the ascii english like command to the binary language of central processing unit and then pass these binary bits of 1's and 0's to cpu byte by byte which then processes and give back the answer to kernel and kernel sends it out to standard output (screen) after converting them back to decimal number notation which we all use.
In this document all the commands that appear in greenish blue color you can type and use in your Unix session.
The Basics
How do I login to Unix system?
You need to have an account created by unix administrator for that particular system. For example if you want to login to unix systems named punjab1., open up a new session to punjab1 and at prompt enter your user name and password as supplied by Administrator.
What do I do after login?
Once logged in, you will see a shell prompt, actually a blank screen with on blinking cursor, that means you are ready to enter your commands. Here you can use These basic unix commands. For more information about that command you can use online help by typing man man. $ sign means shell prompt so you do not need to enter $.


Some common problems
One of the first common problem is incorrect TERM variable. To make sure that your terminal is set to correct emulation check your emulation by cal command which displays calendar for current month. Type cal at command line.
December 1997
S M Tu W Th F S
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 29 30 31
If you did not see nice and formatted like above then probably you need to set your terminal emulation.

To find out what your terminal is set to.
$echo $TERM
vt100
(this is what you should get back, vt100 works well with ibm PCs)

To see what shell you are using echo $SHELL
/bin/ksh
is what you will get if using korn shell,
/bin/csh
if using c shell. You default login files if you are using korn shell are .profile and .kshrc and for c shell are .login and .cshrc. You can edit these files to put any additional variables you like to set when logging in .

To make your backspace key an erase key.
stty erase backspace key

To set terminal emulation to vt100 if using ksh
export TERM=vt100
if using csh
setenv TERM vt100
Other conecpts
What are files?
The bits and bytes of data represented in electronic flip and flops are files. For example, an ascii character of A is represented by 41H or 0100 0001. Which is interpreted by CPU in the time period as one low one high one low one low one low one low one low one high. So here code for A which is 41 (in Hex) is actually one byte, since a 0 or 1 is one bit and one byte equals 8 bits.
Two types of files exist in computing world, Ascii and Binary. ASCII is portable across many different operating systems (or platforms as some people call) it is a standard and its full form is American Standard Code for Information Interchange. Binary files depends upon the application on which it is used. For example this document you are reading is an ASCII file while the pictures you are seeing are binary files cause pictures depends upon few formats like gif or jpg which can be interpreted by the browser (Netscape, IE Explorer). So while transferring files from one system to another, using binary mode is safer, since bit by bit is transferred. As you are reading this document which is called index.html it is using ASCII characters with references to binary picture files and other html ASCII files here and there.
Then there are permissions on each of these files which are divided into your permissions, your group's permissions, rest of world permissions, and extra permissions (sticky bit, suid bit, etc).
I am going to create a new file using cal command which displays calendar and instead of seeing it on the screen I will put the output in a file called cal.txt using redirection > symbol.
cal > cal.txt
Now to see this file and permissions on it I will use ls command with -la option.
ls -la cal.txt
-rw-rw-rw- 1 ssb dxidev 135 Dec 3 16:14 cal.txt
In this line above I have -rw-rw-rw- meaning respectively that owner can read and write file, member of the owner's group can read and write this file and anyone else connected to this system can read and write this file., next ssb is owner of this file dxidev is the group of this file, there are 135 bytes in this file, this file was created on December 3 at time16:14 and at the end there is name of this file. Learn to read these permissions in binary, like this for example Decimal 644 which is 110 100 100 in binary meand rw-r--r-- or user can read,write this file, group can read only, everyone else can read only. Similarly, if permissions are 755 or 111 101 101 that means rwxr-xr-x or user can read, write and execute, group can read and execute, everyone else can read and execute. All directories have d in front of permissions. So if you don't want anyone to see your files or to do anything with it use chmod command and make permissions so that only you can read and write to that file, i.e. chmod 600 filename.

Thursday 30 June 2011

Functions of an Operating System.

1) Process management and Scheduling:
The operating system manages various peripherals and resources of the computer, user’s requests and commands, and schedules the job for the CPU to carry out in a sequence. It also handles sudden interrupt requirements and reschedules it accordingly.

2)Device Management:
There are two kinds of devices connected to a computer:
(1) Sharable devices such as discs, tapes and main memory enable many users simultaneously and dynamically to use them.
(2) Non-Shareable devices are printers, monitors, keyboards, card readers and other input/output devices such as mouse, scanner, plotter etc Non-shareable is so called because the device is for the exclusive use of one user at any given point of time.
The operating system monitors the availability and working conditions or status of these devices, as sharable or non-shareable and takes care of illegal instructions or commands and reports errors accordingly. The device management software, which forms a part of the operating system is called the BIOS (Basic Input Output Control System). For example, if the printer is not switched on or is not working the operating system reports, ‘Printer not ready’ and similar messages for discs or tape errors.

3) File and Data Management:
A user can have two kinds of files stored in the disc. It can be Programs and data or packages as files. In managing user programs and data files the operating system performs the following activities:
(1) Sets up directories and stores user files.
(2) Blocks and stores records
(3) Transfers main memory contents in specific filenames to discs and vice versa.
(4) Displays the name of files stored their size requests permission for overwriting or erasing and warnings such as space not available etc.
4) File Directory:
This refers to a table created by the operating system, where the list of filenames and their location in the floppy, hard disc, tape along with their size is stored for reference. The user needs to know only the name of the file and not its actual or physical location in the disc/tape or floppy.

5) Blocking and storing records:
The operating system logically partitions a media into blocks and then stores the records instead of allocating records to tracks and sectors serially. The operating system, stores records block by block and allocates physical location by dynamic blocking. The records are not stored serially from track 1 to the last track or from sector 1 to the last sector of a track. It stores randomly, but maintains the storage information in the lookup tables.

6) File Management:
In a multiuser system the access to the files are protected against tampering by unauthorized users. The hard disc, tapes and backup media, end users and system files storage and retrieval are all taken care of by the operating system.

7) Memory Management:
The available memory for processing such as accepting the keyboard and media inputs, storing intermediate results or output are all managed by the operating system. The operating system partitions the memory for different users and programs. In single user systems such as PC’s or workstations memory address and allocation is fixed but in a multiuser system memory allocation is dynamic.

8) Handling Users:
The operating system stores user passwords, access permissions provided for any files and directories and allocates disc space, execute commands, and manage single or multiple users simultaneously.

9) Command Interpretation and Execution:
The operating system reads the commands entered by the user, checks for errors, interprets and translates them to machine instructions and gets them executed by the hardware. Any error status is reported at the terminal. Every Operating System accompanying the hardware, has provision for executing user commands like copying, printing, renaming, deleting, listing etc.,

10) Job Accounting and Log Maintenance:
The operating system with the help of an internal time clock computes the time each resource (peripherals and CPU) is used by different users. It computes the lines printed, cards read , disc space, memory used, CPU time utilized etc. It also maintains a log and keeps track of the login and logout time of a particular user the commands entered by the user, files used and jobs carried out such as compiling, saving on hard disc or any other media printout etc.

11) Security:
In a single user system, the security generally provided is to physically lock up the system and media, to protect it from unauthorized access. The working files are saved in floppies or cartridge tapes and locked. Recently and of late add-on cards and software’s are available even for single user systems to incorporate password protection and security to prevent access.
In a multiuser environment, security protects one user from other by encrypting passwords and access permissions. File security and access permissions for owner, group and others, can be fixed at different modes such as read only , write only, execute only, etc., to enable access or non-access of file by various levels of users.

12) Communication:
Communication refers to the provision and facility provided to users to communicate with each other in the same system, or in another system, by sharing, transferring or downloading of programs and data files.
Multiuser systems provide interaction among different authorized users by forwarding and storing mails.
The console operator or system manager can send mail or messages to all the users currently logged in the system, either as general instructions or to warn users while shutting down the system, switching to single user mode etc., as the case may be.

13) Fault Tolerance Management:
In critical applications, fault tolerance management is built-in with the operating system, providing replication and dual hard discs. In the event of any interface or peripheral device failure, the system automatically switches over to the substitutes and keeps the process on without causing a breakdown. Instructions as to the nature of fault, and faulty devices is also displayed. This is achieved by incorporating parallel or duplicate devices redundantly. Disc mirroring for example, copies all files and programs in two discs and switches to one disc, if the other disc fails.

Wednesday 29 June 2011

Functions of an Operating System

3) FUNCTIONS OF AN OPERATING SYSTEM:
Any kind of operating system has to carry out a variety of functions fundamentally an operating system is to:

• Transfer input from the keyboard to memory
• Display messages, be it input or output on the screen
• Store data or programs in external storage devices
• Output data on the printer from the memory
• Control the printer and other peripherals
• Load programs and packages from storage and media to the main memory
• Copy data or programs from one device to another
• Communicate, control and provide error message giving the status of peripherals and processes
• Execute user programs and commands
• Protect working storage from overwriting by another program
• Store details of data and location stored for all media and devices
• Security and protection to the user data program and files.
The functions and much more in the case of multiuser systems can be grouped and classified as:

1. Processor management and Scheduling
2. Device management
3. File and data management
4. Memory management
5. Handling Users
6. User Commands execution
7. Job accounting and log maintenance
8. Security
9. Communication
10. Fault tolerance management

Types of Operating Systems

2) KINDS OF OPERATING SYSTEMS
There are different types of operating systems in use, and they have been evolved in phases, parallel to computer generations and models. Different systems enable different types of computer operations. The type of system, depends on the way the system handles various data processing jobs. The types of operating systems are:
1. Batch Processing
2. Multitasking
3. Time Sharing
4. Real time and online
5. Operator dependent system
6. Interactive Processing
7. Distributed data processing and networking
8. Multi-user Systems
9. Multiprocessing and parallel processing
Batch Processing:
This type of operating system, was used for a long time with early computers, known as mainframes. Routine jobs like data processing were carried out in a batch, one after other. Data was punched in a punch card. Along with punch cards. Job control cards which carried the instructions were also used. This was one of the earliest forms of operating system. In this Primitive operating system, the CPU and the peripherals remained idle most of the time while the cards were being read, the printer was not in use. The throughput and utilization of the system resources was very low.
Multitasking:
In multitasking, the resources are made to work continuously. The card reader reads one job after another, and is stored in the main or auxiliary memory, depends on the volume of transactions. Similarly, the processed output of various jobs are stored in the main or auxiliary memory , and the outputted one by one to the printer. The CPU switches from one task to another for reading, processing and outputting. Thus the idle time of the peripherals are maintained drastically. The main memory is partitioned and many jobs are handled simultaneously. This enables more programs to reside in the central memory at the same time and instructions are executed by CPU. Multiprogramming and multitasking is the capability of this kind of operating system, which can executed multiple programs. This is possible because many programs can reside in the memory simultaneously, and the CPU can switch from one portion of a program to another. Many users and user terminals can also be connected and facilitated by these operating systems.
Time Sharing:
Many users are connected to the computer using an operating system called as “time sharing”. In time sharing the CPU switches from one user job to another user at a faster rate. After processing a user job, Operating system proceeds to the second, third, fourth user and so on, processing a job in a short interval of time and thus goes in a cycle continuously. If there are thousand users, the CPU can execute more than 2,50,000 instructions of every user with an average speed of 250 MHz.
Real Time/Online Operating System:
In a real time or an online operating system, all the resources are accessible 24 hours (online). The computer processes immediately, one or all the inputs, and delivers the outputs instantaneously, as for example, in process control, supermarkets or banking are some of the other examples of real time/online operating system. These operating systems are generally single application oriented; users are not permitted to prepare or modify programs, but allowed only to input data, make enquiries and get reports. These are dedicated systems meant for one specific application.
Operating Dependent System:
Earlier systems such as IBM 1620 DEC SYSTEMS and so on, required a computer operator to operate the system. His job was to stack manually, punched cards prepared by various users, along with specific job control cards, load the tapes, replace cartridge discs depending on the user’s need Operate the computer identify outputs from the line printer and provides them to the respective individuals. Debugging and obtaining correct results by each user involved lot of time, since they did not have direct access to the computer.
Interactive processing:
With the advent of PC’s, the computer is completely at the disposal of and dedicated to the user (single). The operating systems, in this case, like MS-DOS, WINDOWS, etc, enables direct interaction with the compiling process and errors are displayed on the screen minimizing the duration of getting the result.
Application packages can also be loaded through simple commands by non-programmers. Users can comfortably use the computer with ease. Interactive processing is also facilitated in multiuser systems, using dumb or intelligent terminals.
Distributed Data Processing and Networking:
In a single user system as detailed above, the peripheral resources, such as the hard disc and printers are not fully utilized. The printer remains idle, when the computer is used for data entry, and this happens most of the time. An application packages used by different users, have to be copied to various PC’s. Data updating, editing becames cumbersome with single user systems, since the data in the system is to be correct one by one. An application package on inventory . For example can be used stores accounts, purchase sections etc.
Multiuser Systems:
The principle of multiprogramming and multitasking and the need for interactive processing led to the development of multiuser systems. Mainframes, super minis and mini systems, were designed to serve the needs of multiple users incorporating the concepts of multiprogramming and time sharing. A mini system serves 10 to 15 users, a super mini serves 30 to 40 users, and a mainframe 100 to 1000 users. These systems provide each user a terminal (consisting of monitor and keyboard). The size configuration and cost of the computer is decided not noly on the software needed but also on the number of users, and the speed with which the processing is to be carried out.
With the development of communication technologies embracing microwave and satellite communication and optical fiber systems, large computers are networked across continents and a terminal connected to a computer in a particular location, can downloaded files, programs and data from a computer located thousands of kilometers away and can send mail to another user, even if he is not logged on to the system when the mail is sent. Such developments in computer and communication technologies demand standardization of operating systems communication protocols networking software and interfaces.
Multiprocessing and parallel Processing Operating Systems:
As the number of users increased the response time had to be kept up and when the volume of data to be processed increased like in the case of weather forecasting terrain mapping, nuclear research, image processing, simulation etc., just one processor or increasing the clock speed of the processor did not suffice. In the cases, the speed of the computer had to be enhanced by adding few more processors.
Two approaches evolved in this technique. Both incorporated multiple processors. One was to route different jobs to different processors and another was to route each statement in the program to different processors. This was called parallel programming. The functions of an operating system and design in such environments became more complex. Fault tolerance of processor, interfaces and peripherals had also to be built into such operating systems like disc mirroring and replication.
Current trends towards multiprocessor and parallel processing systems and these operating systems and techniques are associated with super mini and super computers.

Operating System

1) Operating System:
Operating System in an interface between the user and hardware. The operating system is a complicated set of instructions data which is required to make the computer perform to its optimum level. This software along with certain other software’s can be grouped as system software’s. The system software’s, such as editors, compilers, utilities, Operating system and application software, all forms various layers well integrated within themselves, around the hardware

Operating Systems and Software layers


System Software’s is so-called because it deals with the ‘system’ or hardware directly. Hence these software’s are powerful and efficient. Besides the Operating System software’s comprise of:




1. Assemblers: The hardware, functions only on two levels of pulses, ‘ON’ or ‘OFF’. The processor is designed to execute instructions in binary form only. Coding instructions for the CPU is difficult, because the entire coding is to be done by using a combination of ‘0’ (represents ‘OFF’) and ‘1’ (represents ‘ON’). This is also known as machine code/language. The system programmer codes instructions in assembly language, which is covered to machine code by the assembler.
2. Compilers and Interpreters: For scientific and commercial applications, programs (a set of instructions) using high level languages, such as languages/codes by the concerned compiler or interpreter, which generate executable files (in the case of compilers), or execute each statement one by one (in the case of interpreters).
3. Utilities: Specific jobs such as sorting, merging, setting up databases, crating tabular form of data, word processing etc. can be carried out straight away in the computer without any programming, with the help of certain utilities designed for specific purposes.
4. Debugging Tools: Any error or bugs in the user- prepared source programs can be debugged using debugging tools. Debuggers save time in interpreting and rectifying the errors easily.
5. Editors: Programs and data can be created by using editors. These software’s offer the advantage of storing data in the form of files in permanent storage media, such as tapes or discs. There are various editors- simple and complex, and the type of editor, depends on the Operating System.

Tuesday 7 June 2011

Unix Commands

Access Control

exit - terminate a shell (see "man sh" or "man csh")
logout - sign off; end session (C shell and bash shell only;)
passwd - change login password
rlogin - log in remotely to another UNIX system
ssh - secure shell
slogin - secure version of rlogin
yppasswd - change login password in yellow pages
Communications

mail - send and receive mail
mesg - permit or deny terminal messages and talk requests
pine - send and receive mail
talk - talk to another logged-in user
write - write to another logged-in user
Programming Tools

as - assembler, specific to each machine architecture
awk - pattern scanning and processing language
bc - online calculator
cc - C compiler
csh - C shell command interpreter
dbx - source-level debugging program
f77 - Fortran compiler
gdb - GNU Project debugger
gprof - display profile of called routines
kill - kill a process
ld - the UNIX loader
lex - generate lexical analysis programs
lint - check C source code
make - maintain large programs
maple - symbolic mathematics program
math - symbolic mathematics program
nice - run a command at low priority (see "man nice" or "man csh")
nohup - run a command immune to hangups
pc - Pascal compiler (xlp on ADS)
perl - Popular script interpreter
prof - display profile data
python - Python programming language
sh - Bourne shell command interpreter
yacc - generate input parsing programs
xcalc - graphical calulator under x
Documentation

apropos - locate commands by keyword lookup
find - locate file (i.e. find . -name *.tex -print)
info - start the info explorer program
man - find manual information about commands
whatis - describe what a command is
whereis - locate source, binary, or man page for a program
Editors

emacs - screen-oriented text editor
pico - screen-oriented text editor (renamed called nano)
sed - stream-oriented text editor
vi - full-screen text editor
vim - full-screen text editor ("vi-improved")
File and Directory Management

cd - change working directory
chmod - change the protection of a file or directory
chown - change owner (or group) of a file or directory
chgrp - change group of a file or directory
cmp - compare two files
comm - select/reject lines common to two sorted files
cp - copy files
crypt - encrypt/decrypt files (CCWF only)
diff - compare the contents of two ASCII files
file - determine file type
grep - search a file for a pattern
gzip - compress or expand files
ln - make a link to a file
ls - list the contents of a directory
lsof - list of open files
mkdir - create a directory
mv - move or rename files and directories
pwd - show the full pathname of your working directory
quota - display disk usage and limits
rm - delete (remove) files
rmdir - delete (remove) directories
stat - status of file (i.e. last access)
sync - flush filesystem buffers
sort - sort or merge files
tar - create or extract archives
tee - copy input to standard output and other files
tr - translate characters
umask - change default file protections
uncompress - restore compressed file
uniq - report (or delete) repeated lines in a file
wc - count lines, words, and characters in a file
File Display and Printing

cat - show the contents of a file; catenate files
fold - fold long lines to fit output device
head - show first few lines of a file
lpq - examine the printer spooling queue
lpr - print a file
lprm - remove jobs from the printer spooling queue
more - display a file, one screen at a time
less - like more with more features
page - like "more", but prints screens top to bottom
pr - paginate a file for printing
tail - show the last part of a file
zcat - display a compressed file
xv - show print, manipulate images
gv - show ps and pdf files
xpdf = shopw pdf files (use gv)
File Transfer

ftp - transfer files between network hosts
rsync - fast and flexible sync between computers
scp - secure version of rcp
Miscellaneous

alias - define synonym commands
chquota - change disk quota on ACITS UNIX systems
chsh - change default login shell
clear - clear terminal screen
echo - echo arguments
pbm - portable bitmap manipulation programs
popd - pop the directory stack (C shell only)
pushd - push directory on stack (C shell only)
script - make typescript of terminal session
setenv - set an environment variable (C shell only)
stty - set terminal options
News/Networks

netstat - show network status
rsh - run shell or command on another UNIX system
ssh - secure-shell version of rsh
Process Control

bg - put suspended process into background
fg - bring process into foreground
jobs - list processes
^y - suspend process at next input request
^z - suspend current process
Status Information

clock - determine processor time
date - show date and time
df - summarize free disk space
du - summarize disk space used
env - display environment
finger - look up user information
history - list previously issued commands
last - indicate last login of users
lpq - examine spool queue
manpath - show search path for man pages
printenv - print out environment
ps - show process status
pwd - print full pathname of working directory
set - set shell variables (C shell, bash, or ksh)
spend - lists year-to-date ACITS UNIX charges
stty - set terminal options
time - timing programs
top - list top cpu processes
uptime - show system load, how long system has been up
w - show who is on system, what command each job is executing
who - show who is logged onto the system
whois - Internet user name directory service
whoami - who owns the shell
Image Processing

gimp - photoshop type image processing program
xfig - drawing program
xv - image viewer
xvscan - scan picture
xpaint - paint program
kpaint - kde paint program
Sound

mplayer - mpg player
realplay - realaudio player
timidity - midi to wav converter and player
xmms - mp3 player
Text Processing

abiword - open source word processor
addbib - create or extend bibliographic database
col - filter reverse line feeds
diction - identify wordy sentences
diffmk - mark differences between files
dvips - convert TeX DVI files into PostScript
explain - explain phrases found by diction program
grap - pic preprocessor for drawing graphs
hyphen - find hyphenated words
ispell - check spelling interactively
latex - format text in LaTeX (based on TeX)
pdfelatex - latex with pdf output
latex2html - Latex to html
lookbib - find bibliography references
macref - make cross-reference listing of nroff/troff macro files
ndx - create a subject-page index for a document
neqn - format mathematics with nroff
nroff - format text for simple display
pic - make simple pictures for troff input
psdit - filter troff output for Apple LaserWriter
ptx - make permuted index (not on CCWF)
refer - insert references from bibliographic databases
roffbib - run off bibliographic database
sortbib - sort bibliographic database
spell - find spelling errors
ispell - interactive spell checker
style - analyze surface characteristics of a document
tbl - format tables for nroff/troff
tex - format text
tpic - convert pic source files into TeX commands
wget - grab webpage
X windows

grabmode - info on screen: i.e. "1152x864" 51.213kHz/56.59Hz
import - grab window (i.e. import ppm:- >out.ppm)
xdpyinfo - number of colors
xkill - kill xwindow
xlock - lock screen
xterm - xterminal
xwininfo - information on open window
Web

html2ps - html to ps
latex2html - latex to html translator
lynx - text based webbrowser
netscape - webbrowser
sitecopy - sitecopy is for easily maintaining remote web sites.
weblint - html sytax and style checker

Unix

What is Unix ?
The UNIX operating system is a set of programs that act as a link between the computer and the user.

The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.

Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.

Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.

There are various Unix variants available in the market. Solaris Unix, AIX, UP Unix and BSD are few examples. Linux is also a flavour of Unix which is freely available.

Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system.

A user can also run multiple programs at the same time; hence UNIX is called multitasking.

Unix Architecture:
Here is a basic block diagram of a UNIX system:

Korn Shell

Korn Shell Programming


Basics of Korn Shell.
Shell is a user interface between computer and a user. Windows-95, Dos, Os/2 are all Shells as well as operating systems. Unix is an operating systems while Korn shell, Bourne Shell, C shell are the user interface to the Unix operating systems. Shells are means and ways to communicate with computer through command line.
If I want to e-mail me a calander of current month at the beginning of each month, I will use
cal | mail sateesh
In this command, I am telling computer to throw the current calandar at output and them I am piping (|) that output to mail which is sending it to user sateesh.

Unix Commands

Unix commands

Misc commands
man,banner,cal, calendar,clear,nohup, tty .
Man ual command.
man man This is help command, and will explains you about online manual pages you can also use man in conjunction with any command to learn more about that command for example.
• man ls will explain about the ls command and how you can use it.
• man -k pattern command will search for the pattern in given command.

Banner command.
banner prints characters in a sort of ascii art poster, for example to print wait in big letters. I will type
banner wait at unix command line or in my script. This is how it will look.


Cal command
cal command will print the calander on current month by default. If you want to print calander of august of 1965. That's eightht month of 1965.
cal 8 1965 will print following results.
August 1965
S M Tu W Th F S
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
29 30 31


Clear command
clear command clears the screen and puts cursor at beginning of first line.

Calendar command
calendar command reads your calendar file and displays only lines with current day.
For example in your calendar file if you have this
12/20 Test new software.
1/15 Test newly developed 3270 product.
1/20 Install memory on HP 9000 machine.
On dec 20th the first line will be displayed. you can use this command with your crontab file or in your login files.

Nohup command.
nohup command if added in front of any command will continue running the command or process even if you shut down your terminal or close your session to machine. For exmaple, if I want to run a job that takes lot of time and must be run from terminal and is called update_entries_tonight .
nohup update_entries_tonight will run the job even if terminal is shut down in middle of this job.

Tty command
Tty command will display your terminal. Syntax is
tty options
Options
• -l will print the synchronous line number.
• -s will return only the codes: 0 (a terminal), 1 (not a terminal), 2 (invalid options) (good for scripts)


File Management commands.
cat,cd, cp, file,head,tail, ln,ls,mkdir ,more,mv, pwd, rcp,rm, rmdir, wc.

Pwd command.
pwd command will print your home directory on screen, pwd means print working directory.
/u0/ssb/sandeep
is output for the command when I use pwd in /u0/ssb/sandeep directory.

Ls command
ls command is most widely used command and it displays the contents of directory.
options
• ls will list all the files in your home directory, this command has many options.
• ls -l will list all the file names, permissions, group, etc in long format.
• ls -a will list all the files including hidden files that start with . .
• ls -lt will list all files names based on the time of creation, newer files bring first.
• ls -Fxwill list files and directory names will be followed by slash.
• ls -Rwill lists all the files and files in the all the directories, recursively.
• ls -R | more will list all the files and files in all the directories, one page at a time.

Mkdir command.
mkdir sandeep will create new directory, i.e. here sandeep directory is created.

Cd command.
cd sandeep will change directory from current directory to sandeep directory.
Use pwd to check your current directory and ls to see if sandeep directory is there or not.
You can then use cd sandeep to change the directory to this new directory.

will restore all files whose name contain "save"
• find . -depth -print | cpio -padm /mydir will move a directory tree.

Dump command is useful to backup the file systems.
dump command copies all the files in filesystem that have been changed after a certain date. It is good for incremental backups. This information about date is derived from /var/adm/dumpdates and /etc/fstab .
syntax for HP-UX dump is
/usr/sbin/dump [option [argument ...] filesystem]
Options
• 0-9 This number is dump level. 0 option causes entire filesystem to be dumped.
• b blocking factor taken into argument.
• d density of tape default value is 1600.
• f place the dump on next argument file instead of tape.
• This example causes the entire file system (/mnt) to be dumped on /dev/rmt/c0t0d0BEST and specifies that the density of the tape is 6250 BPI.
o /usr/sbin/dump 0df 6250 /dev/rmt/c0t0d0BEST /mnt
• for more info type man dump at command line.

Pack command.
pack command compacts each file and combine them together into a filename.z file. The original file is replaced. Pcat and unpack will restore packed files to their original form.
Syntax is
Pack options files
Options
• - Print number of times each byte is used, relative frequency and byte code.
• -f Force the pack even when disk space isn't saved.
• To display Packed files in a file use pcat command
pcat filename.z
• To unpack a packed file use unpack command as unpack filename.z .

Tar command.
tar command creates an archive of files into a single file.
Tar copies and restore files to a tape or any storage media. Synopsis of tar is
tar [options] [file]

Examples:
tar cvf /dev/rmt/0 /bin /usr/bin creates an archive of /bin and /usr/bin, and store on the tape in /dev/rmt0.
tar tvf /dev/rmt0 will list the tape's content in a /dev/rmt0 drive.
tar cvf - 'find . -print' > backup.tar will creates an archive of current directory and store it in file backup.tar.
Functions:
• c creates a new tape.
• r append files to a tape.
• t print the names of files if they are stored on the tape.
• x extract files from tape.
Options:
• b n use blocking factor of n.
• l print error messages about links not found.
• L follow symbolic links.
• v print function letter (x for extraction or a for archive) and name of files.
________________________________________

Mt command
Mt command is used for tape and other device functions like rewinding, ejecting, etc. It give commands to tape device rather than tape itself. Mt command is BSD command and is seldom found in system V unix versions.
syntax is
mt [-t tapename] command [count]
mt for HP-UX accept following commands
• eof write count EOF marks.
• fsf Forward space count files.
• fsr Forward space count records.
• bsf Backward space count files.
• bsr Backward space count records.
• rew Rewind tape.
• offl Rewind tape and go offline.
• eod Seek to end of data (DDS and QIC drives only).
• smk Write count setmarks (DDS drives only).
• fss Forward space count setmarks (DDS drives only).
• bss Backward space count setmarks (DDS drives only).
• Examples
o mt -t /dev/rmt/0mnb rew will rewind the tape in this device.
o mt -t /dev/rmt/0mnb offl will eject the tape in this device.


System Status
at, chmod,chgrp, chown,crontab,date, df,du, env, finger, ps,ruptime, shutdwon,stty, who.

At command.
at command along with crontab command is used to schedule jobs.
at options time [ddate] [+increment] is syntax of at command.
for example if I have a script named usersloggedin which contains.
#!/bin/ksh
who | wc -l
echo "are total number of people logged in at this time."
and I want to run this script at 8:00 AM. So I will first type at 8:00 %lt;enter>
usersloggedin %lt;enter>
I will get following output at 8:00 AM
30
are total number of people logged in at this time.
Options:
• -f file will execute commands in a file.
• -m will send mail to user after job is completed.
• -l will report all jobs that are scheduled and their jobnumbers.
• -r jobnumber will remove specified jobs that were previously scheduled.

Chmod command.
chmod command is used to change permissions on a file.
for example if I have a text file with calender in it called cal.txt.
initially when this file will be created the permissions for this file depends upon umask set in your profile files. As you can see this file has 666 or -rw-rw-rw attributes.

ls -la cal.txt
-rw-rw-rw- 1 ssb dxidev 135 Dec 3 16:14 cal.txt
In this line above I have -rw-rw-rw- meaning respectively that owner can read and write file, member of the owner's group can read and write this file and anyone else connected to this system can read and write this file., next ssb is owner of this file dxidev is the group of this file, there are 135 bytes in this file, this file was created on December 3 at time16:14 and at the end there is name of this file. Learn to read these permissions in binary, like this for example Decimal 644 which is 110 100 100 in binary meand rw-r--r-- or user can read,write this file, group can read only, everyone else can read only. Similarly, if permissions are 755 or 111 101 101 that means rwxr-xr-x or user can read, write and execute, group can read and execute, everyone else can read and execute. All directories have d in front of permissions. So if you don't want anyone to see your files or to do anything with it use chmod command and make permissions so that only you can read and write to that file, i.e.
chmod 600 filename.

Chgrp command.
chgrp command is used to change the group of a file or directory.
You must own the file or be a superuser.
chgrp [options] newgroup files is syntax of chgrp.
Newgroup is either a group Id or a group name located in /etc/group .
Options:
• -h will change the group on symbolic links.
• -R recursively descend through directory changing group of all files and subdirectories.

Chown command.
chown command to change ownership of a file or directory to one or more users.
Syntax is
chown options newowner files
Options
• -h will change the owner on symbolic links.
• -R will recursively descend through the directory, including subdirectories and symbolic links.

Crontab command.
crontab command is used to schedule jobs. You must have permission to run this command by unix Administrator. Jobs are scheduled in five numbers, as follows.
Minutes 0-59
Hour 0-23
Day of month 1-31
month 1-12
Day of week 0-6 (0 is sunday)
so for example you want to schedule a job which runs from script named backup_jobs in /usr/local/bin directory on sunday (day 0) at 11.25 (22:25) on 15th of month. The entry in crontab file will be. * represents all values.
25 22 15 * 0 /usr/local/bin/backup_jobs
The * here tells system to run this each month.
Syntax is
crontab file So a create a file with the scheduled jobs as above and then type
crontab filename .This will scheduled the jobs.

Date command.
Date displays todays date, to use it type date at prompt.
Sun Dec 7 14:23:08 EST 1997
is similar to what you should see on screen.

Df command.
df command displays information about mounted filesystems. It reports the number of free disk blocks. Typically a Disk block is 512 bytes (or 1/2 Kilobyte).
syntax is
df options name
Options
• -b will print only the number of free blocks.
• -e will print only the number of free files.
• -f will report free blocks but not free inodes.
• -F type will report on an umounted file system specified by type.
• -k will print allocation in kilobytes.
• -l will report only on local file systems.
• -n will print only the file system name type, with no arguments it lists type of all filesystems

Du command.
du command displays disk usage.

Env command.
env command displays all the variables.

Finger command.
finger command.

PS command
ps command is probably the most useful command for systems administrators. It reports information on active processes.
ps options
options.
• -a Lists all processes in system except processes not attached to terminals.
• -e Lists all processes in system.
• -f Lists a full listing.
• -j print process group ID and session ID.

Ruptime command.
ruptime command tells the status of local networked machines.
ruptime options
options.
• -a include user even if they've been idle for more than one hour.
• -l sort by load average.
• -r reverse the sort order.
• -t sort by uptime.
• -i sort by number of users.

Shutdown command.
Shutdown command can only be executed by root. To gracefully bring down a system, shutdown command is used.
options.
• -gn use a grace-period of n seconds (default is 60).
• -ik tell the init command to place system in a state k.
o s single-user state (default)
o 0 shutdown for power-off.
o 1 like s, but mount multi-user file systems.
o 5 stop system, go to firmware mode.
o 6 stop system then reboot.
• -y suppress the default prompt for confirmation.

Stty command
stty command sets terminal input output options for the current terminal. without options stty reports terminal settings.
stty options modes < device options • -a report all options. • -g report current settings. Modes • 0 hang up phone. • n set terminal baud. • erase keyname, will change your keyname to be backspace key. Who command who command displays information about the current status of system. who options file Who as default prints login names of users currently logged in. Options • -a use all options. • -b Report information about last reboot. • -d report expired processes. • -H print headings. • -p report previously spawned processes. • -u report terminal usage. Advance unix command concepts Put advance commands utilities, redirection, etc here. cal > cal.txt To create a new file called cal.txt that has calendar for current month. > sign redirects output from stdout (screen) to a file.

Unix fundamentals

System V Unix operating systems was developed by AT&T bell labs and it is the most widely used Unix operating systems. An operating system is that piece of software which lets you interact with hardware in your computer. For example, when to call CPU, when to store in Memory, when to read from Disk , how to connect to outside world is all being done on any Operating systems in any computer at all the time, oblivious to the user. Then this operating systems is put in a package before selling to us, just like when you buy chocolates. The package around which this operating systems is wrapped is called User Interface in computing terminology. Some developers like Microsoft spend more time on developing this user interface than the real operating systems, like Windows 95, others like Sun solaris had spend more time on reliability and strength of the operating systems rather then how user interacts with it. That's the big difference between Unix and Windows 95 (and all the other microsoft products). Unix is more powerful, more reliable, can do much more work, much faster and you do not need to reboot your computer everyday. Only problem is that many people get put off by the command line user interface. But things are changing now and even unix has its own version of X windows. Learning different command on Unix is quite an experience. Unix operating systems uses many different user interfaces depending upon the user, different command line interfaces are called Shells, you can use Ksh (korn shell), Bash, (bourne Again Shell), csh (C shell), etc.
The core of unix is called kernel. Kernel interacts with hardware, software and user interface (i.e. Shell). When you enter a command to add two numbers, kernel converts the ascii english like command to the binary language of central processing unit and then pass these binary bits of 1's and 0's to cpu byte by byte which then processes and give back the answer to kernel and kernel sends it out to standard output (screen) after converting them back to decimal number notation which we all use.
In this document all the commands that appear in greenish blue color you can type and use in your Unix session.
The Basics
How do I login to Unix system?
You need to have an account created by unix administrator for that particular system. For example if you want to login to unix systems named punjab1., open up a new session to punjab1 and at prompt enter your user name and password as supplied by Administrator.
What do I do after login?
Once logged in, you will see a shell prompt, actually a blank screen with on blinking cursor, that means you are ready to enter your commands. Here you can use These basic unix commands. For more information about that command you can use online help by typing man man. $ sign means shell prompt so you do not need to enter $.


Some common problems
One of the first common problem is incorrect TERM variable. To make sure that your terminal is set to correct emulation check your emulation by cal command which displays calendar for current month. Type cal at command line.
December 1997
S M Tu W Th F S
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 29 30 31
If you did not see nice and formatted like above then probably you need to set your terminal emulation.

To find out what your terminal is set to.
$echo $TERM
vt100
(this is what you should get back, vt100 works well with ibm PCs)

To see what shell you are using echo $SHELL
/bin/ksh
is what you will get if using korn shell,
/bin/csh
if using c shell. You default login files if you are using korn shell are .profile and .kshrc and for c shell are .login and .cshrc. You can edit these files to put any additional variables you like to set when logging in .

To make your backspace key an erase key.
stty erase backspace key

To set terminal emulation to vt100 if using ksh
export TERM=vt100
if using csh
setenv TERM vt100
Other conecpts
What are files?
The bits and bytes of data represented in electronic flip and flops are files. For example, an ascii character of A is represented by 41H or 0100 0001. Which is interpreted by CPU in the time period as one low one high one low one low one low one low one low one high. So here code for A which is 41 (in Hex) is actually one byte, since a 0 or 1 is one bit and one byte equals 8 bits.
Two types of files exist in computing world, Ascii and Binary. ASCII is portable across many different operating systems (or platforms as some people call) it is a standard and its full form is American Standard Code for Information Interchange. Binary files depends upon the application on which it is used. For example this document you are reading is an ASCII file while the pictures you are seeing are binary files cause pictures depends upon few formats like gif or jpg which can be interpreted by the browser (Netscape, IE Explorer). So while transferring files from one system to another, using binary mode is safer, since bit by bit is transferred. As you are reading this document which is called index.html it is using ASCII characters with references to binary picture files and other html ASCII files here and there.
Then there are permissions on each of these files which are divided into your permissions, your group's permissions, rest of world permissions, and extra permissions (sticky bit, suid bit, etc).
I am going to create a new file using cal command which displays calendar and instead of seeing it on the screen I will put the output in a file called cal.txt using redirection > symbol.
cal > cal.txt
Now to see this file and permissions on it I will use ls command with -la option.
ls -la cal.txt
-rw-rw-rw- 1 ssb dxidev 135 Dec 3 16:14 cal.txt
In this line above I have -rw-rw-rw- meaning respectively that owner can read and write file, member of the owner's group can read and write this file and anyone else connected to this system can read and write this file., next ssb is owner of this file dxidev is the group of this file, there are 135 bytes in this file, this file was created on December 3 at time16:14 and at the end there is name of this file. Learn to read these permissions in binary, like this for example Decimal 644 which is 110 100 100 in binary meand rw-r--r-- or user can read,write this file, group can read only, everyone else can read only. Similarly, if permissions are 755 or 111 101 101 that means rwxr-xr-x or user can read, write and execute, group can read and execute, everyone else can read and execute. All directories have d in front of permissions. So if you don't want anyone to see your files or to do anything with it use chmod command and make permissions so that only you can read and write to that file, i.e. chmod 600 filename.