Compiled By: Udhaya Kumar.V
Document   : Tutorial for Unix Architecture & Commands
Date       : April – 2004
Contact    : URL: http://www.udhaya.com , Mail Id: [email protected]

 

Hai, This tutorial specking about Unix features, architecture, file system architecture, commands, vi editor, system administration and job scheduling. It’s very simple way of studying about Unix. I have compiled the information for beginners to Unix. This document not contains all the options of the command. It’s having very important commands and options.

 

What is operating system?

 

An operating system is the program that controls hardware and software. It’s providing the interface to access the hardware resource through the application. OS reduce the end user work for handling hardware. Basic work for OS is Process Management, Memory Management and IO handling.

 

History of Unix:

 

Unix was developed in AT&T Bell Labs. Dennis Ritchie and Ken Thompson released first version of UNIX. This version written in C language and some of the low level interaction written in assembly language.

 

Features of Unix

 

Portability: we can install the Unix for micro, mini and mainframe computers. Unix Os having hardware compatibility.

Modularity: we can modify the OS for our requirement, but it’s not affect the OS architecture and functionality. We can remove some of the unwanted functionality same as we can add more feature in existing OS itself.

Multi Process: At the same time we can run any number of the process under the processor. Virtually Unix running more then one process under one processor. This is handled based on round robin method.

Multi User: Unix system handle more then one user at the same time.

Security: Unix provides different type of the security. Like User level, file level, process level, memory level, hardware resource level. It’s provides the centralized security system.

Communication: Unix provides different type of the communication. Like mail, chat, wall messages.

Net Working: Unix provides some of the basic protocol to interact with external resource. Like TCP/IP, RPC, Telnet, etc

Open System: any external channel can interact with Unix through TCP/IP protocol. This is very basic interface for Unix.

Library: Unix provides development environment for different software. It’s provides some base libraries for development.

 

Unix Architecture

 

Unix is having Layered based architecture. It’s having three important layer 1. Kernel 2. Shell 3. Application & User

 

1.Kernel

This is the first layer in Unix System to interact with Hardware. It’s called as heart of the OS. Basic work of the kernel is process scheduling, memory managing and hardware interaction. Kernel can interact with the hardware through device drivers.

 

2.Shell

This is called as Command Interpreter. Interface between Kernel and User. Unix having different type of the Shell, every shell having unique feature.

 

3.User & Application

User interacts with the Unix system through Shell. All the application also running in this layer.

 

More About Shell                

Whenever we login to a Unix system we are placed in a program called the shell. Because, every unix user id bind with any specific shell. Once successfully logged in the Unix System, we can get the prompt in the screen. Now our shell is ready for user interaction. Some of the prompt like $, %, #, etc

 

Several shells are available in UNIX. Some of the list

 

Bourne shell (sh).

C shell (csh).

TC shell (tcsh).

Korn shell (ksh).

Bourne Again SHell (bash).

 

We can switch between the different shells once we have found out if they are available.

 

Bourne shell (sh):

 

This is the original Unix shell written by Steve Bourne of Bell Labs. It is available on all UNIX systems.

This shell does not have the interactive facilities provided by modern shells such as the C shell and Korn shell.

The Bourne shell does provide an easy to use language with which you can write shell scripts.

 

C shell (csh):

 

This shell was written at the University of California, Berkeley.

It provides a C-like language with which to write shell scripts - hence its name.

 

Korn shell (ksh):

 

This shell was written by David Korn of Bell labs.

It is now provided as the standard shell on Unix systems. It provides all the features of the C and TC shells.

 

Bourne Again SHell (bash):

 

This is a public domain shell written by the Free Software Foundation under their GNU initiative.

This shell is widely used within the academic community. bash provides all the interactive features of the C shell (csh) and the Korn shell (ksh). Its programming language is compatible with the Bourne shell (sh).

 

UNIX file system

 

A file system is a logical method for organizing and storing large amounts of information in a way which makes it easy manage. The file is the smallest unit in which information is stored.

Structure of the File system.

 

The UNIX file system is organized as a hierarchy of Directories. Starting from a single directory called root which is represented by a / (slash). Imagine it as being similar to the root system of a plant or as an inverted tree structure. Immediately below the root directory are several system directories that contain information required by the operating system.

About File system Hierarchy:

 

/(root) - The directory located at the top of the Unix file system. It is represented by the "/" (forward slash) character.

/bin - This directory contains the commands and utilities that you use day to day. These are executable binary files.

/dev - This directory contains special files used to represent real physical devices such as printers and terminals.

/etc - This directory contains various commands and files which are used for system administration.

/lib - This directory contains libraries that are used by various programs and languages.

/tmp- This directory acts as a "scratch" area in which any user can store files on a temporary basis.

/usr - This directory contains system files and directories that you share with other users. Application programs, on-line manual pages, and language dictionaries typically reside here.

/home - This directory contains a home directory for each user of the system.

 

Standard File System

 

Unix system having some standard file systems, Every Unix system having this file system

 

Root File System

/bin, /etc, /dev, /lib

Boot File System

/stand, /unix

Swap File System

            /swap

User File System

/home, /tmp, /var

 

File System Configuration Files

 

/etc/vfstab

Every file system contains one entry in this file. This file contain file system configuration information

/etc/mnttab

            All the mounted file system information available in this file

/etc/default/fs

            Default file system configuration information available in this file. Example: LOCAL=ufs

 

File System Layout

 

Boot Block:

             This block Occupies the beginning(First sector) of a file system. It’s contains the Boot Strap code.

Super Block:

             This Block Contains State of the file system, File Size, free spaces, number of inodes, number of disk blocks etc.

Inode Block:

             This Block Contains List of inodes. The administrator specifies Inode List Size during configuration of the file system.

Data Block:

            This Block Contain file and administrative data

 

Types of Files:

 

Ordinary files:

This is the type of file usually used to store the information, such as some text, image,etc. Any file is always contained within a directory.

 

Directories:

A directory is a file that holds other files and other directories.

 

Special files:

This type of file is used to represent a real physical device such as a printer, tape drive or terminal.

 

What Is a Process?

 

A program execution called as Process. Has a series of bytes that the CPU interprets as instruction, Kernel loads the executable file into memory

The loaded process contains 3 regions text, data and stack. Can run in 2 modes Kernel mode and User mode

About Processes

Each process created on the system has a unique number, known as its PID, associated with process. When you login to the system a process is started to run your shell program. New processes that are started from within your shell such as entering a command are the children of this process. A process can have many children, but only one parent. Kernel Process table contains process entries.

 

Some Basic Process List

 

Process Id 0 - Swapper, Scheduler process, system process

 

Process Id 1 - Init process, invoked by the kernel at the end of bootstrap procedure, never dies, normal user process.

 

Process Id 2 - page daemon process (on virtual memory implementation), kernel process, support paging of virtual memory.

 

How will log in System?

 

Using telnet protocol, we can communicate with Unix system. Example telnet <ip/hostname>. We get the “login:” prompt for enter the login, after get the “password:” prompt, we have to enter password.

 

After successful log in to the system, user placed in home directory. Shell initializes the environment variable for every user. this information configured by user using profile file.

 

Some Environment Variable

 

PATH               = The search path for shell commands

TERM               = The terminal type (sh and csh)

DISPLAY         = X11 - the name of your display

LD_LIBRARY_PATH  = Path to search for object and shared libraries

HOST               = Name of this unix host

PRINTER         = Default printer (lpr)

HOME             = The path to your home directory (sh)

SHELL             = Default Shell

TZ                     = Time Zone

 

Set the environment variable using commands

 

env = provides current shell environment variable list

$env

 

export = update the environment variable in current shell

$ export PS1=“Hai ..”

$ export PATH=$PATH:/usr/oracle/bin:

$ export SHELL=/usr/bin/sh:

 

unset = delete the environment variable from shell list

$unset MYPATH

 

We can change the environment setting using special file. This files is referred by shell at the startup time. This startup file is differed based on the shell type. Default this special file is available in user home directory.

 

Some of the special file follows

C Shell             = .cshrc

Bourne Shell     = .profile

Korn Shell        = .profile

BASH              = .bashrc

 

Some of the Shell name follows

 

sh         = Bourne shell

csh       = C shell

tcsh      = TC shell

ksh       = Korn shell

bash     = Bourne Again Shell

 

Login Process:

 

“getty” is a process for assign the terminal to the login requester. Login and Password verified by “login” process. Login process referred “/etc/passwd” for user verification and “/etc/shadow” for password verification. Once this “Login” process is succeed then corresponding shell is invoked. Now shell is set the environment for user based on special file (.profile). After that user get the prompt to work.

 

About Unix Process

 

Daemon Process

 

Zombie Process

 

 

Orphan Process

 

What happens to the child process when the parent process terminates before the child process?

 

 

Unix Basic Commands

 

Command syntax rules

 

cp [-iprR] filename ... directory.

 

 

Online Manual Command

 

$man cp

-The command “man” gives you access to an on-line manual containing a complete description of every command available on this system.

 

$man –k keyword

-Gives the manual based on the keyword

 

Locating Commands

 

which - Locate a command path and display its pathname or alias

 

$ which cd

cd: shell built-in command.

 

$ which cp

/bin/cp

 

type - write a description of command type

 

$ type cd

cd is a shell builtin

 

Switch Between User

su - If you have more than one account on the system and want to switch to the other user use command

 

$ su username

-You are still in the same working directory you were when you issued the command, but you now have access to the file system for your other account. To stop using this account enters the command exit.

 

Short hand for home directories

- The (~) tilde character can be used to refer home directories. Eg. cd ~/arun takes us to arun home directory. Paths can also be specified in this fashion.

 

pwd - Command to display the Present Working Directory

$ pwd

/home/helper

 

$su projX

Password: (password for account projX)

 

$whoami (command to display the username)

projX

 

cd - Command to Change Directory . A cd without and parameters takes you to the home

$cd c

 

System identity Commands

 

uname - Display system name and operating system release.

-a  Prints basic information currently available from  the system.

-i   Prints the name of the hardware implementation  (plat- form).

-X Prints expanded system  information,  one  information

 

hostname - Show the name of this host.

 

domainname  - Show the name of the local NIS domain.

 

tty  - return user's terminal name

     

ifconfig - configure network interface parameters.

-a  Apply the commands to all interfaces in the system

 

Show other users logged on

 

finger - Show who is logged onto this and other systems.

 

who - List of users logged into this system.

 

w - Long list of who is logged onto this system and what they are doing.

 

Handling Files

 

mkdir <dir name> - make directories

rmdir <dir name>  -  remove directory entries

cat <filename> - concatenate and display files

cp <source> <Target> - copy files

 -r    copy  the  directory  and  all  its files, including any subdirectories and their files to target.

 -i    Interactive. cp will prompt for confirmation

mv <source> <target> - move files

 -f    mv will move the file(s) without prompting

 -i    mv will prompt  for  confirmation

more - browse or page through a text file

rm - Remove directory or file

-r   Recursively remove directories and  subdirectories

 

List the files

 

ls - list contents of directory

-a    Lists all entries, including those that begin  with  a dot (.), which are normally not listed.

-F   Marks directories with a  trailing  slash  (/),

-i     For each file, prints the i-node number in  the  first column of the report.

-l    Lists in long format,

-R  Recursively lists subdirectories encountered.

-t    Sorts by time stamp (latest first) instead of by name.

-r    Reverses the order of sort to get  reverse  alphabetic

-x    Multi-column output with entries sorted across  rather than down the page.

 

Granting Access Permission

 

Every file and directory in your account can be protected from or made accessible to other users by changing its access permissions To display the access permissions of a file or directory use the command:

 

$ ls -l file1

-rw-r--r--           2         unixjohn         doc        3287        Apr 8 12:10       file1

 

There are three types of permissions:

 

r read the file or directory.

w write to the file or directory.

x execute the file or search the directory.

 

Each of these permissions can be set for any one of three types of user:

u the user who owns the file (usually you)

g members of the group to which the owner belongs

o all other users

 

The access permissions for all three types of user can be given as a string of nine characters:

User              group        others

r w x             r w x        r w x.

 

chmod mode filename - Changing access permissions

chmod mode directory_name.

 

+ add the specified permission.

- subtract the specified permission.

= assign the specified permission, ignoring whatever may have been set before.

 

To give yourself permission to execute a file that you own:

chmod u+x file1

 

To give members of your group permission to read a file:

chmod g+r file2 

 

To give read permission to everyone for a particular type of file:

chmod a+r *.file

 

To give the group write and execute permission

chmod g+wx $HOME/FILE

 

chown [ -fhR ]  owner  [  :  group  ]  file ... - change file ownership

 

chgrp [ -fhR ]  group  file ...  -  change file group ownership

 

Important Keys

 

CTRL-S

                        Stops scrolling of screen output

CTRL-q

                        Resumes scrolling of screen output

CTRL-U

                        Kill command line without executing it

CTRL-C

                        Interrupt or break key. Sends signal 15 to a process.

CTRL-D

                        Terminates Login Session (exit)

CTRL-Z

                        Suspend the present process, but do not destroy it.

CTRL-J

CTRL-M

                        Alternative to enter

                       

Redirection Operator

 

>   redirect out put

$ cat > file1  , > file2

$ cat file1 2> error > logfile

 

>>  append out put to file

$cat file1 >> file2

 

<   redirect input

$ wc < file1

 

|  Pipe Out Put

$ who | wc –l

tee  replicate the standard output

$ who | tee users

&  run process in background

$ pop3.sh &

 

Wild Card Characters

 

`?‘ - Match single character.

            e.g. ls /etc/rc.????

`*' - Match any number of characters.

            e.g. ls /etc/rc.*

`[...]' - Match any character in a list enclosed by these brackets.

            e.g. ls [abc].C

[!nnn] - matches any character that is not enclosed.

[n-m]  - matches any character in this range.

 

Miscellaneous Commands

 

date - Print the date and time.

bc - Text-based calculators.

cal - display a calendar.

touch - Creates an empty new file if none exists, or updates date and time stamps on existing files.

file  <File name>

lp, lpr - Line printer. Send a file to the default printer, or the printer defined in the `PRINTER' evironment variable.

lpq, lpstat - Show the status of the print queue.

 

Alias Commands

 

alias dele='rm -i.‘

alias l=‘ls –al’

dele memo.txt

 

$ alias aliasname - To check what command is aliases to an alias name type

$ alias  - To list all aliases type

$ unalias aliasname - To remove alias use command

 

Communication Commands

 

write - Send a simple message to the named user, end with CTRL-D. The command `mesg n' switches off messages receipt.

talk - Interactive two-way conversation with named user.

mail - The standard (old) mail interface.

 

$ mailx -s "Test mail“ [email protected]

TEst msg

.

EOT

 

wall - write to all users

 

Disk Usage

 

du  - summarize disk usage

-k  Write the files sizes in units of 1024  bytes,  rather than the default 512-byte units.

-s    Instead of the default output, report only  the  total sum for each of the specified files.

 

df  - displays number of free disk blocks and files

-a    Report  on  all  file  systems  including

-b    Print the total number of kilobytes free

-e    Print only the number of files free

-v    complete set of file system specific  command lines

 

Process Commands

 

ps - report process status

-a Lists information about all processes most  frequently requested

-f Generates a full listing

-e Lists information about every process now running

-l  Generates a long listing.

 

$ ps –ef

$ ps –el

 

kill - terminate or signal processes

Kill <signal> <pid>

 

$kill –9 1020   # kill the 1020 pid process

$kill –9 0         # Kill all process including the login shell

 

System Statistics Commands

 

vmstat - List kernel virtual-memory statistics

$vmstat

 

netstat - List network connections and statistics

$netstat -a

 

rpcinfo - Show rpc information

$rpcinfo

 

showmount - Show clients mounting local file systems

$showmount

 

ipcs - inter-process communication report

$ipcs

 

ipcrm - remove a message queue,  semaphore ,  shared memory

 

ping - send ECHO_REQUEST  packets  to  network hosts

 

$ ping India.com

 

No Hang Up command

 

nohup - run a command immune to hang ups

 

nohup sh [file]

 

$ nohup ComServer &     #nohup.out the output file

$ nohup ComServer comlog &  #comlog is the out file

 

History Commands

 

history - process command history list

 

hash - evaluate the internal  hash table of the   contents of directories

 

last – display login and logout information about users  and terminals

 

Line, Word, Character count Commands

 

wc - command counts the number of words, characters and lines in a file. By using a different option you can choose what is counted.

wc -w file1 counts the words.

wc -c file1 counts the characters.

wc -l file1 counts the lines.

 

Link Commands

 

Hard link

ln <source File> <Target File> - Hard links

$ ln systemlog log

 

Symbolic Link (Soft Link)

ln –s <source> <Target> - Soft links

$ ln –s systemlog /nformix/log/sys

 

Cut & Transfer Commands

 

cut - cut out selected fields of each line of a file

cut -c list  [ file ... ]

cut -f list  [ -d delim ]

$cut –d”|” –f2 emp.dat

 

tr - translate characters

tr [options] expression1 expression2

-s   replace single character

$ ps -ef | tr -s " "

$ ps -ef | tr -s " " | cut -d " " –f3

 

Head & Tail Commands

 

head - display first few lines of files

head [ -number ]  [ filename ...]

$head file1 $head -5 file1

 

tail - deliver the last part of a file

tail [ +- number ]  [ file ]

-f    Follow

 

$tail -5 syslog  #last 5 lines

$tail +5 syslog  #start with 5 th line to EOF

$tail -f syslog   #monitor the growth of the file

 

Editor - vi - Text Editor

 

Syntax: “vi filename”

$ vi <file Name>           # open the given file

$ vi +<Line Number> <File Name>      #open the given file and place the cursor in given line Number.

 

Commands

 

a - Insert text after the cursor                                       

i  - Insert text before the cursor                                                

A - Append text at the end of the current line               

I - Insert text at the start of the current line                    

o  - Open a new line below the current line                               

O  - Open a new line above the current line                              

 

Saving and Quitting

ZZ or  :wq - To quit and save the contents of the buffer to the file

:q - quit

:q! – quit without saving the contents of the buffer to the file

:w filename - Save the contents of the buffer to a new file

 

Cutting and Pasting

yy - yanks the current line into the buffer.

p - places the yanked text after the current cursor position.

 

Delete Text

x - to delete the current character.

dd  - to delete the current line.

dw  - to delete the current word.

d$  - to delete till end of line from cursor.

d0  - to delete till beginning of line from cursor.

5dw - deletes the current word and the following four words.

 

Searching Text

Press <ESC>

“/pattern” - to forward search for a pattern

“?pattern” - to backward search for a pattern

“n” to repeat last search

“N” to repeat last search backward

 

Command Line

:g/pattern1/s//pattern2/g replace all occurrences of pattern1 with pattern2

:1,100 s/pattern1/pattern2/g for line 1 to 100, substitute pattern1 for pattern2

:1,$ s/pattern1/pattern2/g for all lines substitute pattern1 for pattern2

:10,20d delete lines 10 through 20

:10,20y yank lines 10 through 20 to the buffers

:1,5p display 1 through 5 lines

:20 cursor got to 20 the line

 

Navigation

h - Cursor Left, l - cursor Right, k – up,  j - down

b - back word wise,  w - forward word wise

 

<Ctrl-f> Scrolls full page forward

<Ctrl-b> Scrolls full page back word

<Ctrl-d> Scrolls half page forward

<Ctrl-u> Scrolls half page backward

 

.exrc file configuration

 

set showmode      # see the mode

set shownumber   # see the number

set ts=2                            # set the tab space

map #1 :!cc %       # map the F1 key

abbr inc #include <stdio.h>  # add abbreviation

 

Regular Expression

 

`.' Match any single character except the end of line.

`^‘ Match the beginning of a line as the first character.

`$' Match end of line as last character.

`[..]' Match any character in the list between the square brackets

`*' Match zero or more occurrences of the preceding expression.

`+‘ Match one or more occurrences of the preceding expression.

`?' Match zero or one occurrence of the preceding expression.

 

[...] matches any of the enclosed characters

[^...] matches any character that is not enclosed

[n-n] matches any character in this range

* matches any number of the preceding character

 

Search Commands

 

grep  [-bchilnsvw ] limited-regular-expression [ filename ... ]

-l Print only the names of files with matching lines

-v Print all lines except those that contain the pat-tern.

-n Precede each line by its line number in  the file

 

$ls -l | grep '^d........x.‘

lists all the directories in the current directory for which other users have execute permission.

$ls -l | grep '[^.xdh]$.‘

lists all the files and directories in the current directory which do not end in .xdh.

$grep –n “sys” serverlog

 

find - find a files

 

find path ...  Expression

 

-name pattern select file filename

-atime n  the file's data was accessed n days ago

-mtime -n  the file's data was modified les then n days

-print current  path  name  to  be printed

-type c type of the file is c, [b, c, d, f,  l,  p,  or s ]

-links n  True if the file has n links.

-size n[c] the size is in bytes

-exec command   execute unix command

-ok command  Like –exec. Ask confirmation

 

$find . -name '*.fm' -print  -searching using wild cards. Quotes is mandatory

 

$find ./ -size +1024 -print

 

$find /usr/local -name gnu -type d –print   -searching for a directory

 

$find $HOME \( -name a.out -o -name '*. \) \  -atime +7 -exec rm {} \;

 

$find . -name SCCS -print

 

Sort Command

 

sort filename.

 

sort +2 -3 names  - This sorts the file names on the third word of each line).

sort -o results +3 -5 scores  - sorts on words 4 and then on 5

 

-d (Dictionary order) sort only uses numbers, letters and blank spaces when sorting the file.

-f (Fold in lower case) sort treats all lower-case letters as if they were upper-case letters.

-i (Ignore non-printing characters) sort ignores any characters that do not print.

-n (Numeric order) sort recognizes the value of numbers and sorts them in terms of their value.

-r (Reverse order) sort reverses its default sort order.

-t option to specify another character to act as the field delimiter.

 

Different & Unique command

 

diff - command can be used to compare two files.

diff -iw part1 part_one

 

-iw - makes it ignore case and also white spaces.

 

uniq -  Unique To remove duplicate lines from a file

uniq in_file out_file.

 

Compress Utility

 

compress <option> <File Name> - Compress the file

 

$ compress comserver.tar

 

uncompress <File Name> - Uncompress the file

 

$uncopress comserver.tar.Z

 

zcat <File Name> - display the compressed file content

 

$zcat comserver.Z

 

pack, pcat, unpack - compress and expand files

 

pack file ...

pcat file ...

unpack file ...

 

Pack the file

$pack comserver

 

Unpack the file

$unpack comserver.z

 

display the compressed file content

$pcat comserver.z

 

tar  - Tape Archive Command

 

tar - create tape archives and add or extract files

tar [options] [file]

 

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:

f - uses path name.

b n - use blocking factor of n.

l - print error messages about links not found.

v  - list file in long format ( verobse option )

w  - confirm from user for any action.

 

$tar cvf server.tar server1.txt server2.txt

$tar cvf server.tar servre_dir

$tar xvf server.tar

$tar cvf /dev/rdsk/f0q18dt /home/informix   #taking backup

$tar xvf /dev/rdsk/f0q18dt                           #restore the file

$tar tvf /dev/rdsk/f0q18dt                            #Display archive

$tar uf /dev/rdsk/f0q18dt ./query.sql           #Append archive

$tar xvwf /dev/rdsk/f0q18dt ./query.sh       #interactive

                        /etc/default/tar         #device identify KEY

$tar cv6 server_code

$tar xv6

 

Formatting floppy diskettes

 

format  & fdformat   #  format the floppy default

 

$format            #SCO Unix, etc

$fdformat         #Linux

 

Handling DOS Diskettes

 

$dosformat a:       #dos format

$doscp ip.dat a:

$dosdir a:                       # List files

$dosrm a:ip.dat   # Remove ip.dat from floppy

$dosmkdir a:bin  # Create directory in Floppy

$dosrmdir a:bin   # delete directory from floppy

$mcopy ip.dat /dev/fd0H1440:/ip.dat    #Linux

 

File System Command

 

fdisk - create or modify fixed disk partition table

mkfs - construct a file system

$ mkfs –F minix /dev/sdb2

 

fsck - check and repair file systems

fsck <Device>

$ fsck /dev/vx/dsk/source

 

mount, umount - mount or unmount  file  systems

mount   [-F FSType]    <Device> <mount_point>

$ mount /dev/fd0 /mnt

umount <mount_point>

$ umount /mnt

mountall, umountall - mount, unmount multiple file systems

$ mountall

$ umountall

 

Running Jobs Periodically

 

The ‘cron’ command starts a process that executes commands at specified dates and times. Regularly scheduled commands can be specified according to instructions found in crontab files in the directory /var/spool/cron/crontabs. Users can submit their own crontab file using the crontab command. /etc/cron.d is main cron directory.

 

Crontab Entry Format, A crontab file consists of lines of six fields each. Spaces or tabs separate the fields.

 

minute (0-59),

            hour (0-23),

            day of the month (1-31),

            month of the year (1-12),

            day of the week (0-6 with 0=Sunday),

 

-e  - Edit crontab file

-l   - list the crontab file for the invoking user

-r   - remove a user's crontab from the crontab directory.

 

$crontab crontabfile    # submit the job to cron

$crontab –l                   # list the current crontab entries

$crontab –r                  #delete your file

$crontab –r username  #delete any user crontab file

 

Cron Samples

 

15 4 * * * /usr/local/bin/geterror > /usr/log/geterror.log 2>&1

0 1 * * * /usr/local/bin/log > /usr/log/log.err 2>&1

0 3 * * 0 /usr/local/bin/clientlogs.sh > /dev/null 2>&1

0 3 * * * /usr/local/bin/batch.sh /usr/local/bin/batch_param

15 3 * * 1-5 find $HOME -name core 2>/dev/null | xargs  rm -f

 

User Admin

 

useradd - administer a new user login on the system

-c comment

-d dir  The home directory of the new  user.

-g group existing group's  integer  ID  or  character-string name.

-s shell Full pathname of the program used as the user's  shell.

-u uid The UID of the new user

 

$useradd –d /home/user1 –g dba –c “Informix” –s /bin/ksh user1

 

usermod - modify a user's login information on the system

$usermod –s /bin/sh user1

 

userdel - delete a user's login from the system

$userdel user1

 

Internet Daemon

 

inetd, inetd.conf - internet ``super-server''

 

Configuration FILES

 

/etc/inetd.conf configuration file for all inetd provided services

            #  <service_name> <socket_type> <proto> <flags> <user> <server_pathname> <args>

/etc/services service name to protocol and port number mapping

/etc/protocols protocol name to protocol number mappings

/etc/rpc Sun-RPC service name to service number mappings.

 

Default RPC Services

 

rlogin - remote login

 

rsh - remote shell

 

rcmd -  routines for returning a stream to a remote command

 

rcp - remote file copy


 

Hosted by www.Geocities.ws

1