0% found this document useful (0 votes)
448 views290 pages

(123doc) - Nc2000-System-Operation-Manual-Vol4

gsdfgsgfsd gsdfg sgf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
448 views290 pages

(123doc) - Nc2000-System-Operation-Manual-Vol4

gsdfgsgfsd gsdfg sgf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 290

Maintenance Manual of

NC2000 computer monitoring system

(V2.0)

Maintenance Manual IV

State Network Research Institute, Nanjing Automation Research

Institute of Automatic Control


NARI, Nanjing Automation Co., Ltd.

June 2006
Copyright Notices

The copyright of "NC2000 computer monitoring system user manual" is belonded


to NARI,Nanjing Automation Co., Ltd.. Without the written permission of NARI,
Nanjing Automation Co., Ltd., everyone shall not copy or spread any part of this
manual in any form, using any means (electronic or mechanical, including
photocopying or recording), or for any purpose.

, is the registered trademark of Nanjing NARI Group

Corporation .
(c) Copyright 2004 is belonded to NARI, Nanjing Automation Co., Ltd.. All rights
are reserved, and all reproductions are rejected.
Preface

System software NC2000 is the power system computer control system software of
a new generation, which is completed and has accumulated the monitoring software
experience of many years, after NARI Access has been used in a number of power
plants in our country by NARI Nanjing Automation Co., Ltd.. The System introduces
CLINET / SERVER architecture and supports for different hardware, operating system
and relational database systems. Because the development approach is object-oriented
and covers both the design and development process, users can use it more conveniently
and intuitively.

The main objective of this manual is to enable users to fully grasp the
installation、usage、maintenance methods and procedures of NC2000 system. The user
manual is divided into four parts: the first volume introduces the installation process of
NC2000 and the operating system, including, and the installation and configuration
process of NC2000; the second volume is the user operation manual of NC2000 system
and introduces operation methods of NC2000 in details; the third Volume introduces
the usage of the configuration tool of NC2000 and the usage of the configuration
software which is united by NC2000 system; the fourth volume is the maintenance
manual of the system and introduces all aspects which need to be maintained and the
methods and procedures of maintance.

We hope that through this user manual, the readers can grasp the NC2000 system
and ensure the system to operate more securely, reliablely and stablely, and make
greater contribution to the automation construction of power systems.
Read Guide

Manual target
This volume is the fourth book of the use manual of NC2000 computer monitoring
system, and it is the maintenance manual of NC2000 system.

Reading object
This manual is writen by internal engineering and technology-based personnel in our
company and the computer monitoring system maintenance personnel of hydropower
plant. The manual uses Microsoft Word to typeset.

Manual constitute
This manual is composed by six chapter.
1. A brief description of the software architecture of NC2000 system.
2. Introduce the basic Linux/Unix command and Linux utility.
3. Introduce the Solaris system commands and tools when manage and maintain.
4. Introduce the command in Windows platform in common use.
5. The tutorial of MySql relational database management and maintenance.
6. The technical of import and exportp of oracle relational database and the
introduction of the maintenance tool of Sqlplus.

Handbook agreement
This manual keeps to the following agreement:
1. All the headings is in bold type.
2. If the title followed by a "conditions", it means that the content behind the heading
required by the body is necessary under certain conditions.

【Note】 That means readers should pay attention to those which need to pay attention.
【Warning】 That means readers should pay attention to certain matters, otherwise they
will cause serious error.
Contents

Chapter I NC2000 Monitoring System Software..............................................................1


1.1 The Architecture of NC2000 Monitoring System Software................................1
1.1.1 Constitution of NC2000 monitoring system software.............................1
1.1.2 Directory of NC2000 monitoring system.................................................2
1.2 The background process of NC2000 monitoring and control system.................4
1.2.1 The running environment of background process....................................4
1.2.2 Background Process of Monitoring System...........................................10
1.2.3 The Data Stream of NC2000 System.....................................................15
1.3 The Communication Drivers of NC2000 System.............................................16
1.3.1 The Header File of NC2000 system Driver............................................16
1.3.2 The common NC2000 system communication driven library function. 20
Chapter II Functional Specification of Linux Operating System...................................43
2.1 Linux System Commands..................................................................................43
2.1.1 Commonly Used Command Explain of Linux System..........................43
2.2 utility Linux system tools..................................................................................77
2.2.1 RedHat Linux 9 package management tools..........................................77
2.2.2 users and configuration groups of RedHat Linux 9................................79
2.2.3 RedHat Linux 9 Network Configuration Computers need a network
connection to communicate with other computers. It is achieved by
recognizing the operating system interface card (such as: Ethernet card, ISDN
modems, token ring), and configuring the interface to connect to the network.
.........................................................................................................................91
2.2.4 Network File System (NFS).................................................................105
2.2.5 RedHat Linux 9 basic firewall configuration......................................113
2.2.6 The RedHat Linux 9 controlling of accessing to services...................122
Chapter III Utility of Solaris 9 Operation System.........................................................130
3.1 Solaris 9 System Commands..........................................................................130
3.1.1 boot command and parameters under the case of Solaris Unix OK...130
3.2 The Utility in Solaris 9....................................................................................154
3.2.1 Admintool tools....................................................................................154
3.2.2 program package command..................................................................161
3.2.3 Installation and Management of system patch.....................................177
3.3 Shell programming instructions......................................................................182
3.3.1 programme shell scripts........................................................................183
3.3.2 Reference table and script examples....................................................226
Chapter IV Practical Help of Windows Operating System...........................................240
4.1 DOS command................................................................................................240
4.1.1 Commands of directory operation........................................................240
4.1.2 Disk operation command......................................................................243
4.1.3 File operation commands.....................................................................247
4.1.4 Other commands...................................................................................252
4.2 Detail explain of utility command of windows...............................................254
4.2.1 explanation of network command........................................................254
4.2.2 Windows command Guinness..............................................................270
Chapter I NC2000 Monitoring System Software
1.1 The Architecture of NC2000 Monitoring System Software
1.1.1 Constitution of NC2000 monitoring system software
NC2000 system monitoring software is mainly omposed of two parts, the Front
Human-Computer Interaction program and Backgrounds background program.The
Human-Computer Interaction program mainly provides the screen display, reports,
briefings, and other interactive query curve graphic display and operating functions;the
Background program provides the communication between the computer monitoring
system and the external device, the management of NC2000 database,the management
of historical database and other kinds of background processes.The two programs
exchang of data through the way of multicast.

Figure 1-1
Because each node has different function,the required deployment of NC2000
system software are also different.The chart below shows the NC2000 system software
architecture:

1
Figure 1-2
The Human-Computer Interaction of program of NC2000 system procedures are
developed by Java.The class of inport is nc2000 ncconsole StartMenu,and after
starting, relating various functions of human-computer interaction by implementating
nc2000.ncconsole. Human-computer interaction of NC2000 system mainly include:
information of briefing, the screen showed ,list and Report inquiries, optical character
display, AGCAVC parameter query, editing of sequence control program, database edit
and so on.
At the node do not need to run the human-computer interaction should not run the
human-computer interaction process of NC2000 system.The communication among the
various nodes of NC2000 monitoring system, as well as external communications are
realized by the background context,and different roles of the computer nodes, the
deployment of background processes will be slightly different. The role of the
background process playing will be described in a special chapter.
1.1.2 Directory of NC2000 monitoring system
Directory of NC2000 monitoring system software is as follows:

2
Above all is a simple role of the directory and description.The follows is a function
indication specific documents of directory under certain commonly used directory .
1. ~ / data / resource directory.For example,when configurate communication drivers in
DB-databese of NC2000,and the driver name does not appear in the drop-down menu
list,you can manually edit the file in this directory, "drvlist.properties", in order to
adding new drivers at the end of the file.The format of the file can be defined as other

3
writed drivers.
2. ~ / data / sysfile directory.When start NC2000,the file “strategy”whice is under this
directory is a file that defind whice project to loating.The content of the file is the string
"xxx", that is the suffix of the
directory of project.
3. ~ / projects.xxx / db directory. The "config.sys" is the file whice read the
configuration of NC2000 system node.The "agc_ *.properties" is the default
configuration file whice the AGCAVC program has to read. "x.x.x.13. x." is the objects
script file of the DB-database,and is explained by the program "ooexpr".
4. ~ / projects.xxx / userinfo directory.The "defaultagcavc.properties" is the default
configuration file whice the AGCAVC program has to read, Recording the
number,name and other information of Plant Station which is managed by AGC, (text
file, you can manually edit). "Defaultrundsp. properties" record default screen file whice
can be start directly under the "screen" window "screen" menu bar after NC2000 system
starting, (text file, you can manually edit).
5. ~ / projects.xxx / XXX directory.XXX stands for a project name.The establishment of
XXX is required by the plant whice has many stations,and the graphics files and
sequence control program is placed in this directory.
6. ~ / ~ / projects.xxx / drvconfig directory.NC2000 system "Communication Interface"
function to generate The communication configuration file whice is generated by the
NC2000 system"Communication Interface" is stored in this directory.The file "xxx.txt"
is a text file whice contain configuration of the communications point ,and can be
opened by a text editor.
1.2 The background process of NC2000 monitoring and control system
1.2.1 The running environment of background process
To smoothly run NC2000 background process monitoring system, the minimum
configuration requirements are as follows:
850MHz Intel Pentium III processor or equivalent processor
512MB RAM

4
10GB free disk space
The minimum configuration mentioned here is required by only running the basic
background monitoring system NC2000 procedures.In the configuration of NC2000
monitoring system,Generally communications only the ommunications and the host do
not need to run the Front Human-Computer Interaction program. The communication is
only responsible for communication between NC2000 system and the external
system,and the background program running on it do not need to consume too many
resources,therefore the communication only has the general hardware configuration.But
as a host,the background process of NC2000 system need to deal with much more
complex data than communication, but also need to ensure that the system must run in a
security and stability status, so its hardware configuration is also much higher.Typically,
the running of NC2000 monitoring system requires the host minicomputer or server
configuration.
1.2.1.2 Software platform of NC2000 background program system execution
The of developmentNC2000 system background process are based on C-language
of Unix or Linux (compatible with standardized POSIX.1).Tested, the software
platforms whice is applicable to the background program of NC2000 including: RedHat
Linux 9, Sun Solaris 8, Sun Solaris 9 for Sparc, Sun Solaris 10 for Sparc and Sun
Solaris 10 for x64.To run the Front HCI of NC2000 system, also need to insall a Java
virtual machine that require higher version than JRE5.0.0_1.
1.2.1.3 The composition of the background program
The background program of NC2000 systems mainly includes the following programs:
dbload, client, server, red_m, mam, drvman and various types of driver, engine,
lsdmn, ooexpr, st_clock and so on.
1.2.1.4 Setting of Environment variable
For the smooth running of NC2000 monitoring system software, you need to
configurate some parameters of the system environment variables. Generally,during the
installation of NC2000 system, we will set up the user"nari",and the running script
language is "csh", at the sametime,should also set up the user's home directory. The

5
environment variable required by the normal operation of NC2000 monitoring system
software is usually defined in the file "Cshrc" under the user's home
directory,"nari".The self-starting file of NC2000 system is defined in ".login"(in Linux
systems) or". startdt" (in Solaris system).
The fllowing is a nice setting "Cshrc" file:
alias a alias
a s 'source ~/.cshrc'
#setenv LANG C
setenv XAPPLRESDIR ../data/resources
setenv WINDOWS /usr/bin/X11
setenv EBTRC /usr/ebt/bin/ebtrc.global
setenv JCC "javac -deprecation -g:none -O -nowarn -d ../bin"
a dtext '/usr/ebt/bin/dtext'
umask 002
# This is the path for Motif/Sunview:
set path=(. /usr/local/bin /opt/SUNWspro/bin ~/exe /usr/ccs/bin /usr/bin/mme
/usr/bin /usr/ucb /etc /usr/etc /usr/man /usr/sccs /usr/dt/include/Xm /usr/dt/bin
/usr/include $HOME/exe $WINDOWS /usr/sbin /usr/i18n/mule/bin)
# added for openwin
setenv F1H $HOME/data/lib
setenv LD_LIBRARY_PATH
/usr/ucb/lib:/usr/dt/lib:/usr/lib:/usr/ucblib:/usr/local/lib:
#setenv JAVA_FAST64_VM True
setenv JAVA_HOME /usr/java
setenv CLASSPATH $F1H/dx.jar:$F1H/JLex.jar:$F1H/java_cup.jar:$F1H/jbcl.jar:
$F1H/dx3.0.jar:$F1H/mediaplayer.jar:$F1H/multiplayer.jar:$F1H/customizer.jar:$F1H/
jmf.jar:$F1H/glf.jar:
setenv CLASSPATH
$F1H/F1J8Swing.jar:$F1H/jh.jar:$F1H/F1J8_zhs.jar:$F1H/xalan.jar:$F1H/infobus.jar:

6
$F1H/xerces.jar:$CLASSPATH
setenv CLASSPATH
$F1H/jcfield450K.jar:$F1H/NetComponents.jar:$F1H/dbswing.jar:$F1H/
sunjce_provider.jar:$F1H/lb.jar:$F1H/kernel.jar:$CLASSPATH
setenv WINMGR /usr/bin/X11/mwm
setenv MANPATH /usr/local/man:/usr/share/man
setenv MANPATH
/opt/SUNWconn/man:/opt/SUNWrtvc/man:/opt/SUNWsmtv/ShowMeTV/man:/opt/
SUNWvts/man:/opt/SUNWspci2/man:/opt/SUNWspro/man:/opt/SUNWste/man:$
{MANPATH}
# 8/6/91 Added for running exec's from ~/work/bin, Chinese character editor...
# 10/3/91 But some files are dependent on path....so don't like this addition
#set path=(/usr/ucb/ $path ~/work/bin /usr/bin/mme/ /usr/bin/mtools)
set path=($path /usr/ucb/ ~/work/bin /usr/bin/mme/ /usr/bin/mtools/sbin )
# normal ' ---- backward `
a sprompt 'set prompt="$USER@`hostname`[\\!]:"'
#settings for interactive shells
set filec
set fignore=( .o )
set history=100
setenv EXINIT 'set ai sw=3 sm report=2 ts=5 ignorecase'
a pu pushd
a po popd
a ls 'ls -F'
a pp 'ps -ef|grep nari'
a l 'ls -l'
a bye 'logout'
a sel 'setenv LINES \!*'
a sem 'alias more "more -n\!*"'
a pcset 'sem 33; sel 34'

7
set savehist=0
a h history
a lock lockscreen
a rma 'ipcrm -q \!:1 -m \!:2 -s \!:3'
a rmq 'ipcrm -q'
a rmm 'ipcrm -m'
a rms 'ipcrm -s'
a sts ipcs
a m more
a open 'chmod go+r'
a shut 'chmod go-r'
a x 'chmod +x'
a j 'jobs -l'
a f 'fg %\!*'
a nms 'tbl \!* | nroff -ms |more'
a cd ' cd \!*; set prompt="`hostname`:`pwd`> "'
a inc 'cd ~/include'
a exe 'cd ~/exe'
a src 'cd ~/txt/\!*'
a txt 'cd ~/txt/\!*'
a sys 'cd ~/data/sysfile'
a db 'cd ~/projects/\!*'
a cd.. 'cd ..'
a dir 'ls'
#setenv DISPLAY :0
setenv exepath ~/exe/
setenv LIBSRC "-I $HOME/txt/libipc -I $HOME/txt/libncdb -I $HOME/txt/libdrv
-I $HOME/txt/libntool"
#-----------------------modified by icelee 2005.3.15-----------------------#
set _DB_BASE_TYPE=`awk -F: '{ if($1 == "oracle") print $1;}' < /etc/passwd`

8
set _DB_BASE_HOME=`awk -F: '{ if($1 == "oracle") print $6;}' < /etc/passwd`
if { test "X$_DB_BASE_TYPE" = "X" } then
setenv DB_BASE_TYPE mysql
else
setenv DB_BASE_TYPE oracle
endif
if { test "$DB_BASE_TYPE" = "oracle" } then
setenv ORACLE_BASE $_DB_BASE_HOME
#setenv ORACLE_BASE /usr/users/oracle
setenv ORACLE_HOME $ORACLE_BASE/product
setenv ORA_NLS33 $ORACLE_HOME/ocommon/nls/admin/data
setenv ORACLE_HELP $ORACLE_HOME/help/admin/resource
#setenv ORACLE_SID ora9`/usr/sbin/clinfo -n`
#setenv EPC_DISABLED false
setenv NLS_LANG american_america.ZHS16GBK
#setenv NLS_LANG AMERICAN_AMERICA.ZHS16CGB231280
setenv ORACLE_OWNER oracle
set path=($ORACLE_HOME/bin $path)
setenv LD_LIBRARY_PATH
$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:$ORACLE_HOME/javavm/ad
min:$LD_LIBRARY_PATH
setenv CLASSPATH
$ORACLE_HOME/sqlj/lib/runtime.zip:$ORACLE_HOME/sqlj/lib/translator.zip:
$CLASSPATH
setenv CLASSPATH $ORACLE_HOME/jdbc/lib/classes111.zip:
$ORACLE_HOME/jdbc/lib/nls_charset11.zip:$CLASSPATH
set path=($path $ORACLE_HOME/product/bin $ORACLE_HOME/bin)
endif
#----------------------modified by icelee 2005.3.15----------------------#
#source /usr/local/bin/coraenv

9
if { test "$?WINDOW_PARENT" = "1" } then
source .login
endif
1.2.2 Background Process of Monitoring System
1.2.2.1 the starting of background process
Background programs of NC2000 system are stored in the exe directory whice is
under the home directory of nari users.For different roles of the computer nodes, the
deployment of background processes will be slightly different. The nodes of NC2000
monitoring system are divided into 3 basic categories:Host, operator and
communication.The following is the background process that kinds of nodes required to
run and the sequence of boot.
Host:

dbloa clien serve red_m mam lsdmn


d t r

start_svc engin agcav agcdr drvma ooexp


start e c v n r
Operator :

dbloa clien serve red_m mam agcdr xncdeskto


d t r v p

Communication:

dbloa clien serve red_m mam agcdr drvman


d t r v

Typically, we will make the sequence of start into a shell ,for exzample,
"startmain", "startop "or "startcom / startyd" whice is stored in "~ / exe" directory
("~"stand for nari user's home directory ). When NC2000 is started, the corresponding
procedures are also started automatically one by one.
Above all, we can see that the background procedure host equired are significantly
more than other types of computer nodes. The the function of these procedures will be
introduced in the next section.
1.2.2.2 Introduction for Uses of Background Process

10
We can see from the last ection, basic background procedures of NC2000
including: dbload, client, server, red_m and mam. The following diagram outlines the
main purpose of these procedures:

Red_m has the same function as red_a ,and the two-network system configuration
need to start the two processes simultaneously.red_m is the Net-based process, and
red_a is the supplemented Net process.A single net system only need to start red_m.In
addition ,red_m also responsible for consistency of network time, so need to have
superuser-property.
Except of the basic background process there is a number of processes whice must

11
deal with the special mission, they include:
lsdmn:the management process of logicality source,in NC2000 DB-database,it is
responsible for management of quotion relations of logicality source among all
measuring points.
ooexpr: Object Management process,in NC2000 DB-database, it is responsible for
interpretation and management of objects script.
agcavc: management process of automatic generation and automatic voltage
control,in NC2000 DB-database,it is the advanced application software whice is
responsible for automatic generation control.
agcdrv: responsible for sending AGC data of the host and receiving it at the other
nodes.
Drvman: the management process of kinds of driver process,it is responsible to the
management of communication process among host,LCU,communication and external
communications equipment.
st_clock: GPS clock synchronization receiver process,it is CPS responsible for
receiving data of CPS clock synchronization. Generally,it is running on the
communication.
start_svc: shell of the process starting of the process of the NC2000 historical DB-
databese.NC2000 system it is responsible for the starting of related process of NC2000
historical DB-databese.These processes include: hsvr_log, hsvr_mn, hsvr_smp,
hsvr_red and so on.
【Note】 NC2000 historical database systems have to run on oracle or mysql
database.Currently,In accordance with the verification,there is several relational DB-
database systems applicable to NC2000 historical DB-databese ,including:oracle 8i,
oracle 9i, mysql-4.0, mysql-5.0 version.Before the operation of NC2000 historical
database system process ,you need to make sure that oracle Services or mysql Services
Services has been running.
In addition to the above main background procedures, exe directory also includes a
number of practical orders of NC2000 system,including:

12
sh_data:
sh_data use for looking for or setting parameters status of the point in NC2000
real-time database system .Usage format: sh_data xxxxx.xx (point code. Parameter
code).For example,To check the power value of No. 1 generator (point is
number1.1.2.1.6, and code-named of parameters is 59), examples are as follows:
sh_data 1.1.2.1.6.59
If you want to manually set the parameters of a measuring point,on the premise of
meeting set value(Measuring point parameters can be written with no other background
process refurbishing this parameters),and using the setting format:sh_data
xxxxx.xx.xxx。As shown above,sh_data 1.1.2.1.6.59 60.0 express that the power value
of No. 1 generator is evalued 60.0.
node_t:
node_t :the order show node status of NC2000 system in the local view,as shown
in the following figure.

Figure 1 - 5
You can see that there is only one host in this NC2000 system,and the node status
is STANDALONE(operating independently,and there is other possible node
status,including:dead,backup,main and so on.)In the system network ,that net 0 is 1
show the net 0 is ok,and the net is 0 show there is some problem in net 1. The "used " is
0 means the main net is net 0.
proc_t:shows the occupancy of the NC2000 system-mail,as shown in the following
figure.

13
Chart shows the process PID No., QID No., QMUN queue and processes name.
redsw_test:
1.2.3 The Data Stream of NC2000 System.
After the brief introduction to you the background program of NC2000
system,now we want to make an other brief introduction in the way of the NC2000
system data stream that how the NC2000 system operate through the coordinate of
programs.

14
Black arrow line - the direction of the local data stream.
Green arrow line - the direction of data stream in networks.
The black connecting line - the connection line from the main process to its sub-
process.
The figure above show the relations among data streams of processes on the nodes
of NC2000 system.The nodes including host node,op node and LCU node.Because the
node status in the system are different, it contains the different processes and has
different role.In the figure the op node request of sercice from the host server through
the process of the Client,so the host server processes fork the corresponding sub-process
server to handle the requestion.NC2000 main data processing system is by the client,
server process through the way of TCP / IP.In addition, the DB-database information
can also be transfered by the process of mam in the way of multicast and broadcast.It
should be noted that database synchronization of each network node is also by host
mam process in the way of multicast.
1.3 The Communication Drivers of NC2000 System
In the implementation NC2000 system project, that our technical staff mostly faced
is preparation and revision of the driver.In the following sections ,we will make a more
detailed explanation in API which is interrelated to NC2000 system and communication
drivers and the definition of C structure,and hope that can help you to parpare the
relevant programs.
The basic data structure NC2000 system is as same as NARIAcc , with DIN, AIN,
PID and other similar functions NARIAcc block.Also add some special block with
some new functions.At the time of writing drivers, they generally only use DIN, AIN,
PID, PIN, AOUT, DOUT, MODULE such as function block,and these function blocks is
basically no change, same with drv_DIN, drv_AIN, drv_PIN, drv_DOUT,
drv_MODULE ansd so on.
1.3.1 The Header File of NC2000 system Driver
1.File: ~ / include / newdb.h
The file focused on the definition of the AIN, DIN and other functional blocks.

15
DATA_STRUCT used to access the data in the database, and used in the external
communications driver.
DBS_KEY ,points Key, each point the database has a unique DBS_Key, the value
identified in the database configurating.
2.File: ~ / include / dbhead.h
The file focused on the definition of head information in buffer of Nc2000 system
DB-database.
3.File: ~ / include / libdrv.h
The file mainly defines the driver-related structure information.
A)PORT_INFO: port information
Driver is used to describe the serial or network equipment information which is
used in communication between driver and peripheral devices.
typedef struct {
char *file; // name of the device opend by the driver
//Corresponds to serial communication, the value should be a serial device
//Corresponds to the network communications, the value should be Network
Address
int ID; //Unused
int fd; //device number to open file
unsigned network:1; //1: file is a network address
unsigned udp: 1; //1: The network protocol to use UDP communication (reserved)
unsigned mca:1; //1: The network protocol to use Multicast communications (reserved)
unsigned tcp:1; //1: The network protocol using TCP communication (default)
unsigned error:1; //Open the device error
unsigned pad:11; //Unused
unsigned port:16; //If the network == 1, port specified the port number
int pointCount; //The number of measuring points
char dest_node_name[NAME_SIZE + 1]; // Can be used to express the Network
communication node

16
char filename[NAME_SIZE + 1]; //Configuration file or Remote data files
FBStruc *pFB[]; //Measuring point
} PORT_INFO;
B)LOCATE_INFO: positioning information
It is used to describe positioning information relevant to the driver.
typedef struct{
short plant; //-p, Plant No.
short lcu; //-l, LCU number (start from 1)
short UnitNo; //-u, driver ID No.
short ICNNo; //-I, internal network number (for Modcell)
short TargetIndex; //-t, driving the index number (internal use)
unsigned char Address; //-a, driver Address No.
char pad[3];
} LOCATE_INFO;
C)POINT_MAP:The measuring point information
typedef struct {
FBStruc **pPoint; //Measuring point
unsigned short count; //Measuring point No
unsigned char fType; //Types of measuring point
unsigned char pad1;
short plant;
short lcuNo;
} POINT_MAP;
D)ExtComTag: remote measurement point information
typedef struct {
char tag[NAME_SIZE+1]; // tagname (ip)
unsigned char output; //0: Downlink messages, 1: uplink messages

unsigned char din; //0:remote,1:telemetering


unsigned char soe; // 1: SOE
unsigned char pin; // 1: PIN

17
unsigned char data;
unsigned char convert; // Whether or not transform coefficient by AB
unsigned char func_code;
#ifdef SUN
unsigned char pad8:1;
unsigned char pad7:1;
unsigned char pad6:1;
unsigned char pad5:1;
unsigned char pad4:1;
unsigned char pad3:1;
unsigned char bcd:1;
unsigned char tap:1;
#else
unsigned char tap:1;
unsigned char bcd:1;
unsigned char pad3:1;
unsigned char pad4:1;
unsigned char pad5:1;
unsigned char pad6:1;
unsigned char pad7:1;
unsigned char pad8:1;
#endif
unsigned short sno; //Top No
unsigned short boardno; //Plate No.
unsigned short slotno; //Slot No.
unsigned short occno; //Point No.
float coeA; // A coefficient
float coeB; // B coefficient
float lowoutput;
float highoutput;

18
float deadband;
float f_pad;
} ExtComDef;
typedef struct {
ExtComDef tagDef;
FBStruc *pFB;
DATA_STRUCT data;
long ActTime;
unsigned attr:16;
unsigned changed:1;
unsigned quality:1;
unsigned pad:14;
} ExtComTag;
E) DRV_SET_MSG:DO message format
Descending order for event-driven. The specific definition is descriped in the
document.
F)File:~/include/libipc.H
The document mainly defines the message-related structure
information .MSG_BUF is definited as same as NARIAcc.
1.3.2 The common NC2000 system communication driven library function
1、 SYS_DB *map_db(): [~/txt/libncdb.c]
The function make the shared memory address map to the address space of application.
When Successful return a pointer "SYS_DB", otherwise return NULL.
2、 int msg_init(char *processname); [~/txt/libipc/ipclib.c]
int msg_send(MSG_BUF *msgp, int time_out, int dest_flag,
int pp_flag, int ret_flag);
int msg_recv(MSG_BUF *msgp, int timeout);
int msg_delete();
The four functions have the same definition with NARIAcc.
In addition,"dest_flag" can use the following macro definition [~ / include / msg_info.h]

19
SND_DEST_LOCAL 1 // Sent to the local
SND_DEST_MAIN 2 // Sent to the remote main
SND_DEST_RED 4 // Sent to the remote backup
SND_DEST_MAIN_RED 6 // Sent to the remote main and backup
SND_DEST_PEER 8 //Sent to the contralateral parallel node
SND_DEST_LOCAL_PEER 9 //(SND_DEST_LOCAL | SND_DEST_PEER)
"pp_flag" Can use the following macro definition:
SND_PP_MAIN //Send only under the local host status
SND_PP_RED //Send only under the backup status
SND_PP_MAIN_RED (SND_PP_MAIN | SND_PP_RED) //Send under the local host
or slave State
"ret_flag" can use the following macro definition:
SND_RET_NO // Do not send the counter-information
SND_RET_YES // Send the counter-information
3、 int drvInitDrv(int argc, char *argv[], int down_config, int notAppendPid)
:[~/txt/libdrv/drvCom.c]
Initialization driver
Parameter description:
argc:main 的 argc
argv:main 的 argv
down_config: 1: Driver need to receive the modified message of the points setting
value.
0: Driver don`t need to receive the modified message of the points setting
value.
Modified message structure of the measuring point setting value is as follows:
function_code = MSG_CHG_CFG;
the length of msg_size = msg_data
msg_data = the number of modified setting value n (int)
Tagpath(char 〔24〕)

20
Type (int)
Data
Notes:
〔Type = Short, data with the short-type〕
〔Type = Field, data with type int〕
〔Type = Int, data with type int〕
〔Type = Long, data with the long-type〕
〔Type = Float, data with the float type〕
〔Type = Double, data with the double-type〕
〔Type = Tstring, the data is the char array type , length 128, fill the shortage with zero〕
Type values are defined at sysdef.h
notAppendPid: localProcName and process_name definit the return value of
parameters
4:process_name = argv[0](basename)
2:process_name = argv[0] + “_” +_LCU English name
1:process_name = argv[0] + “_” + portInfo.dest_node_name
0:process_name = argv[0] + “_” + pid
The function do the following operate:
A) Call drvGetArgumentOption (int argc, char * argv []), analysis argc, and argv
command line arguments (), in this step ,fill the structure. of portInfo and locationInfo.
Command-line parameters are defined as follows:
-p: specify Plant No.
-L: specify generate No.
-U: the designated driver ID No.
-I: specify ICNNo No.
-M: specify ModuleNo No.
-S: specify serial device name and its related parameters
-N: specify network address and port number
-D: specify goal node name No

21
-T: specify index number of driver
Above parameters all generated from drive configuration program ,except that "-t "
generated from "dbload" .
B) mapping shared memory address (call SYS_DB * map_db ())
C) Registration the pid of driver
D) Analysis of the port information (call int drvAnalyzePortInfo (argv [0]))
E) loaded the driver-related points information (called int drvLoadPoint ())
F) obtain the driver process_name
G)obtain the local alias, deposited in the Medium aliasName (call int
get_local_aliasname (char *))
H) initialization message queue (call int msg_init (char * localProcName))
I)obtain the information number of SIG_USR1 (called void sigset (int sig, void (*
function )()))--- exit_exe
J)register the driver to all measuring points (called int drvRegistDriver ())
5 .int drvInitPort();[~/txt/libdrv/drvCom.c]
Port initialization: If it is a serial port connection, it will open the corresponding
equipment, and set the relevant parameters. If it is a network,it will set up the related
connection.
Return Value: when Successful ,return equipment number
when fail,return -1
6.void drvClosePort ();[~/txt/libdrv/drvCom.c]
Turn off the port: If the port has been opened, then closed it.
7.int drvWriteCommStat(int comport, int offline) ;[~/txt/libdrv/drvCom.c]
Writing communication port status.
comport: corresponds to the bit0-bit in MODULE
Offline: 1: offline 0: Online
8. FBStruc *drvGetPoint(int plant, int lcu, int point , int type) ;[~/txt/libdrv/drvCom.c]
Obtain the measuring point.
plant: Plant No.

22
lcu: Unit No.
point: Point No.
type: the type of measurement points (fAIN, fDIN, fSOE, fPID etc.)
Return Value: when Successful ,return pointer which point at the corresponding to
measuring point.
Otherwise, return NULL
9. POINT_MAP *drvGetPointMap(int lcuNo, int ioType) ;[~/txt/libdrv/drvCom.c]
Obtain the index table of the Measuring point.
lcuNo: Unit No.
ioType: the type of measurement points (fAIN, fTIN, fDIN, fSOE, fPID, fMODLE,
fDOUT, fAOUT and so on)
Return value: when successful return the map table of the measuring point,Otherwise
return NULL.
Map tablesof measuring points are defined as follows (defined in libdrv.h):
Typedef struct (
FBStruc ** pPoint; //pointer array point to measuring points
unsigned short count;//The number of measuring points
unsigned char fType; //measuring point type
unsigned char pad1; / / unused
Short plant; / / Plant No.
Short lcuNo; / / Unit No.
) POINT_MAP;
10. .int drvSendMsg(int comID, unsigned char *msg, int len, int timeOut)
Send data to the designated equipment .
ComID: device descriptor of the specified port Msg: data buffer
Len: Data length
TimeOut: time-limited. If timeOut ≤ 0, it will be open.
Return the length of the send data
11. int drvReadMsg(int comID,char *pMsg, int len, int timeOut)

23
Receive data. from the specified device.
ComID: device descriptor of specified port
PMsg: data buffer
Len: Data length
TimeOut: time-limited. If timeOut ≤ 0, it will be open.
Return the length of received data.
12. The following functions are defined in ~ / txt / libncdb / libndrv.c
void drv_AIN (AIN *pFB, float RawData, int quality);
void drv_AIN1(AIN *pFB, float RawData, int quality, int alarm_flag);
Writing AIN database.
pFB: the designated corresponding measured points
RawData: specified send value
Quality: the specified quality
Alarm _flag: warning signs
void drv_DIN (DIN * pFB, int RawData, int quality);
void drv_DIN1 (DIN * pFB, int RawData, int quality, int alarm_flag);
Writing DIN database parameters Ibid
void ain_alarm (AIN * pFB, int hour, int minute, int second, int state, float RawData)
Function is same with drv_AIN, when warning, will use the specified hour, minute,
second
void din_alarm(DIN *pFB, int hour, int minute, int second, int ms, int RawData)
Function is same with drv_AIN, when warning, will use the specified hour, minute,
second
void drv_DOUT (DOUT * pFB, int RawData)
Writing out status
PFB: point to out point
RawData: out status
Void drv_MODULE (MODULE * pFB, int RawData)
Writing module status

24
PFB: point to module
RawData: module status (0 for normal ,otherwise abnormal)
void drv_PIN (PIN * pFB, int RawData, int quality)
Writing Pulse value.
int msg_alarm (char * msg, int hour, int minute, int sec);
Alarm, and log in the operation list of the entire plant .
Msg: Alarm information
Hour: the specified hours
Minute: the specified minute
Sec: the specified second
If hour <= 0 will use the current system time
int msg_alarm_log(char *msg, int toPlant, int toLcu, int toTableTag, int hour,
int minute, int sec);
Alarm, and log in to a specific list
msg: Alarm information
ToPlant: the specified Plant No.
ToLcu: the specified generator No.
toTableTag: specify list, it has the following value〔~ / include / commsg.h〕:
ALM_OPER_LOG / / operation list
ALM_DIAG_LOG / / self-diagnosis list
ALM_SOE_LOG / / accident list
ALM_FAIL_LOG / / Failure List
ALM_AIN_LOG / / list of the more complex restrictions
ALM_DIN_LOG / /state change list
ALM_AUX_LOG / / set start and stop Des table
ALM_AGC_LOG / / AGC operation table
ALM_SEQ_LOG / / flow information table
ALM_RELAY_LOG / / protection action information table
Hour: the specified hours

25
Minute: the specified minute
Sec: the specified second
If hour <= 0 will use the current system time
void Write_Log(char *msg_log_data, int alarm_table, int msgwin, int log,
unsigned plant_no, unsigned lcu_no);
msg_log_data: Alarm information
alarm_table: specify list, it has the following value〔~ / include / commsg.h〕:
ALM_OPER_LOG / / operation list
ALM_DIAG_LOG / / self-diagnosis list
ALM_SOE_LOG / / accident list
ALM_FAIL_LOG / / Failure List
ALM_AIN_LOG / / list of the more complex restrictions
ALM_DIN_LOG / /state change list
ALM_AUX_LOG / / set start and stop Des table
ALM_AGC_LOG / / AGC operation table
ALM_SEQ_LOG / / flow information table
ALM_RELAY_LOG / / protection action information table
msgwin: bulletin of warning informationLog: Log in police information
Plant_no: designated Plant No.
Lcu_no: designated generator No.
void Self_Write_Log(char *msg_log_data, int alarm_table, int msgwin, int log, short
year, short month, short day, short hour, short min,short sec, short ms, unsigned
plant_no, unsigned lcu_no)
The parameters are idem
13. Int loadExtFile (char * filename) [~ / txt / libdrv / drvExt.c]
ExtComTag * extTagInfo = NULL;
Read the dynamic configuration file
14. LoadExtPoint () [~ / txt / libdrv / drvExt.c]
obtain the dynamic pointer

26
15. Int registExtDriver (localProcName) [~ / txt / libdrv / drvExt.c]
Remote communication program registers to "rmtsoe" inoder to receive REMOTE_SOE
message
16. Int unregistExtDriver (localProcName) [~ / txt / libdrv / drvExt.c]
Remote communication program registers to "rmtsoe" inoder to write-off the receiving
of REMOTE_SOE message
17. Void freshExtData (int idx, int * changedDICount, int * changedEICount) [~ / txt /
libdrv / drvExt.c]
Refrurbish the data of dynamic points
18. Void drvExtCommitWrite (int idx) [~ / txt / libdrv / drvExt.c]
Sending the downstream data of dynamic points, the program must first purchase the
signs of extTagInfo [idx].
Writting a system application program ,the dricer neede the following header files of
NC2000:
newdb.h, dbhead.h, commsg.h, msg_info.h, libipc.h, libdrv.h
Therefore,in the head of program files, in addition to the necessary system header files,
also need the following line:

# include "newdb.h"
# Include "dbhead.h"
# Include "commsg.h"
# Include "msg_info.h"
# Include "libipc.h"
# Include "libdrv.h"

The file "make"need to connect to the following library file

libncdb.a, libipc.a, libdrv.a


Therefore, in the file "make" ,mke sure that the variable value of PGM_LIB 1.3.3
NC2000 common format of communications driver in NC2000 System .
A simple exzample:

27
#include <stdio.h>
#include <stdlib.h>
#include “newdb.h”
#include “dbhead.h”
#include “commsg.h”
#include “msg_info.h”
#include “libipc.h”
#include “libdrv.h”
extern PORT_INFO portInfo;
extern LOCATE_INFO locationInfo;
extern POINT_MAP *drvGetPointMap(int , int);
POINT_MAP *pSOE_Index, *pAIN_Index, *pPIN_Index, *pDOUT_Index,
*pMOD_Index, *pPID_Index, *pCTRL_Index;
AIN *pAIN;
DIN *pSOE;
PIN *pPIN;
DOUT *pDOUT;
CONTROL *pCTRL;
PID *pPID;
MODULE *pMOD;
int main(int argc, char *argv[]) {
/ * Initialize driver: the driver is scheduled to receive the value modified message of the
measuring point, the driver "processname" use pid as suffix * /
if (drvInitDrv (argc, argv, 1, 0)! = 0) return -1;
/ * Initialize the measuring point index * /
InitPointIndex ();
/ * Initialize port * /
if ((portID = drvInitPort ()) <0) exit_exe (0);
/ * Main cycle, receive and dispose the message * /

28
While (1) (
/ * Read data from the message queue * /
/ * Initialize port * /
get_msg_cb ();
/ * Read data from the corresponding equipment, and call drv_AIN, drv_DIN to write
database * /
/ * Send data to corresponding equipment* /
Flush_alarm ();
) / / End of while (1)
) / / End of main
/ **
* The following two functions tdeal with exit
* They call function "exit_exe" after receiving the signal SIG_USR1* /
Void before_exit_process () (
/ * The operation before carry out Msg_delete * /
)
Void end_exit_process () (
/ * The operation after carry out Msg_delete.The program "exit"will be carried out after
execution of Msg_delete,then the exit the program * /
)
void Process_SetValue (char * msg_data, int msg_size)
{
DBS_KEY pdbk;
int i, count, attr, type, offset;
char tagpath[24], st[128];
short s_val;
int i_val;
long l_val;
float f_val;

29
double d_val;
memcpy(&count, msg_data, 4); offset = 4;
#ifdef SUN
cvt_i(&count);
#endif
for (i=0; i<count; i++) {
memcpy(tagpath, msg_data+offset, 24); offset += 24;
attr = rConvertTagpathToDBK(tagpath, &pdbk);
memcpy(&type, msg_data+offset, 4); offset += 4;
#ifdef SUN
cvt_i(&type);
#endif
printf("%s : %d-%d-%d type=%d\n", localProcName, pdbk.module, pdbk.point,
attr, type);
switch (type) {
case Short :
memcpy(&s_val, msg_data+offset, 2); offset += 2;
#ifdef SUN
cvt_s(&s_val);
#endif
IntWrite(pdbk.plant, pdbk.obj, pdbk.point, pdbk.module, attr, s_val);
break;
case Int :
case Field :
memcpy(&i_val, msg_data+offset, 4); offset += 4;
#ifdef SUN
cvt_i(&i_val);
#endif
IntWrite(pdbk.plant, pdbk.obj, pdbk.point, pdbk.module, attr, i_val);
break;

30
case Long :
memcpy(&l_val, msg_data+offset, 8); offset += 8;
#ifdef SUN
cvt_l(&l_val);
#endif
break;
case Float :
memcpy(&f_val, msg_data+offset, 4); offset += 4;
#ifdef SUN
cvt_i((int *)&f_val);
#endif
FloatWrite(pdbk.plant, pdbk.obj, pdbk.point, pdbk.module, attr, f_val);
break;
case Double :
memcpy(&d_val, msg_data+offset, 8); offset += 8;
#ifdef SUN
cvt_l((long *)&d_val);
#endif
break;
case TString :
memcpy(st, msg_data+offset, 128); offset += 128;
break;
default :
return;
}
}
}
void Process_SetMsg(DRV_SET_MSG dsm)
{
switch(dsm.command) {

31
case DN_CMD_DOUT: //开出动作命令
pDOUT = (DOUT *)drvGetPoint(dsm.plant, dsm.lcu, dsm.point, fDOUT);
if (pDOUT != NULL) {
printf("%s : Do Dout command[%s %s]\n", localProcName, pDOUT-
>FB.pDescript, pDOUT->FB.pTag);
switch(pDOUT->Stat.PulseType) {
case DOUT_PULSE: //Pause dout
case DOUT_HOLD: //Hold dout
IntWrite(dsm.plant, dsm.lcu, dsm.point, fDOUT, OUTPUT, 1);
break;
case DOUT_CONTROL: //Control Command
printf("%s : Receive Control command[%s %s]\n", localProcName, pDOUT-
>FB.pDescript, pDOUT->FB.pTag);
IntWrite(dsm.plant, dsm.lcu, dsm.point, fCTRL, OUTPUT, 1);
break;
default:
printf("%s : Unknown DOUT type", localProcName);
break;
}
}
break;
case DN_CMD_DOUT_CL: //开出撤销命令
printf("%s : Cancel dout command\n", localProcName);
pDOUT = (DOUT *)drvGetPoint(dsm.plant, dsm.lcu, dsm.point, fDOUT);
if (pDOUT != NULL && pDOUT->Stat.PulseType != DOUT_CONTROL)
IntWrite(dsm.plant, dsm.lcu, dsm.point, fDOUT, OUTPUT, 0);
break;
case DN_CMD_PID_SETPOINT: // PID SETPOINT
printf("%s : PID set value [%d %f]\n", localProcName, dsm.type, dsm.fvalue);
FloatWrite(dsm.plant, dsm.lcu, dsm.point, fPID, SETPOINT, dsm.fvalue);

32
break;
case DN_CMD_AOUT: // AOUT SETPOINT
printf("%s : AOUT set value [%d %f]\n", localProcName, dsm.type, dsm.fvalue);
FloatWrite(dsm.plant, dsm.lcu, dsm.point, fAOUT, OUTPUT, dsm.fvalue);
break;
case DN_CMD_FC_IN:
IntWrite(dsm.plant, dsm.lcu, dsm.point, dsm.type, OUTPUT, 1);
break;
case DN_CMD_FC_IN_CL:
IntWrite(dsm.plant, dsm.lcu, dsm.point, dsm.type, OUTPUT, 0);
break;
case DN_CMD_FC_ON:
IntWrite(dsm.plant, dsm.lcu, dsm.point, dsm.type, MANUAL, 1);
break;
case DN_CMD_FC_OFF:
IntWrite(dsm.plant, dsm.lcu, dsm.point, dsm.type, MANUAL, 0);
break;
case DN_CMD_CONTROL:
printf("%s : CONTROL %d\n", localProcName, dsm.point);
IntWrite(dsm.plant, dsm.lcu, dsm.point, fCTRL, OUTPUT, 1);
break;
case DN_CMD_PID_ONOFF:
break;
case DN_CMD_PID_MSET:
printf("%s : PID %d mset\n", localProcName, dsm.type);
IntWrite(dsm.plant, dsm.lcu, dsm.point, fPID, MSET, dsm.type);
break;
default:
printf("%s : Received DRV_SET_MSG [cmd = %d]\n", localProcName,
dsm.command);

33
break;
}
}}
void get_msg_cb()
{
int pending;
unsigned short len;
MSG_BUF rbuf;
DRV_SET_MSG dsm;
unsigned char buf[8196];
pending = 1;
while (pending) {
rbuf.msg_size = 8196;
rbuf.msg_data = ( char *)buf;
rbuf.mtype = MESG_ALL;
memset(buf, 0, 8196);
pending = msg_recv(&rbuf, 0);
if (pending < 0) break;
else {
switch ( rbuf.function_code) {
case MSG_CHG_CFG :
if ( red_flag ) Process_SetValue(rbuf.msg_data, rbuf.msg_size);
break;
case MSG_SETVALUE :
if (rbuf.msg_size == sizeof(DRV_SET_MSG) && red_flag)
memcpy(&dsm, rbuf.msg_data, rbuf.msg_size);
#ifdef SUN
cvt_drv_set_msg(&dsm);
#endif
Process_SetMsg(dsm);

34
}
break;
default: break;
} // end of switch
} // end of if
} // end of while
}
void InitPointIndex() {
pSOE_Index = drvGetPointMap(locationInfo.lcu, fSOE);
pAIN_Index = drvGetPointMap(locationInfo.lcu, fAIN);
pPIN_Index = drvGetPointMap(locationInfo.lcu, fPIN);
pDOUT_Index = drvGetPointMap(locationInfo.lcu, fDOUT);
pMOD_Index = drvGetPointMap(locationInfo.lcu, fMOD);
pPID_Index = drvGetPointMap(locationInfo.lcu, fPID);
pCTRL_Index = drvGetPointMap(locationInfo.lcu, fCTRL);
}
The routine is a simple process, and in practical applications, you can refer to
"mdcntcp" and "ccudrv" communication program.

void CtrlExec()
{
unsigned int address;
unsigned char type;
address = 0;
memcpy((unsigned char *)&address, recv_buf+12, 3);
type = recv_buf[15] & 0x03;
address = address - CTRL_ADDR;
printf ("RECV ------ CONTROL COMMAND addr %d OP %d, CTRL_NUM=%d\
n", address, type, CTRL_NUM);
if (CtrlDeselect() == 0) {

35
C_DC_NA_118();
if (CTRL_NUM > 0 && address <= CTRL_NUM) {
extTagInfo[CtrlList[address-1]].data.DataValue.iData = type-1;
extTagInfo[CtrlList[address-1]].changed = 1;
drvExtCommitWrite(CtrlList[address-1]);
extTagInfo[CtrlList[address-1]].changed = 0;
printf ("%s : CtrlExec ------ CONTROL COMMAND %s %d\n",
localProcName,extTagInfo[CtrlList[address-1]].tagDef.tag,
extTagInfo[CtrlList[address-1]].data.DataValue.iData);
}
ms_sleep(100);
C_DC_NA_119();
}
else
C_DC_NA_121();
}
void CtrlExec_TA()
{
unsigned int address;
unsigned char type;
address = 0;
memcpy((unsigned char *)&address, recv_buf+12, 3);
type = recv_buf[15] & 0x03;
address = address - CTRL_ADDR;
printf ("RECV TA ------ CONTROL COMMAND addr %d OP %d, CTRL_NUM=
%d\n", address, type, CTRL_NUM);
if (CtrlDeselect() == 0) {
C_DC_TA_118();
if (CTRL_NUM > 0 && address <= CTRL_NUM) {
extTagInfo[CtrlList[address-1]].data.DataValue.iData = 1;

36
extTagInfo[CtrlList[address-1]].changed = 1;
drvExtCommitWrite(CtrlList[address-1]);
extTagInfo[CtrlList[address-1]].changed = 0;
printf ("%s : CtrlExec_TA ------ CONTROL COMMAND %s %d\n",
localProcName, extTagInfo[CtrlList[address-1]].tagDef.tag,
extTagInfo[CtrlList[address-1]].data.DataValue.iData);
}
ms_sleep(100);
}
else C_DC_TA_121();
C_DC_TA_1T();
}
void AOExec()
{
short value;
unsigned int address;
address = 0;
memcpy((unsigned char *)&address, recv_buf+12, 3);
memcpy((unsigned char *)&value, recv_buf+15, 2);
address = address - SET_ADDR;
if (PID_NUM > 0 && address <= PID_NUM) {
if (extTagInfo[PidList[address-1]].tagDef.convert == 0)
extTagInfo[PidList[address-1]].data.DataValue.fData = value;
else
extTagInfo[PidList[address-1]].data.DataValue.fData =
value * extTagInfo[PidList[address-1]].tagDef.coeA;
extTagInfo[PidList[address-1]].changed = 1;
drvExtCommitWrite(PidList[address-1]);
extTagInfo[PidList[address-1]].changed = 0;
printf ("%s : AOExec addr %d value %d --- %f\n", localProcName, address,value,

37
extTagInfo[PidList[address-1]].data.DataValue.
fData);
}
}
void AOExecf()
{
float value;
unsigned int address;
address = 0;
memcpy((unsigned char *)&address, recv_buf+12, 3);
memcpy((unsigned char *)&value, recv_buf+15, 4);
address = address - SET_ADDR;
if (PID_NUM > 0 && address <= PID_NUM) {
extTagInfo[PidList[address-1]].data.DataValue.fData = value;
extTagInfo[PidList[address-1]].changed = 1;
drvExtCommitWrite(PidList[address-1]);
extTagInfo[PidList[address-1]].changed = 0;
printf ("%s : AOExecf addr %d fvalue %f\n", localProcName, address,
extTagInfo[PidList[address-1]].data.DataValue.fData);
}
}
void AOExec_Curve()
{
unsigned short address, value;
unsigned char num;
int i;
address = 0;
if(PID_NUM <= 0) return;
num = recv_buf[7];
for( i=0; i<num; i++) {

38
memcpy((unsigned char *)&address, (unsigned char *)&recv_buf[10+i*4], 2);
memcpy((unsigned char *)&value, (unsigned char *)&recv_buf[12+i*4], 2);
address = address - SET_ADDR;
if (address > 0 && address <= PID_NUM) {
if (extTagInfo[PidList[address-1]].tagDef.convert == 0)
extTagInfo[PidList[address-1]].data.DataValue.fData = value;
else
extTagInfo[PidList[address-1]].data.DataValue.fData =
value * extTagInfo[PidList[address-1]].tagDef.coeA;
extTagInfo[PidList[address-1]].changed = 1;
drvExtCommitWrite(PidList[address-1]);
extTagInfo[PidList[address-1]].changed = 0;
}
}
}

39
Interlocution of FAQ

40
Chapter II Functional Specification of Linux Operating System

2.1 Linux System Commands


2.1.1 Commonly Used Command Explain of Linux System
2.1.1.1 Enter and Exit the System
Enter the System
If you want to enter the Linux system,must have to enter the user's account.During the
installation process in the system,you can create the following two accounts:
root - super user account (system administrator), using this account in the system you
can do anything.
Ordinary users - that account for ordinary users, using this account in the system you
can do limited operation.
Linux users in general are ordinary users, but system administrators mainly using
super-user account to complete the work of system management.If we want to complete
the task which only need the ordinary account, recommended,do not use super-user
account, so as not to damage the system inadvertently . Affect the normal operation of
the system.
Users logging must go through two stages : the first step, enter the user's login name, so
the system according to the login name to identify users;The second step, enter the
user's password.The password is a string which user set up,to other users is confidential
and is used to distinguish the keywords of true and false users druing the logging the
system.
When the user entered the correct user name and password, you can enter the
system legitimately. Screen shows: [root @ loclhost / root] #
At this time,the system can do a variety of operations. Attention, DOS prompt of
super-user is "#",and DOS prompt of other users is "$."
1.Modify Password
In order to protect the security of user account, Linux allows users can modify their own
password at any time. The command of modify is "passwd", and it will prompt the user

41
to enter the old password and new password, and then also asked users to confirm the
new password again in order to avoid the user accidentally pressed the wrong button.If
the user forgot the password, you can apply to the system administrator to set up a re-for
their own.
2.Virtual Console
Linux is a true multi-user operating system, it can accept multiple users log on at
the same time.Linux also allows a user to log on several times,because,like Linux or
UNIX ,provides Virtual Console access mode

that allows users to log on several times at the same time.The virtual console can be
choiced by pressing the "Alt" key and a function key to achieve.We used such as F1-F6,
after users logging on, click Alt-F2 key, then the user can see the DOS prompt :logint,
after that the user can find the second virtual console.And then only need to press Alt-
F1 key, you can return to the first virtual console. A new installed Linux system allows
users to use the default key Alt-F1 to Alt-F6 to access the first six virtual
consoles.Virtual Console allows users to work simultaneously in a number of console,
emboding that Linux systems truly has the characteristics of multi-user.Before the end
of a work in a virtual console, the user can switch to another virtual console to start
another.
3.Exit the System
Both the super-user and the ordinary user, if want to exit the system ,should input "exit"
or "logout" at the DOS prompt :shell.
2.1.1.2 Linux Copy, Delete, and Mobile Command of the File
1.cp command
Function:The cp utility copies the contents of source_file to the destination path
named by target_file.
Expression:cp [options] source file or directory target file or directory
Discription:one or more source_files are copied to the directory specified by target.
User Commands:
-a:

42
-d:
-f: Unlink. If a file descriptor for a destination file cannot be obtained, this option
attempts to unlink the destination file and proceed.
-i: Interactive. cp prompts for confirmation whenever the copy would overwrite an
existing target. A y answer means that the copy should proceed. And other answer
prevents cp from overwriting target.
-p: Takes actions on any symbolic link specified as a source_file operand or any
symbolic link encoun-tered during traversal of a file hierarchy.
-r: Recursive. cp copies the directory and all its files, including any
subdirectories and their files to target. Unless the -H, -L, or -P option is specified,
the -L option is used as the default mode.
-l:Takes actions based on the type and contents of the file referenced by any
symbolic link specified as a source_file operand or any symbolic links encoun-tered
during traversal of a file hierarchy.
It should be noted that, in order to prevent users in the case of inadvertently using
command "cp" to undermine the other documents, such as the user-specified goal file
name has already existed, when using command "cp", this document will be covered by
the new source file, therefore, it is best to use the option "i" ,when use command "cp".
2.mv command
Function:the mv utility moves the file named by the source operand to the destination
specified by the target_file.
Expression:mv [options] source file or directory target file or directory
Discription:according to the difference of the second parameter(the target file or target
directory), command "mv" will rename files or move them to a new directory.When the
type of the second parameter is document,the mv utility moves the file named by the
source operand to the destination specified by the target_file. source and target_file
may not have the same name. If target_file does not exist, mv creates a file named
target_file. If target_file exists, its contents are overwritten. This first synopsis form
is assumed when the final operand does not name an existing directory.When the type of

43
the second parameter is directory,mv moves each file named by a source operand to a
destination file in the existing direc-tory named by the target_dir operand. The
destination path for each source is the concatenation of the target direc-tory, a single
slash character (/), and the last path name component of the source. This second form
is assumed when the final operand names an existing directory.
The following options are supported:
-i: mv will prompt for confirmation whenever the move would overwrite an
existing target. An affirmative answer means that the move should proceed. Any
other answer prevents mv from overwriting the tar- get.
-f: mv will move the file(s) without prompting even if it is writing over an
existing target. Note that this is the default if the standard input is not a terminal.
If the target file has (not directory) already existed, at this time the contents of the
document will be covered by the new document.In order to prevent users in the case of
inadvertently using command "mv" to undermine the other documents, it is best to use
the option "i" ,when use command "mv".
3.rm command
Function: The rm utility removes the directory entry specified by each file argument.
If a file has no write permission and the standard input is a terminal, the full set of
permissions (in octal) for the file are printed followed by a question mark. This is a
prompt for confirmation. If the answer begins with y (for yes), the file is deleted,
otherwise the file remains. If file is a symbolic link, the link will be removed, but the
file or directory to which it refers will not be deleted. Users do not need write
permission to remove a sym- bolic link, provided they have write permissions in the
directory.
The general form of the command rm:
Syntax: rm [options] file...
If you do not use the option "-r", rm will not delete the directory.
The following options are supported:
-f: Ignore non-existent files, never given prompt.

44
-r: delete all directories and subdirectories recursively
-i: Interactive delete.
To be careful when using the command "rm",because once the file is deleted, it can
not be restored.To prevent this case, you can use the option "i" to confirm the document
that you want to delete one by one .
2.1.1.3 Linux Creation and deletion Command of Directory
1.mkdir command
Function:make directories
Syntax: mkdir [options] dir-name
Discreption:The order creates the directory named by the "dir-name".Creation of a
directory requires write permission in the parent directory.
The following options are supported:
-m: This option allows users to specify the modes to be used for new directories.
Choices for modes can be found in chmod
-p: With this option, mkdir creates dir by creating all the non-existing parent direc-
tories first. The mode given to intermediate directories will be the difference between
777 and the bits set in the file mode creation mask. The difference, however, must be
at least 300 (write and execute permission for the user).
2.rmdir command
Fuction:remove directory entries
Syntax: rm [options] dir-name
Discreption:dir-name is the directory name.The order can delete one or more
subdirectories from a directory.Need to pay particular attention is that a directory be
empty before it is removed."rm - r dir" command can replace "rmdir",whether the
directory is empty, it will be deleted, so it is dangerous. When a directory is deletedmust
,it must have write permission in the parent directory.
The meaning of the various options of the command are as follows:
-p: Allows users to remove the directory dirname and its parent directories which
become empty. A message is printed to standard error if all or part of the path could not

45
be removed.
3. cd command
Function:change working directory
Syntax: cd [directory]
Discreption:cd utility changes the current directory in the context of the cd utility only.
If no argument is given, change to the home directory of the user.cd must have execute
(search) permission in dir. Because a new process is created to execute each command,
cd would be ineffective if it were written as a normal command; therefore, it is
recognized by and is internal to the C-shell.The command can use wildcards
For example:
cd :(If without any parameters,it wil directly access to the current logged-on user's
home directory)
cd -:(Entered into the previous directory)
cd ~ jp :(enter the designated user's(jp) home directory)
4. pwd command
Function:return working directory name
Syntax: pwd
Discreption:The pwd utility writes an absolute path name of the current working
directory to standard output.
5.ls command
Function:"ls" is the short of "list",and the function of the command is that list contents
of directory.This is the most common command, because the user needs to find contents
of a directory from time to time.This order is similar command "dir" in DOS.
Syntax: ls [options] [directory or file]
For each file that is a directory, ls lists the contents of the directory. For each file that
is an ordinary file, ls repeats its name and any other information requested. The
output is sorted alphabetically by default. When no argument is given, the current
directory is listed. When several arguments are given, the arguments are first
sorted appropriately, but file arguments appear before directories and their contents.

46
The meaning of the various options of the command are as follows:
-a:Lists all entries, including those that begin with a dot (.), which are normally not
listed.
-A: Lists all entries, including those that begin with a dot (.), with the exception of the
working directory (.) and the parent directory (..).
-b: Forces printing of non-printable characters to be in the octal \ddd notation.
-c: Uses time of last modification of the i-node (file created, mode changed, and so
forth) for sorting (-t) or printing (-l or -n).
-C: Multi-column output with entries sorted down the columns. This is the default
output format.
-d: If an argument is a directory, lists only its name (not its contents). Often used with
-l to get the status of a directory.
-f: The order is the order in which entries appear in the directory.It will make the option
lts ineffective and option Ua effective.
-i: For each file, prints the i-node number in the first column of the report.
-l: Lists in long format, giving mode, ACL indication, number of links, owner, group,
size in bytes, and time of last modification for each file (see above).
If the file is a symbolic link, the filename is printed followed by "->" and the path
name of the referenced file.
If the file is a special file, the size field instead contains the major and minor
device numbers.
-L:If an argument is a symbolic link, this option evaluates the file information and
file type of the file or directory that the link references, rather than those of the link
itself.
-m: Streams output format. Files are listed across the page, separated by commas.
-n: The same as -l, except that the owner's UID and group's GID numbers are
printed, rather than the associated character strings.
-o: The same as -l, except that the group is not printed.
-p: Puts a slash (/) after each filename if the file is a directory.

47
-q: Forces printing of non-printable characters in file names as the character question
mark (?).
-r: Reverses the order of sort to get reverse alphabetic or oldest first as appropriate.
R: Recursively lists subdirectories encountered.
-s: Indicate the total number of file system blocks consumed by each file displayed.
-t: Sorts by time stamp (latest first) instead of by name. The default is the last
modification time. (See -u and -c.)
-u: Uses time of last access instead of last modification for sorting (with the -t option)
or printing (with the -l option).
-x: Shows sort of information by line
The mode printed when the -e, -E, -g, -l, -n, -o, -v, -V, or -@ option is in effect
consists of eleven characters. The first character can be one of the following:
- :Ordinary file
d :The entry is a directory.
l :The entry is a symbolic link.
b :The entry is a block special file.
c :The entry is a character special file.
The next 9 characters are interpreted as three sets of three bits each. The first set refers
to the owner's permissions; the next to permissions of others in the user-group of the
file; and the last to all others. Within each set, the three characters indicate permission to
read, to write, and to execute the file as a program, respectively.
The permissions are indicated as follows:
r :The file is readable.
w :The file is writable.
x :The file is executable.
s :The set-user-ID or set-group-ID bit is on, and the corresponding user or group
execution bit is also on.
t :Setting flag (to stay in memory, not-for-a).The 1000 (octal) bit, or sticky bit, is on
(see chmod(1)), and execution is on.

48
2.1.1.4 Linux Text Processing Commands
1.sort order
Function: A templatized algorithm for sorting collections of entities.There are many
very useful options of commad sort.These options were originally used to do sorting
operations to content of the document in the database format.In fact, sort order can be
considered as a very powerful data management tools,whice used to manage documents
similar to database records.
Sort order compare the contents of the file line by line.If the first characters of the two
line are the same ,it will continue to compare the next line of the two line,and if it is the
same too,it will continue to compare.
Syntax: sort [options] file
Discreption:Wite sorted concatenation of alll file(s) to standard output.If we do not
specify the input file or use the "-", then show that the sort contents is from standard
input.The sorting is according to one or more singal-letter ordering options,which
override global ordering options for that key.If no key is given, use the entire line as the
key.
The option to change the default settings are:
+ Posl - pos2 is designated one or more fields as a sort keywords.The field begin from
pos1 to pos2 (including posl, does not include pos2). If the pos2 is not specified , the
keywords from the pos1 to the end-of-line . The location of fields and characters start
from 0.
-b: when look for keyword,ignore leading blanks
-t: Designated "separator" as separator.
-m: merge already sorted files;do not sort
-c: check whether input is sorted.If it has not been sorted, then print out a
wrong information, and to withdraw from the state with value 1.
-u: check for strict ordering.Output only the first of an equal run.
-o: write result to file instand of standard output.If the output file is one of the input
files, the commad sort will first write the contents of the file to a temporary file, and

49
then sort and write the output result
The options to change the default collation are:.
-d: consider only blanks and alphanumeric characters
-f: fold lower case to upper case characters
-I: consider only printable characters
-M: month-sort,“JAN”<“FEB”
-r: reverse the result of comparisons
2.uniq command
Function:Processed documents in its output files may appear the repeat line. For
example,use command "cat" to merge the two documents and then use the command
"sort" to sort, then possible appear the repeated line.Then you can use the command
"uniq" to report or filter out repeated lines in a file.
Syntax: uniq [options] file
Description:The uniq utility will read an input file comparing adjacent lines, and write
one copy of each input line on the output. The second and succeeding copies of repeated
adjacent input lines will not be written.The command writes the results of processed to
the output file.Input file and output file must be different.If the input file with "-",then it
read from standard input.
The meaning the options of the order are as follows:
-c: Precedes each output line with a count of the number of times the line occurred in
the input.
-d: Suppresses the writing of lines that are not repeated in the input.
-u:Suppresses the writing of lines that are repeated in the input.
-n:The frontal several fileds and the blank with fields are ignored.A field is a non-
space, non-string tabs, and is separated with each other by tabs and spaces (field number
from 0 to start).
+n:The frontal n characters are ignored,and skip the previous characters.
- f n is the same with -n, here n is the number of fields.
- s n is the same with +n, where n is the number of characters.

50
2.1.1.5 Backup and Compression Commands in Linux
1.tar command
Function:create tape archives and add or extract files.Using tar, the user can create file
for a particular documents (backup file), can change the document in the file, or add a
new document to file .Tar was originally used to create a file on tape, and now, users
can create files on any device, such as floppy disk.Using tar command can packaged a
lot of files and directories into a document,and backup file or combination of several
documents into one document is very useful for the network .The tar in Linux is the
version of GNU.

Syntax: tar [Auxiliary options + Main options] file or directory

T\There must be the main option,because it tells tar what to do, and auxiliary options
can be choosen to use.
Main options:
c :Create new files. If the user would like to backup a directory or some documents, it is
necessary to choose this option.
r :The named files are written at the end of the tarfile.For example, users has already
backup documents, then found that there is a directory or some documents forget to
backup , at this time you can use this optionto backup the directory or file to the end of
the tarfile.
t :Table of Contents. The names of the specified files are listed each time they occur in
the tarfile.
u :Update. The named files are written at the end of the tarfile if they are not already in
the tarfile, or if they have been modified since last written to that tarfile.
x :Extract or restore.
b :Use when reading or writing to raw magnetic archives (see f below). The blocksize
argument specifies the number of 512-byte tape blocks to be included in each read or
write operation performed on the tarfile. The minimum is 1, the default is 20.
f :File. Use the tarfile argument as the name of the tarfile.
k :Save the file already exists.For example, we have to restore a file,in the restore

51
process, encountering the same document, and it will not be coveraged.
m : Modify. The modification time of the file is the time of extraction.
M :create Multi-volume file in order to storage in a number of disk.
v :Verbose. Output the name of each file preceded by the function letter.
z :Use gzip to compress / decompress files.Adding this option,the files can be
compressed.
For example: tar cvf aa.tar / home / aa ( package / home / aa directory to aa.tar)
tar zcvf aa.gz / home / aa (compression / home / aa directory packaged to package
aa.gz )
2.gzip command
There are two obvious benefits to reduce the file size , one is that can reduce the storage
space, and the other is that can reduce the transmission time when transfer files through
the network.gzip is convenient and easy in Linux systems to file compression and
decompression
Syntax: gzip [options] compress (decompress) the file name
The meaning of each option:
-c:Writes the output to standard output and restore the original document.
-d:decompress --uncompress
-l:For each compressed file, list the following fields:
compressed size: size of the compressed file
uncompressed size: size of the uncompressed file
ratio: compression ratio (0.0% if unknown)
uncompressed_name: name of the uncompressed file
-r:Travel the directory structure recursively. If any of the file names specified on the
command line are directories, gzip will descend into the directory and compress all
the files it finds there (or decompress them in the case of gunzip ).
-t:Test. Check the compressed file integrity.
-v: Verbose. Display the name and percentage reduction for each file compressed or
decompressed.

52
-num:adjust Num compression speed with the number "num",and -1 or - fast stand for
the fastest compression method.System default value is 6.
For example: gzip-l aa.gz (listed aa.gz package content )
3.unzip command
In Linux,how to decompression the file which is compressed by the software winzip
under MS Windows ? Unzip command can be used.
Syntax: unzip [options] compressed file name. Zip
The meaning of each option are as follows:
-x:List the compressed files, but does not include the specified file file.
-v:Check the compressed file directory, but does not decompressed.
-t:Test document any damage, but does not decompressed.
-d:Put the compressed file to the specified directory.
-z:Show only comments of the compressed file.
-o:Does not cover documents that already exist
-j:Do not rebuild the directory structure of the document,and compressed all the files to
the same directory.
4.gzexe order
This command can compress executable files in place,similar to pklite under
dos.Compressed executable file size smaller, and do not affect the normal operation of
the executable file.when the disk space is tight,you can use this command to compress
executable files in order to reduce the disk space occupied.
2.1.1.6 run DOS command in the Linux environment
Linux system provides a set of portable tool which is known as mtools, that allows users
to easily reading and writing files and directories from standard DOS floppy disk.It is
very useful for the exchange between DOS and Linux environment.It is a powerful tool
for exchange of documents among the systems that do not have a common file system
format.To a MSDOS floppy disk, as long as the floppy disk in the floppy drive , they
can use the mtools commands access to files on floppy disk.
The main mtools commands are as follows:

53
mcd directory name change MSDOS directory;
mcopy source file target file ,copy files between Unix and the MSDOS
mdel file name ,delete files MSDOS;
MSDOS directory name,show MSDOS directory;
mformat drive NO ,create a MSDOS file system in low-level formatted floppy disk ;
rnlabel drive NO, create MSDOS volume label;
mmd directory name ,establish MSDOS directory ;
Mrd directory name ,deleted MSDOS directory ;
mren source target file rename the existing MSDOS file;
Mtype file name display MSDOS document.
NOTE: These commands and the corresponding command is very similar to MSDOS.
2.1.1.7 Change the File or Directory Access Authority Commands in Linux
In Linux system, files and directories all have access authorities, which determine who
can access the files and directories and in which way.
The access authorities of file or directory is divided into three types read-only ,write
only and enforceable.
Make document as an example, read-only authority that allow only read its contents,
and the prohibition to make any changes to its operation.Executable authority that allow
the document as a procedure.When the file is created, the file owner of the document
automatically has the read, write, and executable authority, in order to read and modify
the document.Users can set up any combination authority based on need .There are
three different types of users can access file or directory: file owner, the same group of
users, other users.Owners generally is the founder of the document.Owners can allow
users in the same group to have the same access authority to document, the access
authority can also be given to the other users of the system.In this case, every user in
the system can access this user's files or directories.Each file or directory access
authority have three groups, each with three bit, that are owner read, write and execute
authority;read, write and execute authority of the user which is in the same group;read,
write and execute authority of the other users in the system.When using ls-l command to

54
display a file or directory for more information, the most left file is the access authority.
For example:
$ ls -l sobsrc.tgz
  -rw-r--r-- 1 root root 483997 Ju1 l5 17:3l sobsrc.tgz
Empty line on behalf of permission. r on behalf of read-only, w on behalf of write only ,
x on behalf of the executable.Note,there a total of 10 location.The first character
designated file type.In the ordinary sense, a directory is also a file.If the first character is
a line that means it is a non-directory file.If it is d, that means it is a directory.
For example:
- Rw-r - r --
Ordinary file Owner file User in the same group The other user
The above means that Sobsrc.tgz is an ordinary document; sobsrc.tgz owner has reading
and writing authority; group users has read only authority; other users has read only
authority.
After identified access authority of a file, the user can use the chmod command in
Linux system to re-set different access authority to the file.Can also use the command
chown to change a file or directory owners.Use command Chgrp to change user group
of a file or directory .
The following is the introduce of these commands.
1.chmod command
Command chmod is very important for changing the file or directory access authority.
Users use it to control file or directory access authority.There are two usage of the order.
One is character set method which contained in letters and expressions of the operator;
the other digital set method which included figures .
Character set method
chmod [who] [+ | - | =] [mode] file name?
The meanings of the various options in command are as follows:
But the operate objects who can be any one of the following letters or combination of
them:

55
u "the user (user)", that is, the owner of files or directories.
g "the same group (group) users", that is, with the all users which has the same group ID
with the owner.
O the "other (others) users."
A "all (all) users." It is the system default values.
Operation symbol may be:
+ Add an authority.
- Cancel an authority.
= Given the setting authority and cancel all other authority (if any).
Setting the authority that "Mode" stand for can be any combination of the following
letters:
r readable.
w writable.
x executable.
X only the target file is executable for some users or only the target document is a
directory ,then add x attribute.
s when the document is executing ser the owner or group ID to the file owner. The way
"u + v s" set user ID bit file, and "g + s" set group ID bit.
t save the text of the procedure to exchange the device.
U Has the same authority with the document owner .
g Has the same authority with user which is in the same group with the owner of the
document owner
O Has the same authority with the other users .
File Name: space-separated and changing the authority file list,and support of
wildcards.
In a command line mode can give a number of authority, which separated by commas.
For example: chmod g + r, o + r example
Make the same group and other users have read authority to the document example.
Digital set method

56
First we must understand the meaning of properties of number :0 means no authority ,1
means executable authority (x), 2 means writable authority(w), 4-readable authority (r),
and then add.
Therefore, the form of the number attributes should be three from0 to 7 octal number,
and the order is (u) (g) (o).
For example, if you want a file owner has "read / write" two kinds of authority, need to
do 4 (readable) +2 (can write) = 6 (read / write).
The general form of digital set method :
chmod [mode] file name
For example: chmod 777 aa (give aa an owner, users in the same group , other users
have all access authority)
2.chgrp command
Function:change file group ownership
Syntax: chgrp [options] group filename
The order is used to change the user groups of the specified files.The group can be a
user group ID, and it also could be a group name of the user group in the / etc / group
file. File name is separated by space ,and if you want to change the file list of the
group ,it support of wildcards.If the user is not the document owner or super user, then
the document can not change the group.
The meaning of the various options of the order is as follows:
-R Recursive. chgrp descends through the directory, and any subdirectories, setting
the specified group ID as it proceeds.
For example: chgrp-R root / home / test (chang the group of directory in / home / test
directory and all files in subdirectories to root group)
3.chown command
Function:change file ownership.This command is also very common.Such as the root
user copy their files to the user xu, in order to allow users xu to access the document, so
root user should change the owership of this document to xu, otherwise, users xu can
not have access to this document.

57
Syntax: chown [options] user or group of files
Description: the command chown change the owner of the specify file to the specify
user or group.The user can be username or user ID.Group can be a group name or group
ID.The file is the file list which is seoarated by space and need to change the
permissions,and it support the wildcards.
The meaning of the various options of the order are as follows:
-R Recursive. chown descends through the directory, and any subdirectories, setting
the specified ownership ID as it proceeds.
-V Show the work the command chown has done.For example: chown-R root: root doc
(change the group of doc file to root ,and the owner-user to root)
2.1.1.8 The User-related Command in Linux
1.passwd command
For systems security, every user in Linux systems in addition to have their user name,
and they have the corresponding password.Therefore when increasing with the
command useradd, also have to use the command passwd command to incease the
password for the new user.The user can also use passwd command to change their
password.
The general format of the command: passwd [username] ,and the username the
username which need to amend password.Only super-user can use the "passwd
username" modify other user's password, nad the ordinary user can only use the passwd
command with no parameters to modify their own password.
The use of the order is as follows:
Enter: passwd <Enter>;
Under the (current) UNIX passwd: enter the current password
Under the new password: enter the new password (can not find this password in the
screen):
In the system prompt to enter the new password again.
After the correct input, the new password is encrypted and put in / etc / shadow file.
Select a password can not easily be deciphered is very important.

58
Select the Password shall be subject to the following rules:
Password should be at least six (preferably eight) characters;
Password should be mixed by the upper ,lower case letters, punctuation and numbers.
The posesse of super-users to modify the of password other users (xxq) is as follows,
# passwd root
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully
#
3.su command
This command is very important.It allows ordinary users have authorities of super-users
or other users, but also allows super-users to do something with the authority of
ordinary user. When ordinary users use this command ,they must have super-user or
other user's password.If you want to leave the current user's identity, you can enter
"exit".
The general form of the command: su [options] [?] [User account]
Note: If there are no specified user account, the system default value is the super user
root. The meanings of the various options of this command are as follows:
C end after the implementation of a command.
? Plus the minus sign is to make the environment variables and the user wishes to
convert the same.
- M to retain the same environment variable.
Password: 【Input super user's password】
2.1.1.9 Administration Command in Linux System
1.wall command
The function of this command is sending messages to all registered users, and the users
can write the msssage into a document, and then enter:
# Wall <file name
Then can send send message to all users.

59
In the above example, the symbol "<" that redirect input, about its meaning and usage
please refer to the relevant content in Chapter 10. For example:
# Wall 'Thank you!'
Broadcast message from root (tty1) Fri Nov 26 14:15:07 1999 ...
Thank you!
#
After the implementation of the above command, the user's screen shows "Thank you!"
will be shown in the user's screen without the system prompt $(#), and then press the
Enter key, the screen appears the system prompt.
2.write command
The function of the command write send a message to another user. The general form of
the order is as follows:
Write user account [end-name]
For example: $ write Guest hello
At this time the system go into a state of send a message, then the user can enter
message. When want to be out of the state, using the combination of keys <Ctrl + c> .
3.mesg command
The mesg utility will control whether other users are allowed to send messages
via write(1), talk(1), or other utilities to a terminal device. If allow others to send
messages, enter the command:
# Mesg y
Otherwise, enter:
# Mesg n
To the super-users, the system default value is n; and to the ordinary users system
default value is y. If the command mesg without any parameters, it shows the current
state is y or n.
4.sync command
Sync command is used in the close of Linux system. Users need to pay attention, you

60
can not shut down the system in the simple way that only turn off the power, because
Linux, the same to other Unix systems, there are a lot of data in memory cache, when
shut down the system, need to check synchronization between hard disk data and
memory data , and ensure that hard drive data is new when the system is closed, so it is
the only way to ensure that data will not be lost. The normal process to shut down the
system to carry out these tasks automatically ,and in the course of system operation such
work has been done from time to time which does not require user intervention. sync is
mandatory to write the data in memory into the hard disk, so as to avoid loss of data.
Users can use this command necessarily. The general form of the order as follows:
Sync
5. shutdown command
This command can shut down or restart the Linux system safely , and before close the
system it will send a warning message to all logged-on user. The order also allows the
user to specify a time parameter,which can be a precise time or can be a period of time
from now. the format of porecise time is that hh: mm, that stand for the hours and
minutes; "+" and the number of minutes stand for period of time.After the
implementation of the order system will automatically carried out the work of data
synchronization.
5.The general format of the command: shutdown [options] [time] [warning]
,themeaning of the various options of the command are as follows:
- K does not really shut down, only send a warning message to all users.
- R restart immediately after the shut down .
- H don't restart after shutdown.
- F quick shutdown.when restart the skip fsck.
- N fast shutdown, skip the process of init.
- C Cancel an already running shutdown.
Note that the order only used by the super-users.
6.Free order

61
The function of the command free is to find the usage of the current system memory, it
shows remainder memory in the system,the physical memory and the exchange
memory, as well as shared memory and the buffer used by core.
The general form of the order for: free [-b |-k |-m] .The meaning of the various options
of the command are as follows:
-B show in bytes.
-K show in K bytes.
-M show in megabytes.
7. Uptime command
This command can show how long the system has been up.The uptime command prints
the current time, the length of time the system has been up, and the average number
of jobs in the run queue over the last 1, 5 and 15 minutes. It is, essentially, the first
line of a w(1) command.The general format of the command: uptime
2.1.1.10 Disk Management Commands in Linux
1.df command
Function: displays number of free disk blocks and free files. The command can be used
to obtain the number of occupied hard disk space , how much space is still left and so
on.
Syntax: df [options]
Note: df command to display state of all the file system using the i-node and disk block .
The meaning of the various options of the command are as follows:
-a show usage of all the disk file system , including 0 (block) file system, such as the /
proc file system.
-K show in k bytes.
-I show the information of i-node rather than disk blocks.
-t showed the usage of the specified type of file system disk .
-x list disk space usage of file system that don't be specified (contrary to the t option).
-T showed the type of file system.
2.du command

62
du original meaning in English is "disk usage", meaning is that show the usage of disk
space.
Function: summarize disk usage
Syntax: du [options] [Names ...]
Note: The du utility writes to standard output the size of the file space allocated to,
and the size of the file space allocated to each subdirectory of, the file hierarchy rooted
in each of the specified files.If no file is specified, the current directory is used.
The meaning of the various options of the command are as follows:
-s Instead of the default output, report only the total sum for each of the specified
files
.-a In addition to the default output, report the size of each file not of type directory
in the file hierarchy rooted in the specified file
.-b Write the files sizes in units of bytes (system default to k bytes).
-k Write the files sizes in units of 1024 bytes
-c end with a final total (system default settings).
-l calculate the size of all files.To the hard-linked files, then the calculation many times.
-x Skip in different directories on the file system, not statistical.
3. dd command
Functions: The dd utility copies the specified input file to the specified output with
possible conversions.This command can play the role of the command diskcopy in the
DOS. First ,write the data on the floppy into a disk storage file with dd , then write this
storage files into the second floppy disk, and complete the function of diskcopy . It
should be noted that you should removed the storage file on your hard disk with
command rm . System default using the standard input file and standard output file.
Syntax: dd [option]
If = input file (or device name).
Of = output file (or device name).
ibs = bytesl, the bytes once read , that is the nunmber of bytes read into the buffer bytes.
skip = blocks ,skip the block-ibs * blocks read into beginning of the buffer zone

63
obs = bytes , the bytes once write , that is the nunmber of bytes write into the buffer
bytes.
bs = bytes ,the number of the bytes that set the read /write buffer at the same time
(equivalent to setting ibs and obs).
Cbs = byte, bytes in a conversion.
count = blocks ,only copy the importation blocks.
Conv = ASCII , converse EBCDIC code to ASCIl code.
Conv = ebcdic, converse ASCIl code to EBCDIC code
conv = ibm,converse ASCIl code to alternate EBCDIC code.
conv = block ,converse converted charaters into a fixed-bit characters.
conv = ublock,converse a fixed-bit characters into converted charaters.
conv = ucase,converse lowercase letters to uppercase letters .
conv = lcase,converse lowercase letters to uppercase letters .
Conv = notrunc ,not truncate the output file.
Conv = swab ,exchange every input byte.
conv = noerror ,does not stop processing with error.
conv = sync, transferred the size of every input to the size of ibs (filled with NUL).
4.fdformat order
Floppy disk is one of the storage medium users commonly used. The floppy disks must
be formatted before the operation, and then can use storing data command tar, dd,
cpio ,and can also create the file system which can install on a floppy disk .
Function: low-level formatted floppy disk
Syntax: format [-n] device
Note: the role of the command is formatted floppy disk.
-n after format the floppy disk do not do any examination.
Device specified format equipment, and usually is one of the following equipment:
/ Dev/fd0d360
/ Dev/fd0h1200

64
/ Dev/fd0D360
/ Dev/fd0H360
/ Dev/fd0D720
/ Dev/fd0H720
/ Dev/fd0h360
/ Dev/fd0h720
/ Dev/fd0H1440
2.1.1.11 Other Command in Linux
1.echo command
The function of the command echo is display a section of text in the screen. generally
played the role of a reminder.
The general format of the command: echo [-n] string
the option n means that output without wrap; the string can add quotation marks or not.
When output string which has not can add quotation,it will make the every word in the
string in to a string to output,and is separated by the space.
2.cal command
The function of the command cal is display a calendar
The general format of the command: cal [options] [month [year]] .The meanings of the
various options of the command are as follows:
- J shows the every day in the specified month is which day in the year, (begain from
the date of January 1).
- Y shows that the entire calendar of a year.
3.Date command
The function of the command date is displaing and setting the system date and time.
The general format of the command: date [option] .
The format of setting time
The meaning of the various options of the command are as follows:
-d datestr, - date datestr. show the date described by datestr
-s datestr, - set datestr .Set the date described by datestr

65
-U, - universal display or set the universal time
Time domain
% H hour (00 .. 23)
% I hour (01 .. 12)
% K hour (0 .. 23)
% L hour (1 .. 12)
% M minutes (00 .. 59)
% P shows AM or PM
% R Time (hh: mm: ss AM or PM), 12 hours
% S the number of seconds from January 1, 1970 00:00:00 to the current
% S second (00 .. 59)
% T time (24 hour) (hh: mm: ss)
% X display time format (% H:% M:% S)
% Z time zone ,the date of the domain
% a short name of the week (Sun.. Sat)
% A full name of the week (Sunday.. Saturday)
% b short name of the month (Jan.. Dec)
% B full name of the month (January.. December)
% C date and time (Mon Nov 8 14:12:46 CST 1999)
% D the first few days in a month (01 .. 31)
% D date (mm / dd / yy)
% h same as% b option
% J The first few days a year (001 .. 366)
% M month (01 .. 12)
% W the first few days a week (0 for Sunday)
% W the first few weeks a year (00 .. 53, on Monday for the first day)
% X shows the date format (mm / dd / yy)
% Y last two digits of the year (1999 99)

66
% Y year (example: 1970,1996, etc.)
【Note】Only super-user can get the privilege of using the date command to set up time,
the general users can only use the date command to display the time.
4. Clear command
The feature of the clear command is to remove information on screen, which is similar
to the “cls” command in DOS. After clearing the screen, the prompt moves to the upper
left corner of the screen.
2.1.1.12 Linux Using Tips
1. The use of the virtual console
When press on Alt + F2 key after log in, we can see the "login:" prompt again, this is
the second virtual console. Generally there are four virtual console in newly installed
Linux, you can use Alt + F1 ~ Alt + F4 to access. It is very useful when the input is
locked because of a program error, the virtual consoles can switch to other virtual
consoles.
2. Copy and paste
Character interface: after the installation either “RedHat” or “Slackware”, a program
called “gpm” will start automatically every time when they start, the mouse can be used
to copy and paste after the program runs. The specific approach is holding down the left
mouse button and dragging to make the copy area anti-white, the region of anti-white
now has been copied, and then the contents to be copied will be pasted at the cursor
location when press on the right mouse button. In the X-Window: the operation of the
copies is same with it on the character interface, if it is a three button mouse, click the
center button to paste. Press both buttons at the same time to paste if it is a two buttons
mouse, (should have to select “Emulate 3 Button” in the mouse settings when
configuring XF86).
3. Quick access to certain directories
Type “cd ~” can enter the user's home directory. Type “cd –” can enter a directory
accessed last time.
4. The use of floppy disk

67
If it is a “ext2” file system of Linux, use the following command: # mount-t ext2 /
dev/fd0 / mnt. If it is s floppy disk of dos format, use the command: # mount-t msdos /
dev/fd0 / mnt. And then will be able to visit the content of “/ mnt” floppy, and pay
attention to remove the file system in the floppy disk before taking out the floppy disk,
Otherwise “# umount / mnt” would result in the loss of information. the following
command can be used to establish file systems in the floppy disk: # mke2fs / dev/fd0
1440.
5. display color directory listing in RedHat
Open “/ etc / bashrc”, adding the following line: alias ls = “ls – color”. when you start
bash the next time a color list directory can be showed as in the “Slackware”, the
meanings of colors are as follows: blue  directory Green  executable file Red 
light Blue compressed files links Gray  other documents.
6. Show the types of documents
Command file can be used to make you know what is a file format ELF, is it executable
file or shell script file or any other format such as: # file startx.
7. The path to command file
Have you think about in which directory the documents are when you type a few
commands such as “find”, “shutdown”, “mount”, “startx”? It can be realized by using
the “Whereis” command, such as “# whereis startx”.
8. Find a document
It need to add some parameters to the “find” command to find the documents, such as:
“# find / usr-name XF86Setup-print” in the “/ usr” file to find where is the “XF86Setup”
file.
9. Delete unwanted core files
After running the program, a “core”-named document will be sometimes produced, the
document is no use and can be large in general, so it can be removed to free up space.
10. Untie “.Tar.gz” file at one time
Unting “.Tar.gz” file use “gunzip” to unzip first in general and then use “tar” to unpack,
it can be in Linux can be completed at one time, such as: #tar zxpvf sample.tar.gz.

68
11. Show the long file names in the win95 partition district
If you find the long file names can not be showed in the win95 partition district, it can
be re-used “vfat” way to “mount”. To modify the “/ etc / fstab” file when start the
mount partition district, replace the words “msdos” inside with “vfat”. If you can not
use “vfat mount”, you will have to recompile the core, adding the supporting of “vfat”.
12. “Norton Commander” in Linux
type in the commend “mc” with the command prompt, and you will see a interface very
similar to “Norton Commander”, in fact, the ability is very similar and even more
powerful, for example, it can operate the “Tar.gz” file in compression pack directly. (a
bit like ZipMagic).
13. X program running in the background
Do not forget to add a “&” at back when implementing the X program, such as “#
netscape &”. Otherwise you will no longer be able to prior to enter the command in the
terminal window before you exit the procedure.
14. Forced to withdraw from X
Sometimes the mouse and the keyboard both can not work because of an error in X, Do
not worry when this happens, because Linux will not be so vicious as in Win95 in the
crash, you can return to the interface character just by pressing “Ctrl + Alt + Backspace”
keys.
15. After reinstalled the Win9x, the “lilo” failures and can not start Linux
Only need to start Linux by using a floppy disk and then run “lilo” again. RedHat can
create a boot disk by using the “mkbootdisk” order, such as: mkbootdisk - devices /
dev/fd0 2.0.34-1. the “2.0.34-1” is a directory in “/ lib / modules”.
16. Change the dos/windows to OS booted default
RedHat take Linux as the OS of “lilo” that booted default, which is pressing enter to
start directly after the boot: prompt appears. If you want to change it to dos / Windows,
modify the “/ etc / lilo.conf” file, put the part of starting dos in the front and then run
“lilo” again. For example, change “lilo.conf” from:
boot = / dev / hda

69
map = / boot / map
install = / boot / boot.b
prompt
timeout = 50
image = / boot/vmlinuz-2.0.34-1
label = linux
root = / dev/hdc5
read-only
other = / dev/hda1
label = dos
table = / dev / hda
to:
boot = / dev / hda
map = / boot / map
install = / boot / boot.b
prompt
timeout = 50
other = / dev/hda1
label = dos
table = / dev / hda
image = / boot/vmlinuz-2.0.34-1
label = linux
root = / dev/hdc5
read-only
17. Remove lilo information from guiding area
After installing the “lilo”, any change of the circumstances of the number of hard disks
or partition district will lead to the hard disk could not be activated, now it only needs to
re-boot dos by a floppy disk and then run “fdisk / mbr”. (This method can also remove
any virus in the boot sector)

70
18. Save the information of “man” or “info” as a text file
Take “tcsh” as an example:
man tcsh | col-b> tcsh.txt info tcsh-o tcsh.txt-s
19. Take the current path as the prompt
To the bash, add “PS1 = "\ $ PWD \ \ $"” in the line “.Bashrc Riga”. To the tcsh, add
“set prompt ="%/>"” in the line “.Tcshrc Riga”:
20. Compress executable file
There is an order in Linux similar with “pklite” and “lzexe” in the dos -- gzexe. The
compression ratio can generally be more than 50%,it is very useful when space is tight.
For example:
/ dosc / temp # ls-al
total 148
-rwxr-xr-x 1 root root 149564 Dec 8 15:33 gawk
/ dosc / temp # gzexe
gawk gawk: 54.5%
/ dosc / temp # ls-al
total 216
-rwxr-xr-x 1 root root 68710 Dec 8 15:36 gawk
-rwxr-xr-x 1 root root 149564 Dec 8 15:33 gawk
/ dosc / temp #
21. See the information when Linux starts
The information showed in the screen when Linux starts flashes too fast to see the, if
interested, to view this information by using the command “dmesg” after start.
22. To deal with the document containing special characters in file names
If there is a file named “-file”, and you want to delete it, “invalid option” will shows
after typing “rm –file”, Linux take the file name as an option because of the first
character “-“, you can add “--“ to solve this problem such as “rm -- -file”. If they are
other special characters, you can add a “\” in the front of the special characters, or use
double quotes to enclose the entire file name.

71
23. deal an entire directory at the same time
many common commands such as “rm, cp” and so on in Linux / UNIX have one
parameter ---- -r, it is the meaning of recursive, adding parameters-r in order will make
it able to operate on the target directory and all of its subdirectories, such as : rm -rf /
test (f is “force” means force), the order completely removes the subdirectory of the root
directory, similar to “deltree” in dos, of course, be especially careful to use this
command. Another example: “cp-r / test / test1”, is similar with xcopy / s in dos.
24. To modify the registry screen
To local machine: modify the file “/ etc / issue” to be replaced with the content
displayed, and then modify the file “/ etc / rc.d / rc.local” (RedHat) or “/ etc / rc.d / rc.S”
(Slackware) to delete the following comment:
# This will overwrite / etc / issue at every boot. So, make any changes you
# Want to make to / etc / issue here or you will lose them when you reboot.
echo ""> / etc / issue
echo "Red Hat Linux $ R">> / etc / issue
echo "Kernel $ (uname-r) on $ a $ (uname-m)">> / etc / issue
cp-f / etc / issue / etc / issue.net
echo>> / etc / issue
Otherwise your / etc / issue will be changed each time you restart.
To the remote machine of telnet: first change the name of file “/ etc / usr / sbin /
in.telnetd”, such as read “in.telnetd.exe”, then made “in.telnetd” as the shell script, call
in.telnetd.exe after showing the contents needed. Such as:
The contents “echo -n “” exec / usr / sbin / in.telnetd.exe” needs to be showed before
“#! / bin / sh cat / etc / login.banner #” logs in the prompt
25. Some useful aliases
There is a few alias can make it easier to operate and reduce the disoperation, it is
recommended to put them into the start documents, such as “/ etc / bashrc”.
alias rm = 'rm-i'
alias cp = 'cp-i'

72
alias mv = 'mv-i'
The use of the first three aliases is confirming first before delete or overwrite files,
RedHat has been automatically added them, it is strongly recommended that the
Slackware users add it too, before once the files is deleted in Linux / UNIX, it will no
longer be able to resume.
alias l = ‘ls-l’
alias cd ..= ‘cd ..’
alias utar = ‘tar xvfz’ # solution the ‘*. tar.gz’ file
alias inforpm = ‘rpm-qpi’ # show the information of rpm packages
alias instrpm = ‘rpm-Uhv’ # install rpm package
alias listrpm = ‘rpm-qpl’ # display the files in rpm package
alias uistrpm = ‘rpm-e’ # anti-installed rpm package
26. Command-Line Completion
Command-Line Completion means that to when the characters typed in is able to
establish a unique file of the directory, it will fill in the remaining part of the file name
automatically only need to press the “Tab” key to, for example, to unpack the files “gcc-
2.8.1.tar.gz” in the directory “/ freesoft”, when it have typed to the “tar xvfz / freesoft /
g”, if the file is only the document begins with g in the directory, then we can press the
Tab key, then the command will be automatically filled for: tar xvfz / freesoft/gcc-
2.8.1.tar.gz, it is very convenient.
2.2 utility Linux system tools
2.2.1 RedHat Linux 9 package management tools
In the installation, users select the installation types such as "workstation" or "servers".
The packages are installed according to this choice. Because the methods and purposes
of computer users are different, they may want to install or remove some packages after
installation. Package management tools allow the user to implement such operations.
It needs X Window System to run Package management tools. To start this process,
click on the "main menu" => "System Settings" => "Add / Remove Applications" in the
panel or with the prompt of shell, type in the “redhat-config-packages” command.

73
If you insert Red Hat Linux CD # 1into the computer, you will see the same interface

Figure2-1 Package management tools


The program interfaces are similar to those used in the installation. Package is divided
into package groups, each group contains a standard package (standard packages) and
an extra packages which shares a common feature (extra packages). For example, the
group of "Graphical Internet" includes the World Wide Web browser, e-mail clients, as
well as other procedure used to connect to the Internet. You can not delete the standard
package, unless the entire package group should be deleted. As long as the package
group is elected, the additional package is the optional packages you can choose to
install or remove.
Main menu shows a list of package groups. If there is a symbol of choice in the check
box next to the package group, it shows that the group has been installed at present. To
view a list of the individual packages, click on the "details" button next to it. The single
package with a symbol of Choice has been installed at present.
2.2.1.1 Installing Packages
To install the standard package which has not yet been installed in the package group,
select the check box next to it. To customize the software packages which will be
installed in the package group, click the "details" button next to it. A list contains
Standards and additional packages will be displayed, as shown in Figure 33-2. Click the
name of the package, the disk space which is needed to install it would be shown in the

74
bottom of the window. To mark it as the package which is to install, click the check box
next to it.
You can also choose individual packages from the packages installed, the way is click
the “details” button, then choose any of the extra packages which has not been installed.

Figure 2-2 The choice of a single package


Chosen the package group and individual packages to install, click the "Update" button
on the main window. Then, the program will calculates the disk space required for the
installation of packages, and the package dependencies, and displays a summary
window. If package dependencies exist, they will be automatically added to the list of
the package to be installed. Click on "show details" button to see a complete list of
packages to install.

75
Figure 2-3 the summary of the package installation
Click "Continue" to start the installation process. When it ended, the message "Update
completed" will appear.
2.2.1.2 Remove a package
To delete all packages in a package group, deselect the check box next to it. To delete a
single package group, click "details" button next to the package group, and then de-
select a single package.
When you have chosen the packages to delete, click the "Update" button of the main
window. The program will calculate the free space it would release and the package
dependences. If other packages depend on the package you choose to delete, they will
automatically be added to the package to be deleted list. Click on "show details" button
to see a list of packages you want to delete.
2.2.2 users and configuration groups of RedHat Linux 9
2.2.2.1 Users Manager
Users Manager allows you to view, modify, add and delete local users and groups.
To use the Users Manager, you must run the X Window System, have the root
privileges, and the redhat-config-users RPM package must be installed. To start User
Manager from the desktop, click the "main menu" => "System Settings" => "Users and
Groups" on the panel, or type the command of redhat-config-users whith the prompt of
shell (such as XTerm or GNOME terminal) .

76
Figure 2-4 Red Hat User Manager
To check the list including all the local users of system, click the tab "User". To check
list of all the system's local groups, click on "groups" tab.
If you need to find the specified user or group, type the first few characters of the name
in the "Search Filter" field. Then press [Enter] key or click the "Apply Filter" button.
The list filtered will be displayed.
To sort users and groups, click on the name of the list. User or group will be sorted out
in accordance with the information of this list.
The User IDs below 500 are reserved to system users by Red Hat Linux .The user
Manager does not display system users by default. To check all users including the
system user, do not select "Preferences" => "filtration system users and groups." from
the drop-down menu.
To view the additional information about Users and groups on, please refer to "Red Hat
Linux Reference Guide" and "Red Hat Linux system administration handbook of
Enlightenment."
1. Add a new user
To add a new user, click on "Add User" button. A window as shown in Figure 25-2 will
appear. In the appropriate field, type the new user's user name and full name. In the
"Password" and "confirm password" field, type a password. Password must be at least
six characters.
【 Note 】 The longer the user's password, the harder others will guess the password,

77
which will log on to the user's account without permitted. We also recommend that you
do not choose a password based on ready-made phrases, the password is better to be a
combined with letters, numbers and special characters.
Select a shell to log in. If you are not sure which shell should be chosen , please accept
the / bin / bash by default. The default home directory is / home / user name. You can
change the home directory created for the user, or de-select the "Create a home
directory" to not create a home directory for the user.
If you choose to create a home directory, the default configuration file will be copied to
the new home directory from the / etc / skel.
Red Hat Linux uses user private group (user private group, UPG) programs. The UPG
program does not add or change the standard method the UNIX used to deal with
groups; it merely provides a new agreement. According to the default settings, whenever
you create a new user, a unique group named same as the user will be created. If you do
not want to create this group, de-select " Create private groups for users."
To specify a user ID for Users, select “Specify a user ID manually ". If this option is not
selected, the next available user ID after the number 500 will be assigned to new users.
The User IDs below 500 are reserved to system users by Red Hat Linux.
Click "OK" to create the user.

78
Figure 2-5 Create a new user
To configure more advanced user attributes (such as password expiration), or modify
user attributes after adding the user, see the next section.
To add User into more users groups, click the "User" tab, select the user, and then click
"Properties." In the "User Properties" window, select "Groups" tab. Select the group and
the main user groups you want the user to join in, and then click "OK."
2. Modify user attributes
To view the attributes of an existing user, click on the "user" label, select the user from
the user list, and then click the button "Properties" in the menu (or select "action" =>
"Properties" from the drop-down menu). A diagram window similar as the following
will appear.

79
Figure 2-6 User Attributes
"User Attributes" window has been divided into a number of loose-leaves with labels:
"user data" - shows the basic user information configured when you add a user. Use this
tab to change the user name, password, home directory or login shell.
"account information" - if you want the account expired when reaches a fixed date,
select the "Enable account expired." Enter the date in the field provided. Select "User
account has been locked" to lock the user account, so that users can not log in the
system.
"Password Information" - the label shows the latest date when the user’s password was
changed. To force the user to change the password after a certain number of days, select
"Enable Password expired." You can also set the number of days to go through before
allowing users to change a password, the number of days to go through the user is
warned before changing the password, and the number of days to go through before the
account becomes inactive,.
Group - Select the group you want the user to join in, as well as the main user groups.
3. Add a new group
To add a new user group, click the "Add group" button. A similar window as Figure 25-
4 will appear. Type the new name of the group to create. To designate the new group ID

80
for new groups, select “specified group ID manually ", then select the GID. Red Hat
Linux reserves the groups of less than 500 for system ID group.
Click "OK" to create a group. The new group will appear in the list of groups.

Figure 2-7 create a new group


To add users to groups, see the next section.
4. Modify group properties
To view the properties of an existing group, select the group from the group list, and
then click on "Properties" button in the menu (or select "File" => Properties in the drop-
down menu). A similar diagram window as following will appear.

Figure 2-8 Attribute group

81
The "User groups" tab shows the users who are the members of groups. Select other
users to join the groups, or de-select the users to remove them from the groups. Click
"OK" or "application" to modify the user group.
2.2.2.2 Command-line configuration
If you prefer to use command-line tool, or do not have X Window System, please refer
to the following sections of this chapter to configure the users and groups.
1. Add User
To add users in the system:
1) Use the “useradd” command to create a locked user account:
useradd <username>
2) Use the “passwd” command, to unlock a certain account by the assignment of
passwords and password aging rules :
passwd <username>
the command-line options of “useradd” in are listed in Table 2-1.
Table 2-1:
Option Description
-c comment Users’ notes.
-d home-dir To replace the default home directory of /
home / username.
-e date the date of disable account, the format is
YYYY-MM-DD
-f days After password is expired, the number of
days before disables the account (if
designated 0, the account after the
password is expired will be immediately
banned. If -1 is specified, when password
is expired, the account will not be
disabled).
-g group-name The name of the default user group or the

82
Option Description
numbers of groups (the group must exist
before it is specified).
-G group-list the user is a member of additional groups
or group number (other than the default)
a list of comma-separated (the group
must exist before it is specified).

-m If the home directory does not exist then


create it.
-M Do not create home directory.
-n Do not create a private user group for the
user.
-r Create a system account whose UID is
less than 500 without home directory.
-p password Using the password encrypted with crypt.
-s The user's login shell, the default for / bin
/ bash.
-u uid The user's UID, it must be unique, and
more than 499.
2. Add a group
Add a group into the system, use the “groupadd” command:
groupadd <group-name>
The options of groupadd command line have been listed in Table 2-2.
Table 2-2:
Option Description
-g gid The group GID, it must be unique, and
more than 499.
-r To create a system groups less than 500.

83
Option Description

-f If the group already exists, exit and


display an error (the group will not be
changing). If you specify the options of -
g and -f, and group already exist, the
option of -g will be ignored.

3. Password aging
For security purposes, if requires the users change their passwords regularly, you can
manage it when add or edit the users in the user's "Password Information" tab.
To configure the profile password expired with the shell prompt for user, use the chage
command, then use the options in Table 2-3, as well as the user's user name.
Table 2-3:
Option Description
-m days Specify the least number of days by
interval that the user must change
password. If the value is 0, passwords
will not expire.
-M days Specify the most number of effective
days. When the number of days specified
by this option adds the number of days
specified by the -d option less than the
current date, the password must be
changed before the user uses the account.
-d days Specify the number of days the password
was changed since January 1, 1970.
-I days The number of inactive days before the
account is locked after the specified

84
Option Description
password expired. If the value is 0,
account will not be locked after the
password is expired.
-E date Specify the date when account is locked,
the date format is YYYY-MM-DD. If no
date the number of days after since
January 1 1970 can also be used.
-W days Specify the number of days warning users
before password is expired.

【Note】 If to use “chage” command, the shielding password must be enabled. If the
“chage” command is followed closely by the user name (no other options), it will
display the value of the current password aging and run these numerical values have
been changed.
If system administrators want users to set password to login the first time, the user's
password can be set to expire immediately, which forced users to change it immediately
after users log on for the first time,.
To force users to configuration password when log on to the console the first time,
please follow these steps. Note that if users use agreement of SSH to log in that this
process will not do.
1) Lock the user's password - If the user does not exist, use the “useradd” command to
create the user account, but do not give any password to it, so it is still locked.
If the password has been enabled, use the following command to lock it:
Usermod -L username
2) Immediate mandatory password expiration - Type the following command:
Chage -d 0 username
This command set the last date the password changed for the epoch (January 1 1970).
Regardless of whether there is Password expiration policies, this value will force

85
password expired immediately.
3) To unlock accounts - there are two commonly used methods to achieve this purpose.
An administrator can assign an initial password or empty password.
【 Warning 】 Do not use “passwd” to set the password, because it will disable the
password just be configured to expired instantly.
4) To assign an initial password, follow these steps:
use python command to start the python interpreter of command-line. It is shown as
follows:
Python 2.2.2 (# 1, Dec 10 2002, 09:57:09)
[GCC 3.2.1 20021207 (Red Hat Linux 8.0 3.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>>

With the prompt, type the following command (to replace the “password” with the
password to be encrypted, replace the “salt” with the two upper or lowercase letters,
numbers, characters or a slash character points, such as “+ ab” or “+ 12”):
import crypt; print crypt.crypt ( "password", "salt")
The output encrypted password is similar to 12CsGd8FRcMSM.
Type [Ctrl] - [D] to withdraw from the Python interpreter.
cut and paste the output encrypted password to the following command (without taking
the spaces of the lead and in the end):
usermod-p "encrypted-password" username
5) rather than assigning initial password, you can also use the following command to
assign empty Password:
usermod-p "" username
6) In either case, after login for the first time, the user will be prompted to enter a new
password.
【Note】 It is easy to use empty passwords for users and administrators, but it comes
with a minor risk - third-party can be the first to log in and enter the system. To reduce
this threat, recommend that the administrator should check if the user has to do a good

86
job for the registry ready when unlock the account.
2.2.2.3 Explain the process
The following steps demonstrate the situations after using the command “useradd nari”
in the system of enable the shield password:
1. Add a line of nari to the file / Etc / passwd. The characteristics of this line are as
follows:
It begins with the user name of nari.
There is an "x" in the password field, means the system is using the shielding password.
UID is created.
GID is created.
GECOS optional information is blank.
Nari’s home directory is set to / home / nari /.
The default shell is set to / bin / bash.
2. Add a line of nari to the file / Etc / passwd. The characteristics of this line are as
follows:
It begins with the user name of nari.
The two exclamation mark (!!) appeared in the / etc / shadow file password field in will
lock the account.
【Note】 If an encrypted password using the-p signs passed, the password will be placed
in the / etc / shadow file for the users of that line.
Password is set to never expire.
3. A line of the message group about nari is added in / Etc / group file. The group
with a same name of users is called user private group (user private group). To view the
details of private user groups, please refer to section 2.2.2.1.
The characteristics of the additional lines in / etc / group file are as follows:
It begins with the groups’ name of nari.
There is an "x" in the password field, means the system is using a shielding password.
GID is the same with and the user nari in the list / etc / passwd file.
4. The line of the “nari” group is added into / Etc / gshadow document on. The
characteristics of this line are as follows:

87
It begins with the groups name of nari.
An exclamation mark (!) appeared in the / etc / gshadow document password field will
lock this group.
All other fields are blank.
5. The directory for Nari user is created in / home / directory. The directory is both for
the user nari and the group nari. Its read and write and execute permissions is for users
nari only. All other rights are denied.
6. The files in / Etc / skel / directory (including the default user settings) are copied to
the new / home / nari / directory.
At this time, there is a locked account called nari in the system. To activate it, the
administrator must use the passwd command to assign a password for the account, or set
password aging rules.
2.2.3 RedHat Linux 9 Network Configuration
Computers need a network connection to communicate with other computers. It is
achieved by recognizing the operating system interface card (such as: Ethernet card,
ISDN modems, token ring), and configuring the interface to connect to the network.
Network management tools It can be used to configure the following types of network
interface:
Ethernet
ISDN
Modem
xDSL
Token ring
CIPE
Wireless devices
To use the network management tools, you must have root privileges. To start this
process, click the "main menu" => "System Settings" => "network" on the panel, or
with the prompt of shell (such as XTerm or GNOME terminal) to type the “redhat-
config-network” command. If you type this command, and if X is running, the graphical

88
version will be displayed, otherwise, text-based version will be displayed. to run text-
based version compulsorily, use the “redhat-config-network-tui” command.

Figure 2-9 Network Management Tools


If you prefer to modify the configuration file directly, please refer to the "Red Hat Linux
Reference Guide" to obtain information about the location of these configuration files
and the content.
【Note】 visit the Red Hat Hardware Compatibility List
(Http://hardware.redhat.com/hcl/) to determine whether or not Red Hat Linux supports
your hardware.
To use the network management tools to configure network connectivity, perform the
following steps:
1. Add the physical hardware device to the hardware list.
2. Add the network equipment related with the physical hardware.

89
3. Configure the host name and DNS settings.
4. Configure the console you can not search through the DNS.
This section will discuss every step of the above for each type of network connection.
2.2.3.1 To establish Ethernet connectivity
To set up Ethernet connectivity, you need a network card (NIC), a network cable
(usually a CAT5 cable), and the network to connect to. Different network configurations
use different speeds, make sure that your NIC and the network you want to connect are
compatible.
To add Ethernet connectivity, follow these steps:
1. Click on the "Equipment" tab.
2. Click on the "New" button in the toolbar.
3. Select the "Ethernet Connection" from the "device type" list, and then click
"forward."
4. If you have added the network card to the hardware list, select it from the "Ethernet
card" list. Otherwise, choose "other Ethernet card" to add the hardware device.
【Note】installation process usually detects supported Ethernet devices and prompts you
to configure them. If you have configured the Ethernet equipment in installation, they
will appear in the hardware list of the "hardware" tab.
5. If you chose "Other Ethernet Card", the "opt-Ethernet adapter" window will appear.
Select the Ethernet card manufacturer and model. Select the name of the device. If it is
the first Ethernet card, select eth0 as the device name; if it is the second Ethernet card,
select eth1 as the device name; and so on. Network management tool also allows you to
configure resources for the NIC. Click "Forward" to continue.
6. on the "Configure Network Settings" page (as shown in Figure 2-10), you can choose
DHCP or static IP address. If the equipment is designated a different IP address each
time the network is started, do not specify its host name. Click "Forward" to continue.
7. Click on "Create Ethernet equipment" on the "Apply" button.

90
Figure 2-10 Ethernet settings
After the Ethernet device is configured, it will appear in the equipment list as shown in
Figure 2-11.

Figure 2-11 Ethernet equipment


Make sure save changes by choosing "file" => "Save" to.
After adding the Ethernet device, you can choose it from a list of the equipment, and
then click the "Edit" to edit its configuration. For example, when a device is added, it is
configured as guided to activate by default. To change this setting, select editing the
device, modify the value of “when the computer starts to activate equipment", and then

91
save the changes.
When equipment is added, it will not be activated immediately, you will see the
"inactive" status. To activate a device, select it from the device list, and then click on the
"activate" button. If the system is configured to activate the equipment when the
computer starts (default), you do not have to re-run this step.
If an Ethernet device is associated with more than one device, the device later is an alias
(device aliases). Device alias allows you to set up a number of virtual devices for a
physical device, so a physical device can have multiple IP addresses. For example, you
can configure eth1 and eth1: 1 device. For further information, please see the next
section.
2.2.3.2 To establish modem connection
The modem can be configured through an active Internet telephone lines connection.
You need an Internet service provider (ISP) account (also known as dial-up account).
To add a modem connection, follow these steps:
1. Click on the "Equipment" tab.
2. Click on the "New" button in the toolbar.
3. Select the "modem connection "from the "device type" list, and then click "forward."
4. If you already have a configured modem in the list of the hardware (in the "hardware"
tab), network management tools assume that you use it to create a modem connection. If
you do not have a configured modem, it will attempt to detect a modem in the system.
Detection may take some time. If it finds a modem, a message will appear, warning you
that the configuration displayed is not the value found in the detection.
5. After detection, a window as shown in Figure 2-14 will appear.

92
Figure 2-14 Modem settings
6. Configure modems, the baud rate, flow control, and modem volume. If you do not
know these values, but the modem was successfully detected, then accept the default
values. If you do not have the connecting way of touch-tone telephone, de-select the
corresponding check box. Click on "forward."
7. If your ISP is in the pre-configured list, select it. Otherwise, enter the information
about your ISP account. If you do not know this information, please contact your ISP.
Click on "forward."
8. In the "IP Settings" window, select the "package approach" which is to use, as well as
obtain the IP address through DHCP or set it statically. Then click "forward."
9. In the "establishment of a dial-up connection" page, click on the "Application."
After configuring the modem device, it will list on the device as "modem" device, as
shown in Figure 2-15.

93
Figure 2-15 modem equipment
Make sure to save changes by choosing "file" => "Save".
After adding the modem device, you can choose it from a list of its equipment, and then
click the "Edit" to edit its configuration. For example, when a device is added, it is
configured to activate when guided by default. You can edit its configuration to modify
the settings. Compression, PPP options, login name, passwords, etc. can be changed.
When equipment is added, it will not be immediately activated, you will see the
"inactive" status. To activate a device, select it from the device list, and then click on the
"activate" button. If the system is configured to activate the equipment when the
computer starts (default), you do not have to re-run this step.
2.2.3.3 DNS settings Management
DNS tab allows you to configure the system host name, domain, name server and search
domain. The name server is used to search other hosts on the network.
If the DNS server is to be retrieved from DHCP or PPPoE (or retrieved from the ISP),
do not add the main, secondary or tertiary DNS servers.

94
If the host name is to be retrieved dynamically from DHCP or PPPoE (or retrieved from
the ISP), please do not change it.

Figure 2-23 DNS Configuration


【Note】 The part of the name server is not used to configure the system to be the name
server, but used to configure to resolve IP address of the system and the name server
used by host name.
2.2.3.4 Host Management
"Host" tab allows you to add, edit, or delete the host from the file of “/ etc / hosts”. The
file contains IP addresses and their corresponding host name.
When your system attempts to resolve the IP address to host name or determine the IP
address to be the host name, before it uses the name server please first reference to /
etc / hosts file (if you are using the default Red Hat Linux configuration). If the IP
address is listed in the / etc / hosts file, the name server will not be used.
If your network is not listed in the DNS with the IP address, recommend that you add
them to / etc / hosts file.

95
To add the item to / etc / hosts file, click on the "New" button under the "Host" tab and
provide the information requested, and then click "OK." Choose "File" => "Save" or
press [Ctrl] - [S] to save the changes to / etc / hosts file. You do not have to restart the
network or network services, because the document will be referenced when each
address is being resolved.
【 Warning 】 do not delete the localhost item. Even if the system does not have the
network connection or continue to run the network connection, some procedures still
need to connect to the system through the localhost interface.

Figure 2-24 Host Configuration


【 Note】 to change the search order, edit the document of / etc / host.conf. The line
“Order hosts, bind” specifies the / etc / hosts in preference to the name server. Change
this line order bind, hosts will configure your system the first to use the name server to
resolve host names and IP addresses. If the IP address can not be resolved through the
name server, your system will search IP address in the / etc / hosts file.
2.2.3.5 Activating device

96
Network equipment can be configured to be active or inactive when guided. For
example, the network equipment a modem connected to generally not been guided start-
up; and Ethernet connections are usually guided to start. If your network equipment is
configured to start when not guided, you can use the Red Hat Control Network program
to activate it after guiding. To activate it, click on the "main menu" => "System Tools"
=> "Network device control" on the panel, or type the command “redhat-control-
network”.

Figure 2-25 activation device


To activate a device, select it from the list, click on "activate" button. To stop the device,
select it from the list, and click on the "disarmament."
If equipped with more than one network configuration file, they will be listed in the
interface and can be activated. For further information, please see the next section.
2.2.3.6 Use the configuration file

97
Each physical hardware device can create multiple logical network equipment. For
example, if your system has an Ethernet card (eth0), you can use different nicknames
and different configuration options to configure the logical network equipment. These
devices are associated with eth0.
The logic of network equipment and equipment aliases are different. And the logic
network equipments associated with the same physical device must exist in different
configuration files, and can not be activated at the same time. Equipment alias is also
associated with a same physical hardware device, but equipment alias associated with
the same physical hardware can be activated at the same time. The details about creating
an alias on the equipment, please see the next section.
Profiles (Profiles) can be used to create multiple profiles set for different networks. The
collection configuration not only has host and DNS settings, but also can include logic
devices. After configuring the configuration file, you can use network management
tools to switch between them.
In accordance with the default settings, including a configuration file of “public." To
create a new profile, select "profile" => "New" and then enter a unique profile name.
If you are now in the process of amending the new configuration file as shown in the
status bar at the bottom of the main window.
Click a equipment has been existed in the list, and then click "Copy" button to copy an
existing equipment to the logic network equipment. If you use the "new" button, a
network alias will be created, this is not correct. To change the properties of logic
devices, select it from the list, and then click on "Edit." For example, the nickname can
be changed to be a more descriptive name, such as eth0_office, so it can be identified
more easily.
In the device list, there is a list of check box marked as a "profile" of. For each profile,
you can select or deselect equipment. Only choose the equipment included in the current
configuration file which is selected now. For example, if you created a logic device
called eth0_office in a configuration file called the Office, and would like to be activate
the logic equipment when the configuration file is selected, de-select eth0 device, and

98
select eth0_office equipment.
For example, Figure 2-26 shows a configuration file called “Office” with a logic device
called “eth0_office”. It is configured to activate the first Ethernet card by using DHCP .

Figure 2-26 Office Profile


Note that as shown in Figure 2-27, the logic device called “eth0_home” is activated by
the Home profile, the device associated with eth0.

Figure 2-27 Home Profile


You can also configure eth0 to activate Office configuration file only, and only activate
ppp (modem) device in the Home profile. Another example is activating eth0 by the

99
"common" configuration file, and activating the ppp device by the using of
configuration files when traveling.
The configuration file can not be activated when guided. It can be activated when
guided only when it is set up in the guide device that activated when guided in the
"common" configuration file (the default configuration file). After the system is guided,
click the "Main Menu" => "System Tools" => "Network Device Control" on the pane
(or type the redhat-control-network command) to select a configuration file and activate
it. The part of the activation profile will appear in the “network device control” interface
only when you have other configuration files in addition to the default "public" profile.
Or, use the following command to activate the configuration file (to replace
<profilename> to be the profile name):
redhat-config-network-cmd -- profile <profilename> - activate
2.2.3.7 Devices aliases
Device aliases are virtual devices associated with the same physical hardware, but they
can be activated at the same time and have different IP addresses. They are usually
represented by using the device name, a colon and a number (for example: eth0: 1).
They will be useful when there is only one network adapter when you want give system
a number of IP addresses.
After configuring the Ethernet device, such as eth0, it needs to use a static IP address
(DHCP can not use an alias), go to "equipment" tab and click "New." Choose the
Ethernet card configured alias, set the static IP address of the aliases, and then click on
the "Application" to create it. Because the equipment Ethernet card has already existed,
it was only an alias just created, such as eth0: 1.
【Warning】 If you want to configure an alias to the Ethernet device, then the equipment
and the use of an alias can not configure to use DHCP. You have to manually configure
the IP address.
Figure 2-28 shows an alias of the eth0 device. Attention to eth0: 1 device - the first alias
of eth0. The second alias of eth0 will be eth0: 2, and so on. To modify the device alias
settings, such as whether or not to activate when guided, or an alias number, select it

100
from the list, and then click the "Edit" button.

Figure 2-28 the example of alias network equipment


Select an alias, click on the "activate" button to activate the alias. If you configured
multiple profiles, choose the configuration file including it.
To check whether the alias is activated or not, use the “/ sbin / ifconfig” command. Its
input should be indicated that the equipment and equipment have different alias IP
Addresses:
eth0
Link encap: Ethernet HWaddr 00: A0: CC: 60: B7: G4
inet addr: 192.168.100.5 Bcast: 192.168.100.255 Mask: 255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1
RX packets: 161930 errors: 1 dropped: 0 overruns: 0 frame: 0
TX packets: 244570 errors: 0 dropped: 0 overruns: 0 carrier: 0
collisions: 475 txqueuelen: 100
RX bytes: 55075551 (52.5 Mb) TX bytes: 178108895 (169.8 Mb)
Interrupt: 10 Base address: 0x9000
eth0: 1

101
Link encap:Ethernet HWaddr 00:A0:CC:60:B7:G4
inet addr:192.168.100.42 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0x9000
lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:5998 errors:0 dropped:0 overruns:0 frame:0
TX packets:5998 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1627579 (1.5 Mb) TX bytes:1627579 (1.5 Mb)
2.2.4 Network File System (NFS)
Network File System (NFS) is a way to share documents between the machines on the
network, just like the documents are at the local hard drive of the customers. Red Hat
Linux can be either an NFS server or be NFS clients, which means that it can export the
file system to other systems, it can also be mounted from other machines into the file
system.
2.2.4.1 Why is the use of NFS
NFS is very useful for multiple users to share the directory on the same network. For
example, a group of users committed to the same project can access the document of the
project by using a shared directory mounted as a / myproject in the NFS file system
(often called as NFS share). To access the shared files, users enter “/ myproject”
directory on their machine. This method does not have to enter the password or
remember the special orders, as if the directory is located on the user's local machine.
2.2.4.2 Mounting NFS file system
Use mount command to mount the NFS file system on another machine:
mount shadowman.example.com: / misc / export / misc / local
【Warning】the mount point directories on the local machines (“/ mnt / local” in the

102
example above) must exist.
In this order, “shadowman.example.com” is host name of the NFS file server; “/ misc /
export” is the file system which will be exported by “shadowman”; “/ misc / local” is
the mount position of the file system on the local machine. After the mount command
runs (and if a customer has the correct permissions from shadowman.example.com NFS
server), customers can implement the “ls / misc / local “command to display the file list
in the “shadowman.example.com on / misc / export” directory.
1. using “/ etc / fstab” to mount NFS file system
Another way to mount the NFS share on other machines is adding one line in “/ etc /
fstab” file. This line must state the NFS server host name, the directory it necessary to
export, and the directory of local machine to mount NFS shared. You must be a root
user to modify / etc / fstab file.
the general grammar of each line in “/ etc / fstab” is as follows:
server: / usr / local / pub / pub nfs rsize = 8192, wsize = 8192, timeo = 14, intr
Mount point “/ pub” must exist on the client machine. After adding this line into the “/
etc / fstab” file on the client systems, type the command “mount / pub” with the prompt
of shell, and the mount point / pub which will be mounted from the server.
2. Use “autofs” to mount NFS file system
the third approach to mount NFS share is using “autofs”. “autofs” uses “automount”
daemon to manage your mount point, it mounts them dynamically when the file system
is visited.
“autofs” advises master map configuration file “/ etc / auto.master” to determine which
mount point should be defined. Then, it uses the parameters applied to every mount
point to start the “automount” process. Each configuration line in the Main mapping
defines a mount point, a separate mapping file defines the file system which would be
mounted under the mount point. For example, the “/ etc / auto.misc” document may
define the mount point of “/ misc directory”; this relationship will be defined in the / etc
/ auto.master file.
The “auto.master” file has three fields for each item. The first field is the mount point.

103
The second field is the location of mapping file, the third field is optional. The third
numerical fields may include information like overtime value.
For example, to mount “/ project52” from the “penguin.example.net” remote machine
directory to the “/ misc / myproject” mount point on your machine, add the following
line into the “auto.master” file:
/ misc / etc / auto.misc - timeout 60
Add the following line into the “/ etc / auto.misc” file:
Myproject -rw, soft, intr, rsize = 8192, wsize = 8192
penguin.example.net: / proj52
The first field of “/ etc / auto.misc” is the name of “/ misc” subdirectory. The directory
is created dynamically by “automount”. It should not be actually exists in the client
machine. The second field includes the mount options, such as: -rw on behalf of read
and write access. The third field is the location NFS exported to, including the host
name and directory.
【Warning】the “/ misc” directory must exist in the local file system. There should be no
subdirectories in the “/ misc” directory on local file system.
“autofs” is a service. To activate the service, type the following command with the
prompt of “shell”:
/ sbin / service autofs restart
To view the active mount point, in the shell prompt type the following command:
/ sbin / service autofs status
If you modified the “/ etc / auto.master” configuration file when “autofs” is running,
you must type the following command with the prompt of “shell” to notify the
“automount” daemon to reload the configuration file:
/ sbin / service autofs reload
To learn how to configure “autofs” to start at boot time, see the information of Linux on
the management of services.
2.2.4.3 Export NFS files system
Share files From the NFS server to, also known as the export directory. NFS server

104
configuration tool can be used to configure the system to be the NFS server.
To use the NFS server configuration tool, you must run the X Window System, have
root privileges, and install the “redhat-config-nfs” RPM package. To start this process,
click the "main menu" => "System Settings" => "Server Settings" => "NFS server" on
the panel, or type the “redhat-config-nfs” command.

Figure 2-29 NFS server configuration tool


To add an NFS share, click the "Add" button. A dialog box as shown in Figure 16-2 will
appear.
"Basic” loose-leaf labeling requires the following information:
"directory" - specify the directory to share, such as” / tmp”.
"host" - specify the hosts to share the directory. Please refer to section 16.3.2 to obtain
the explanation of the format.
"basic rights" - the specified directory should have permissions to read and write or
read-only access

105
Figure 2-30 add a sharing
"General Options" loose-leaf tab allows you to configuration the following options:
"Allow the link from port above 1024” - starting the service in the port less than 1024
number must be root user. Choose this option to allow users other than root user to start
NFS services. The options are corresponding with insecure.
"Allow locking unsafe files" - do not need lock requests. The options are corresponding
with the “insecure_locks”.
"Disable subtree checking" - If a file system subdirectory is derived, but not the entire
file system, the server will check if the requested documents are in the export
subdirectory. This check is called subtree checking. Choose this option to disable
subtree checking. If the entire file system was exported, choosing disable subtree
checking can increase the transmission rate. This option is corresponding with
“no_subtree_check”.
"synchronous write operation as required" – it is enabled by default, this option does not
allow servers to reply the request before writing the requests into the disk. The option is
corresponding with the “sync”. If it was not chosen, the “async” option will be used.
"mandatory synchronous write operation immediately" - not to postpone the operation
of the disk write. The option is corresponding with the “no_wdelay”.
"User access" the loose-leaf tab allows you to configure the following options:

106
"Take a remote root user as local root user" - accordance to the default settings, the root
user's user ID and group ID both are 0. Root squashing map the user group ID 0 and ID
0 to be anonymous users and group ID, so the customer root user will not have root
privileges on the NFS server. If this option is selected, the root user will not be mapped
to be the anonymous user, the customer root user will have a root privilege of the export
root directory. Choosing this option will greatly reduce system security. Please do not
select it unless necessary. The option is corresponding with “no_root_squash”.
"Take all client users as anonymous users" - If this option is selected, all user and group
IDs will be mapped to anonymous users. The option is corresponding with “all_squash”.
“Specify a local user ID for the anonymous user” - if “Take all client users as
anonymous users” had been selected, this option will let you specify a group ID for the
anonymous user. The option is corresponding to “corresponds to anonuid”.
“Specify a local group ID for the anonymous user " - if " Take all client users as
anonymous users " had been selected, this option will let you specify a group ID for the
anonymous user. The option is corresponding to “corresponds to anonuid”.
To edit the NFS share, select it from the list, then click on "Properties" button. To delete
an existing NFS share, select it from the list, then click on "delete" button.
After clicking the "OK" from the list to add, edit, or delete an NFS share, the change
will take effect immediately - the server daemon will be restarted, the original
configuration files are saved as “/ etc / exports.bak”. The new configuration files will be
written in “/ etc / exports”.
NFS server configuration tool reads and writes “/ etc / exports” configuration file
directly. Therefore, this document can be modified manually after using the tool; this
tool can also be used after modified the document manually (assuming using the correct
syntax when changes it manually).
2.2.4.4 command-line configuration
If you prefer to use a text editor to edit the configuration file, or you do not have X
Window System, you can directly modify the configuration file.
The “/ etc / exports” file controls what directory the NFS server will export. Its format is

107
as follows:
directory hostname (options)
The option need to specify only is one of “sync” and “async” (recommended using
“sync is recommended”). If you specify a sync, the server will not reply the requests
before the changes requested have been written into the disk.
For example:
/ misc / export speedy.example.com (sync)
will allow users from “speedy.example.com” mounting “/ misc / export” with the
default read-only permissions, but:
/ misc / export speedy.example.com (rw, sync)
will allow users from “speedy.example.com” mounting “/ misc / export” with reading
and writing permissions.
Please refer to the next section to obtain the interpretation of format of the host name.
Please refer to "Red Hat Linux Reference Guide" to obtain a list of options can be
specified.
【 Note 】 Please manage spaces in the “/ etc / exports” file carefully. If there are no
spaces between the host name and the options in brackets, these options will only be
used on the host name. If there are spaces between the host name and options, these
options will be the overall application. For example, please read the following lines
carefully:
/ misc / export speedy.example.com (rw, sync) / misc / export
speedy.example.com (rw, sync)
The first line gives read and write permissions to the users from “Speedy.example.com”
and reject all other users. The second line gives read-only permissions to the users from
“Speedy.example.com” (default setting), and gives all other users read and write
permissions.
Each time when you change your “/ etc / exports”, you need to notify the NFS daemon
the change, or using the following command to reload the configuration file:
/ sbin / service nfs reload

108
2.2.4.5 the format of Host Name
Host can use the following format:
single machine - a fully limited domain name (can be parsed by the server), the host
name (can be parsed by the server), or IP address.
A series of machines using specified wildcard - the use of Characters like "*" or "?" to
specify the match string. Wildcards can not be used in IP addresses; if the reverse DNS
search fails, a wildcard may happen work. When you specify a wildcard in the fully
limited domain name, the point (.) will not included in the wildcard matching items. For
example: “*. example.com” includes “one.example.com”, but does not include
“one.two.example.com”.
IP network - using the “a.b.c.d / z”, “a.b.c.d” is the network, “z” is the number of bits in
the subnet mask (such as 192.168.0.0/24). Another acceptable format is “a.b.c.d /
netmask”, “a.b.c.d” is the network, “netmask” is the subnet mask (for example,
192.168.100.8/255.255.255.0).
Netgroups – the format is “@ group-name”, the “group-name” is the name of “NIS
netgroup”.
2.2.4.6 Starting and stopping a server
On the server which exported NFS file system, the “nfs” service must be running.
Using the following command to check the status of NFS daemon:
/ sbin / service nfs status
Using the following command to start the NFS daemon:
/ sbin / service nfs start
Using the following command to stop NFS daemon:
/ sbin / service nfs stop
To start the “nfs” service at boot, use the following command:
/ sbin / chkconfig - level 345 nfs on
You can also use “chkconfig”, “ntsysv” or services configuration tool to configure
which services should start at boot.

109
2.2.5 RedHat Linux 9 basic firewall configuration
Just like the firewall in buildings will prevent the fire spreading, the firewall on
computer will try to prevent the viruses spreading into your system. It can also prevent
unauthorized users accessing to your system. Firewall exists between your computer
and networks, it can determine which services can be accessed by the remote users on
the network to. A properly configured firewall can greatly enhance the security of your
system. Therefore, we propose you to configure a firewall for the Red Hat Linux system
connected to the Internet.
2.2.5.1Security Level Configuration Tool
the "Firewall Configuration" screen in the installation of Red Hat Linux gives you
several options to choose: senior, intermediate, no firewall; you can also choose the
designated equipment to be allowed, access to services, and port and so on.
After installation, you can use the security level configuration tool to change the system
security level. If you prefer to use the procedure based on the wizard, please see the next
section.
To start this process, select "main menu" => "System Settings" => "security level" on
the panel, or type the “redhat-config-securitylevel” order under shell(such as XTerm or
GNOME terminal).

110
Figure 2-31 Security Level Configuration Tool
select the security level wanted from the drop-down menu,.
"High"
If you choose the "High", your system will not accept the connection not been defined
deliberately (the connection other than the default setting) in accordance with the
default settings, only the following connections will be allowed:
 DNS response
 DHCP - Therefore, any network interface using of DHCP can be configured
correctly.
If you choose the "High", your firewall will not allow the following connections:
 The actived FTP (the default using of the passive state FTP in most clients, should
be able to operate normally.)
 IRC DCC file transfers
 RealAudio
 Remote X Window System clients
If you want the system to be connected to the Internet, but do not intend to run it as

111
a server, this
is the safest choice. If you need additional services, you can choose "custom" to allow
the specified services to go through the firewall.
"Intermediate"
If you choose the "intermediate", your firewall will not allow remote machines access
certain resources on your system. In accordance with the default settings, visiting the
following resources is not allowed by default:
 The port lower than 1023 - these are the port need to keep as standards, mainly used
by a number of system services, such as: FTP, SSH, telnet, HTTP, and NIS.
 NFS server port (2049) - NFS have been disabled for the remote server and local
customers.
 To set up a remote X client local X Window System display.
 X Font server port (in accordance with the default settings, xfs does not monitor the
network; it is disabled in the font server.)
If you want to be allowed to access to the resources such as the RealAudio (tm), but still
have to plug into the access of the general system, select the "intermediate." You can
choose "custom" to allow the specified services through the firewall.
【Note】 If you choose the intermediate or advanced firewall, network authentication
methods (NIS and LDAP) will not work.
"No firewall"
“No firewall” will grant full access without any security check. System check is to
disable some services. Suggest that you’d better select this option only when running in
a trusted network (non-Internet), or you want to configure the firewall in detail later.
Select "custom" to add trusted devices or to allowed additional access services.
"Trust equipment"
Select any one of "trust the equipment" will allow all traffic from the device to your
system. It is out of the restrictions of firewall rules. For example, if you run a local
network, but connect to the Internet through the PPP dial-up, you can choose "eth0", all
traffic from your local network will be allowed. Choosing the "eth0" as the "trusted

112
devices" means that all traffic through Ethernet will be allowed,
but the traffic through the ppp0 interface is still under the firewall restriction. If you
would like to present traffic of an interface, do not select it.
Suggest you not select the device connected to public networks, such as the Internet, as
the "confidence-building equipment."
"Allowed to enter"
These options will allow the specified services through the firewall. Note that in the
installation type of workstations, the majority of such services does not exist in the
system.
"DHCP"
If you are allowed the DHCP entered to queries and respond, you will allow any
network interface that use DHCP to determine its IP address. DHCP is normally
enabled. If DHCP is not enabled, your computer will no longer be able to obtain the IP
address.
"SSH"
S ecure (security) SH ell (SSH) is the agreement package used to log on the remote
machine and implement command. If you plan to use the SSH tool to login your
machine through the firewall, enable this option. You must have installed “openssh-
server” package when you use SSH tools to access your machine remotely.
"Telnet"
“Telnet” is a protocol of Telnet machine. Telnet communications are not encrypted, it
doesn’t provide any security measures such as prevent the network spying. Suggest that
you not allow the entered Telnet to access. If you want to allow the entered Telnet to
access, you must install the “telnet-server” package.
"WWW (HTTP)"
HTTP protocol is used to provide web pages by “Apache” (and other World Wide Web
servers). If you intend to make your Web server available publicly, enable this option.
You do not have to enable this option to view the local page or do the development of
web pages. If you would like to provide web pages, you have to install the “apache”

113
package.
The opening of "WWW (HTTP)" will not open a port for “HTTPS”. To enable
“HTTPS”, specify it in the "Other ports" field.
"E-mail (SMTP)"
If you want your mail accessed to go through the firewall, so that your remote host can
connect to your machine directly to distribute e-mail, please enable this option. If you
just want to use POP3 or IMAP from the ISP server to collect mail, or use a tool like
“fetchmail”, you do not need to enable this option. Note that incorrect configuration of
the SMTP server will allow remote machines to use your server to send spam.
"FTP"
FTP protocol is used to transfer files between machines on the network. If you intend to
make your FTP server available publicly, enable this option. You need to install the
vsftpd package in order to let this option play a role.
Click "OK" to activate the firewall. After clicking the "OK", the selected option will be
converted into the “iptables” command and be written into the “/ etc / sysconfig /
iptables” file. The “iptables” service has also been started, therefore, after preserved the
option selected, the firewall will be activated immediately.
【 Warning 】 If you configure a firewall or firewall rules in the “/ etc / sysconfig /
iptables” file, this file will be deleted when you choose the "no firewall" and click the
"OK" to save the changes.
The selected options have also been written into “/etc/sysconfig / redhat-config
-securitylevel” files, so these settings will be resume the next time you start the
procedure. Please do not edit the file manually.
To activate the “iptables” service and start automatically when being guided, please
refer to section 13.3 to obtain the details.
2.2.5.2 GNOME Lokkit
GNOME Lokkit allow you configure the firewall settings for ordinary users through the
establishment of basic “ipchains” networking rules. You do not have to compile these
rules, the program will raise a series problems to you on how to use your system, and

114
then put them into the “/ etc / sysconfig / ipchains” file.
You should not use the GNOME Lokkit to generate complex firewall rules. The purpose
of the program is to help ordinary users to protect themselves when using a modem,
cable, or DSL to connect to the Internet. To configure specific firewall rules, see the
chapter of "to create a firewall using iptables" in the "Red Hat Linux Reference Guide".
To disable the specified services or refuse specified host and user, see Chapter 14.
To start the graphical “f GNOME Lokkit”, select "Main Menu" => "System Tools" =>
"More System Tools" => Lokkit, or type the “gnome-lokkit” command as a root user
with the prompt of “shell”. If you do not have installed X Window System, or you
preference text-based procedures, type “lokkit” to start the text mode of this process
with the prompt of “shell”.

Figure 2-32
After starting programs, select the appropriate security level for your system:
 "High Security" - This option disables almost all network connection except the
DNS and DHCP which are necessary to activate the network. IRC, ICQ, the other
instant messaging services, as well as RealAudio all can not run without agents.
 "Low Security" - This option will not allow accessing to remote systems, including
NFS connections and remote X Window System session. Services operated in the
port under 1023 will not accept connections, including FTP, SSH, Telnet, and
HTTP.
 "Disable Firewall" - This option will not create any safety regulations. Recommend

115
that you must select this option only when your system is running in the network
trustable (non-Internet), or running under a firewall, or when you compile to
custom the firewall rules own. If you selected this option and click the "Next", skip
to section 13.3 of this section. Your system's security level will not be changed.
1. Local host
If there are Ethernet devices on the system, "Local Hosts" page will allow you to
configure the connection request of whether the firewall rules to be applied to each
device sent to. If the device connects the system to the LAN behind a firewall, instead
of connecting to the Internet directly, select "Yes". If the Ethernet card connects the
system to the cable or DSL modem, we propose that you choose "No".

Figure 2-33 Local Hosts (local host)

2. DHCP
If you use DHCP to activate any Ethernet interface on the system, you have to answer
"Yes" to the DHCP problem. If you answered "No", you will not be able to use the
Ethernet interface to establish a connection. Many cable and DSL Internet service
providers ask you to use DHCP to establish an Internet connection.

116
Figure 2-24 DHCP
3. Configuration Services
“GNOME Lokkit” also allows you to start or stop ordinary service. If you answered
"yes" when you configure the service, you will get promptings on the following
services:
 "Web Server" - if you wish to allow users to connect to the World Wide Web server
running on your system (such as Apache), please select this option; If you only
intend to view your own system or the network's website on other servers, you do
not need to choose this option.
 "Incoming Mail" - If you need the system to accept the e-mail, select this option. If
you only intend to use the IMAP, POP3, or fetchmail to retrieve e-mail, you do not
need to choose this option.
 "Secure Shell" - security “Shell”, or “SSH”, is a kit used to log on and implement
the order through the encrypt connection on remote machine. If you need to “ssh”
to remotely access your machine, select this option.
 "Telnet" - Telnet allows you to log on to your machine remotely, but it is not safe. It
sent in plain text in the network (including passwords). Recommend that you use
SSH on your remote machine registry. If you need to use telnet to access your
system, select this option.
To disable the other services you do not want, use the service configuration tool (see
section 2.2.6) or “ntsysv” (refer to section 2.2.6), or “chkconfig” (see section 2.2.6

117
below).
4. Activate the firewall
Click on the "end" will write firewall rules into the “/ etc / sysconfig / iptables” file, and
restart “iptables” firewall service to start.
【Warning】 If you have configured a firewall, or have configured the firewall rules in
the “/ etc / sysconfig / iptables” file, if you chose the "Disable Firewall" and click on the
"end" to save changes, the firewall rules will be deleted .
We strongly recommend that you should run “GNOME Lokkit” from the machine rather
than a remote X session. If you disable the remote access to your machine, you will not
be able to disable the firewall rules through the system.
If you do not want to write firewall rules, click "Cancel."
5. E-mail relay
Mail relay is a system allows other systems to send e-mail through it.
If your system is a mail station, some people may use it to distribute the spam through
your machine.
If you choose to open mail service, after clicking on the "end" in the "Activate Firewall"
page, , you will be prompted whether or not to check e-mail forwarding. If you
answered "Yes" to check e-mail forwarding, “GNOME Lokkit” will attempt to connect
Mail Abuse Prevention System Web site (http://www.mail-abuse.org/), and run the mail
relay test procedure. The test results will be showed in the end. If your system opens to
mail relay, strongly recommend that you configure “Sendmail” to prevent it from
happening.
2.2.5.3 “Iptables” service activation
The firewall rules can be activated only when the “iptables” service is running. To start
the service manually, use the following command:
/ sbin / service iptables restart
To ensure that it start at system boot time, use the following command:
/ sbin / chkconfig - level 345 iptables on
The “ipchains” service and the “iptables” service can not be run at the same time. To

118
ensure the “ipchains” service is disabled, perform the following command:
/ sbin / chkconfig - level 345 ipchains off
You can also use the service configuration tool to activate the “iptables” and “ipchains”
service, please refer to section 14.3 to view the details.
2.2.6 The RedHat Linux 9 controlling of accessing to services
Safeguarding the security of Red Hat Linux system is paramount importance. One of
the methods of the system security management is prudent manage the use of system
services. Your system may be required to provide certain services to the public use (such
as “httpd”, if you are running the World Wide Web server). However, if you do not need
to provide a service, then it should be shutted down - this will reduce the possibility of
the exposure of your stealing machine tricks.
There are several methods of managing the visit to the system. You must determine
which method should be used based on services, system configuration, as well as your
grasp extent of Linux.
The easiest way to refuse to use a certain service is turn it off. Whether it is the services
managed by “xinetd” (we will discuss at the back of this section in detail), or in the “/
etc / rc.d” level service, can use the following three different applications to configure
their start or stop:
 Services Configuration Tool - a graphical application that shows the description of
each service and whether each service is activated when guided (run level 3, 4, 5)
and allows you to start, stop, or restart each service.
 ntsysv - text-based procedures. It allows you to configure services to start when
guided for each run-level. For the services that do not belong to “xinetd”, the
change will not take effect immediately. You can not use this procedure to start,
stop, or restart the services do not belong to xinetd services.
 chkconfig - a command-line tool allows you to start-up and shut down services
runned at different levels. For the services do not belong to “xinetd”, the change
will not take effect immediately. You can not use this tool to start, stop, or restart
the services do not belong to “xinetd” services.

119
You may find using the tool above more simple than using the following methods -
Editing manually a large number of symbolic links located in the “/ etc / rc.d” directory
of, or editing “xinetd” configuration file of “/ etc / xinetd.d”.
Managing services on the system in another way is configuring the IP firewall by using
iptables. If you are a Linux novice, please note that, “iptables” may not be your best
way of solution. Setting “Iptables” is a complex operation, it is better to implement by
experienced Linux system administrators.
From another side of view, the superiority of “iptables” is its flexibility. For example, if
you need a customized solution to provide the right to use certain services for some
hosts, “iptables” can provide it to you. To view the details about iptables, please refer to
"Red Hat Linux Reference Guide" and "Red Hat Linux Security Guide."
In addition, if you are looking for procedures that can configure the general access rules
for your home machine, and (or) you are a Linux novice, you should try to use the
security level configuration tool
(Redhat-config-securitylevel). The tool allows you to select the security level for the
system, it is similar to the "Firewall Configuration" screen in the Red Hat Linux
installation program. You can also use the “GNOME Lokkit”. “GNOME Lokkit” is a
GUI tool, it will ask you the problems about how you want to use your machine. Based
on your answers, it will configure a simple firewall for you. To view the details about
these tools, please refer to section 2.2.5. If you need more clear firewall rules, see the
chapter “iptables” in the "Red Hat Linux Reference Guide".
2.2.6.1 Runlevel
Before you configure your visit to the service, you must understand Linux runlevels.
Runlevel is a state, or mode, which are defined by the services listed in the “/ etc / rc.d /
rc <x>.d” directory, “<x>” is the figures of run level.
Red Hat Linux run-level use the following:
 0 – Outage
 1 - single-user mode
 - not be used (which may be defined by user)

120
 - Fully multi-user mode
 - not be used (which may be defined by user)
 - Fully multi-user mode (with X-based login screen)
 - reboot
If you are using a text login screen, you are operating on the runlevel 3. If you are using
a graphical login screen, you are operating on the runlevel 5.
The default runlevel can be modified by changing the “/ etc / inittab” file. There is a line
similar to the following in at the place close to the beginning of the document:
id: 5: initdefault:
Change the figure in this line into the run-level you want. The changes made will take
effect after the system id rebooted.
To change the runlevel immediately, use the command “telinit”, and then follow the
run-level figure. You must be root user to use this command.
2.2.6.2 TCP bypass procedures
Many UNIX system administrators are more familiar with the use of TCP bypass
procedures to manage the use of Web services. Services managed by xinetd (as well as
any built-in procedures supported by “libwrap”) would be able to use TCP to manage
around the using right. “xinetd” can use the “/ etc / hosts.allow” and “/ etc / hosts.deny”
files to configure the using of services to system. As implied by the name of the file,
“hosts.allow” contains a ruled network services list allows customers to use which is
controlled by “xinetd”, “hosts.deny” file contains the rules of refusing the using right.
“hosts.allow” file take precedence over “hosts.deny” file. The grant or deny permissions
of the using right can be based on individual IP address (or host name) or a class of
customers. To view the details, please refer to “Red Hat Linux Guide” and man 5
“hosts_access”
1. Xinetd
To control access to Internet services, using “xinetd”. It is the safety replacement goods
of “inetd”. “xinetd” daemon save system resources, providing access control and
logging diary, and can be used to start special-purpose servers. “xinetd” can be used to

121
provide access to some of the host; refused access to certain services; restricted the
frequency of the accessing to connect and (or) load results from connecting and so on.
“xinetd” runs and monitors the management of its services on all ports all the time.
When a request that connecting to a service managed by it arrives, “xinetd” will start the
appropriate server services.
The configuration file of “xinetd” is “/ etc / xinetd.conf”, but it includes a few default
values and include configuration files in “/ etc / xinetd.d” directory. If the directory
command enable or disable a “xinetd” service, edit the configuration files located in “/
etc / xinetd.d” directory. If the disable attribute is setted to yes, the service is disabled. If
the disable attribute is setted to no, then the service is enabled. You can use the service
configuration tool, “ntsysv” or “chkconfig” to edit a xinetd configuration file or change
its enabled state. To get the network services list controlled by “Xinetd”, use the “ls / etc
/ xinetd.d” command to display the content of “/ etc / xinetd.d directory”.
2. Services Configuration Tool
Services Configuration Tool is a graphical application. It is developed by Red Hat, and
used to configure which “SysV” services and which xinetd services to start when guided
in the “/ etc / rc.d / init.d”(in terms of run-level 3,4,5). It allows you to start, stop, and
restart “SysV” services as well as restart “xinetd”.
To start services configuration tool from the desktop, click on the "main menu" =>
"System Settings" => "Server Settings" => "service" on the panel, or with the prompt
(such as “XTerm” or “GNOME” Terminal), type the command “redhat-config-
services”.

122
Figure 2-25 Configuration Tool Service
Services Configuration Tool displays the current runlevel as well as the runlevel you is
editing now. To edit the operation of different levels from the drop-down menu, select
"Edit Runlevel", and then select runlevel 3, 4, or 5. With regard to the operation level
description, please refer to section 14.1.
Services configuration tool is not only a list of ser vices in the “/ etc / rc.d / init.d”, but
also a list of services controlled by “xinetd”. Click on the service name on the left of the
list to display a brief description of the service and the state of its services. If this
service is not a “xinetd” service, the state of the window will show whether the service
is running now. If the service is controlled by xinetd, the status window will show the
phrase of "xinetd service".
To start, stop, or restart a service immediately, select the service from the list, and then
click the corresponding toolbar button (or from the "Action" drop-down menu to select
Operations). If the service is a “xinetd” service, action button will be disabled, because
they can not be started or stopped singly.
If you select or deselect the check box next to the service name to enable or disable the
“xinetd” service, you must select "File" => "Save changes" from the drop-down menu
to restart “xinetd”, and immediately opened or cut the xinetd service you changed.

123
“xinetd” was configured automatically memory settings., you can enable or disable a
number of xinetd services at the same time, in the end save the changes.
For example, suppose you choose to enable “rsync” at runlevel 3, and have saved the
changes. the “rsync” service will be enabled immediately. The next time “xinetd” is
enabled, “rsync” will still be enabled.
【Warning】 When you save the changes made in the xinetd service, restart the xinetd,
the change will take effect immediately. When you save the changes to other services,
run-level will be re-configured, but the change will not take effect immediately.
To enable the service which does not belong to “xinetd” when guided at the current
runlevel, select the check boxes next to the services names in the list. After a runlevel
configuration, apply the changes by selecting the "file" => "Save Changes" from the
drop-down menu. Runlevel configuration will be changed, but will not be restarted;
thus, change will not take effect immediately.
For example, assume you are at runlevel 3 in the configuration. If you change the
service “anacron” status from the "selected" to "not selected", and then select "Save
changes", the configuration of runlevel 3 will be changed, so the “anacron” will not be
activated when guided. However, if the runlevel 3 have not been re-initialized, the
anacron will be still running. At this time, choose one from the following selection:
1. Stop “anacron” service - to turn off the service, select it from the list, and then click
"Stop" button. The news of a statement of “services have been successful to be stopped”
will be displayed.
2. To re-initialize the runlevel - the method of re-initialize runlevel is: Open the “shell”
prompt, and then type the command “telinit 3” (where 3 is the number of runlevel). If
you change a number of values of services "to start when guided", and would like to
activate the change immediately, recommend that you use this method.
3. To do nothing - you do not have to stop the “anacron” service. You can wait until the
system reboot to stop the service. When the system boots next time, the run-level will
be initialized as not running the “anacron” service.
3. ntsysv

124
The “ntsysv” tools provide a simple interface for the activation or outage services. You
can use “ntsysv” to start or shut down by the service managed by “xinetd”. You can also
use “ntsysv” to configure the runlevel. In according to the default settings, only the
current runlevel will be configured. To configure different runlevels, use the “- level”
option to specify one or more runlevels. For example, the command “ntsysv - level 345-
level” configures to run 3, 4, and 5.
“ntsysv” interface is similar to the work mode of text-mode installation process. Use the
up and down arrows to view the list from top to bottom. Use the space bar to select or
de-select services, or to "click" "OK" and "Cancel" button. To switch among the list of
services and "OK", "Cancel" button, use the [Tab] key. * Indicate a service is set to start.
[F1] key will pop up a brief description of each service.
【Warning】the service managed by “xinetd” will immediately be affected by “ntsysv”.
Other services will not take effect immediately. You must use the command “service
daemon stop” to stop certain services. In the previous example, replace the daemon with
the service name you want to stop, for example, “httpd”. Replaced the “stop” with
“start” or “restart” to start or restart a service.
4. chkconfig
The “chkconfig” command can also be used to activate and stop service. If you use the
“chkconfig – list” command, you will see a list of system services, and their level in the
run of 0-6 has been activated (on) or stopped (off). At the end of the list, you will see
the services part of xinetd management.
If you use “chkconfig – list” to query the service managed by “xinetd”, you'll see
“xinetd” service is enabled (on) or shut down (off) the. For example, the command
“chkconfig – list finger” returns the following output:
finger on
As indicated above, “finger” is enabled as a “xinetd” service. If “xinetd” is running,
“finger” will be enabled.
If you use “chkconfig – list” to query services in the “/ etc / rc.d”, you will see the
service settings in each runlevel. For example, the command “chkconfig - list anacron”

125
returns the following output:
anacron 0: off 1: off 2: on 3: on 4: on 5: on 6: off
chkconfig can also be used to set up a service to be activated or not at a specified
runlevel in a certain cervice. For example, stop the “nscd” service in the runlevel 3,4,5,
use the following command:
chkconfig - level 345 nscd off
【Warning】the service managed by xinetd will be affected by “hkconfig” at once. For
example, if xinetd is running, finger is disabled, then after implementing the
“chkconfig” command, “finger” would not have to be opened immediately when
manually restart “xinetd”. Other changes of services after using “chkconfig” will not
take effect immediately. You must use the command “service daemon stop” to stop the
individual services. In the previous example, replace the daemon with the service name
you want to stop, such as “httpd”. Replaced “stop” with “start” or “restart” to start or
restart the service.
FAQ Q & A:
1.

In case of doubt the contents of this chapter, please write at the back of FAQ questions
and answers, by 1,2,3, ... sort the problem and send the page back to us and we will
respond as soon as possible, thank you! (Nanjing NARI Autocontrol Co., Ltd. /
Engineering Center / Technical Support)

126
Chapter III Utility of Solaris 9 Operation System
3.1 Solaris 9 System Commands
3.1.1 boot command and parameters under the case of Solaris Unix OK
BootPROM is equivalent to CMOS of PC, you can detect the hardware and setting boot
option under BootRPOM. Sun system contains the following two ● basic hardware:
● BootPROM chip
Nonvolatile memory (NVRAM): Save the host ID number and start options setting
The Basic Commands of BootPROM
● banner
Ok banner
Sun UltraSPARC 60 UPA / PCI (2 X UltraSPARC-II 296MHz), Keyboard Present
OpenBoot 3.11, 256 MB memory installed, Serial # 3159808.
Ethernet address 8:0:22:1 a: e7: 3f, Host ID: 72303700.
Ok
The command banner display basic configuration information, including machine type,
CPU number and frequency, memory size, Ethernet address, the host serial numbers,
and so on.
● boot command and parameters
Ok boot [device_name] - [options]
● printenv command
the command printenv display the setting of NVRAM variable and default values.
Ok printenv
Parameter Name Value Default Value
Tpe-link-test? True true
Output-device ttya screen
Input-device ttya keyboard
Sbus-probe-list f0123 f0123
Keyboard-click? False false
Diag-file

127
Diag-device net net
Boot-file
Boot-device disk2 disk
Auto-boot? True true
More [,, q]? Q
Ok
● setenv command
Function set parameter value of PROM, and the commonly used parameters are:
parameter values significance
auto-boot true start operating system automatically the next time
false Stop at the OK state when start the next time
boot-device cdrom start the operating system from the cdrom
disk2 start the operating system from the second harddisk

For example: The boot of the Ultra 60 external hard drive should be as follows:
ok setenv boot-device / pci @ 1f, 4000/SCSI @ 3,1 / disk @ 2,0: a
set-defaults
Recover all the parameters of NVRAM to their default values
the keyboard input when machine starts
● stop
If pressing the Stop button when the system is in Power On Self Test , then cancel the
POST (Power On Self Test) diagnostics, and remain in the OK state.
● stop + d
If press the stop button and d when system is in self test , the system will go to
diagnostic mode automatically, and in the diagnostic mode, the system will do self-test
completely..
● Stop + n
If the system starts correctly because the settings of NVRAM are not correct, you can
press the stop and the n key when system in Power On Self Test . Its role is to set the

128
parameter values of NVRAM to the default values.
● Stop + a
If press the stop and a key at the same time,can interrupt the operation of the operating
system,and back to OK state.
【Warning】Do not press the stop and a key as much as possible when the system is
running, which will lead to the stop of operating system and the loss of data. When
press the stop + a,type the command sync to synchronize the data in memory to the
harddisk.
Find a System
probe-scsi-all
Ok probe-scsi-all
Target 3
Unit 0 Disk SEAGATE ST1480 SUN0424626600190016
Copyright (c)
All Rights Reserved
Target 6
Unit 0 Removable Read Only device SONY CD-ROM
This command can find all system SCSI devices.
【 Note 】 If run this command after the exit of the operating system may cause
system crashes. Please set up auto-boot to false and then run the reset-all.the
system will re-self-test, and remain in a state of OK, and then run this command.
probe-ide
Find all IDE devices in the system.
Ok probe-ide
Device 0 (Primary Master)
ATA Model: ST 34342A
Device 1 (Primary Slave)
Not Present

129
Device 2 (Secondary Master)
Removable ATAPI Model: CDR-8240B
Device 3 (Secondary Slave)
Removable ATAPI Model yyyyyyyyyyyyyyy
【 Note 】 If run this command after the exit of the operating system may cause
system crashes. Please set up auto-boot to false and then run the reset-all.the
system will re-self-test, and remain in a state of OK, and then run this command.
The detection of equipment
● eject
Put the floppy to the diskette, and then enter the command eject, and the floppy disk
will pop-up automatically.
● watch-net-all
Test all the network card and network status. Each network card Test include two parts:
loop-back test and network test cabling. If the loop-back test(from the ring network
adapter) is passed, prove that the network card is in good condition. If the network test
isn't pass the test line ,prove that the cable have not received the signals,and may be that
the cable connect not very well or the cable is bad.
A
--------------------------------------------------------------
acctcom - search and print process accounting files
adb - general-purpose debugger
addbid
sccs-admin, admin - create and administer SCCS history files
aedplot-graphics filters for various plotters
alias, unalias - create or remove a pseudonym or shorthand for a command or series of
commands
answerbook2 - online documentation system
appletvewer
apropos - locate commands by keyword lookup

130
ar - maintain portable archive or library
arch - display the architecture of the current host as - assembler
asa - convert FORTRAN carriage-control output to printable form
at, batch - execute commands at a later time
aedplot-graphics filters for various plotters
atq - display the jobs queued to run at specified times
atrm - remove jobs spooled by at or batch
audioconvert - convert audio file formats
audioplay - play audio files
audiorecord - record an audio file
awk - pattern scanning and processing language
B
--------------------------------------------------------------
banner - make posters
basename, dirname - deliver portions of path names
batch - execute commands at a later time
bc - arbitrary precision arithmetic languag
bdiff - big diff
bfs - big file scanner
bg - control process execution
bgplot - graphics filters for various plotters
biff - give notice of incoming mail messages
break, continue - shell built-in functions to escape from or advance within a
controlling while, for, foreach, or until loop
C
--------------------------------------------------------------
cal - display a calendar
calendar - reminder service
cancel - cancel print request
case,switch,select, - shell command interpreter built-in commands

131
cat - concatenate and display files
cc - C compiler
cd, chdir, pushd, popd, dirs - change working directory
cdc - change the delta commentary of an SCCS delta
chdir - change default directory
checheq -
checknr - check nroff and troff input files; report possible errors
chgrp - change file group ownership
chkey - change user's secure RPC key pair
chmod - change mode of a file
cksum - write file checksums and sizes
clear - clear the terminal screen
cmp - compare two files
col - reverse line-feeds filter
comm - select or reject lines common to two files
command - execute a simple command compress, uncompress, zcat - compress,
uncompress files or display expanded files
break, continue - shell built-in functions to escape from or advance within a controlling
while, for, foreach, or until loop
cp - copy files
cpio - copy file archives in and out
cpp - the C language preprocessor
corntab -
crtplot - graphics filters for various plotters
crypt - encode or decode a file
csh - shell command interpreter with a C-like syntax
csplit - split files based on context
ct - spawn login to a remote terminal
ctags - generate tag file for Emacs, vi
cu - call another UNIX system

132
cut - cut out selected fields of each line of a file
D
--------------------------------------------------------------
date - return date in character form
dc - desk calculator
sccs-delta, delta - make a delta to an SCCS file
deroff - remove nroff/troff, tbl, and eqn constructs
df - displays number of free disk blocks and free files
dhcpinfo - display values of parameters received through DHCP
diff - compare two files
diff3 - 3-way differential file comparison
diffmk - mark differences between versions of a troff input file
dircmp - directory comparison
dirname - deliver portions of path names
dirs - change working directory
dis - object code disassembler
enable, disable - enable/disable LP printers
dispgid - displays a list of all valid group names
dos2unix - convert text file from DOS format to ISO format
download - host resident PostScript font downloade
dpost - troff postprocessor for PostScript printers
du - summarize disk usage
dumbplot - graphics filters for various plotters
dump - dump selected parts of an object file
dumpcs - show codeset table for the current locale
dumpkeys - load and dump keyboard translation tables
E
--------------------------------------------------------------
echo - echo arguments
ed, red - text editor

133
edit - text editor (variant of ex for casual users)
egrep - search a file for a pattern using full regular expressions
eject - eject media such as CD-ROM and floppy from drive
elfdump - dumps selected parts of an object file
enable, disable - enable/disable LP printers
env - set environment for command invocation
eqn, neqn, checkeq - typeset mathematics test
exec, eval, source - shell built-in functions to execute other commands
ex - text editor
exec, eval, source - shell built-in functions to execute other commands
exit - terminate process with status
expand, unexpand - expand TAB characters to SPACE characters, and vice versa
export - shell built-in functions to determine the characteristics for environmental
variables of the current shell and its descendents
expr - evaluate arguments as an expression
exstr - extract strings from source files
F
--------------------------------------------------------------
factor - obtain the prime factors of a number
false - provide truth values
fastboot, fasthalt - reboot/halt the system without checking the disks
fc - process command history list
fdformat - format floppy diskette or PCMCIA memory card
fg - control process execution
fgrep - search a file for a fixed-character string
file - determine file type
filesync - synchronize ordinary, directory or special files
find - - Finds an occurrence of value in a sequence.
finger - display information about local and remote users
fmt - simple text formatters

134
fmtmsg - display a message on stderr or system console
fnattr
fnbind
fnlist
fnsearch
fnunbind
fold - filter for folding lines
from - display the sender and date of newly-arrived mail messages
for, foreach,repeat - shell command interpreter built-in commands
ftp - file transfer program
function - shell command interpreter built-in commands
G
--------------------------------------------------------------
gcore - get core images of running processes
gencat - generate a formatted message catalog
genmsg - generate a message source file by extracting messages from source files
get,sccs-get - retrieve a version of an SCCS file
getconf - get configuration values
getfacl - display discretionary file information
getopt - parse command options
getoptcvt - convert to getopts to parse command options
getopts - parse utility options
gettext - retrieve text string from message database
gigiplot - graphics filters for various plotters
glob - shell built-in function to expand a word list
goto - shell built-in functions to enable the execution of the shell to advance beyond
its sequence of steps
gprof - display call-graph profile data
graph - draw a graph
grep - search a file for a pattern

135
groups - print group membership of user
grpck - password/group file checkers
H
--------------------------------------------------------------
hash, rehash, unhash, hashstat - evaluate the internal table of the contents of directories
hashmake, spellin, hashcheck - report spelling errors
hashstat - evaluate the internal hash table of the contents of directories
head - display first few lines of files
sccs-help, help - ask for help regarding SCCS error or warning messages
history, fc - process command history list
hostid - print the numeric identifier of the current host
hostname - set or print name of current host system
hp7221plot - graphics filters for various plotters
I
--------------------------------------------------------------
iAPX286, i286, i386, i486, i860 - get processor type truth value
iconv - code set conversion utility
if,test - shell command interpreter built-in commands
implot - graphics filters for various plotters
indxbib - create an inverted index to a bibliographic database
install - install commands
Intro, intro - introduction to mathematical library functions and constants
ipcrm - remove a message queue, semaphore set, or shared memory ID
ipcs - report inter-process communication facilities status
isainfo - describe instruction set architectures
isalist - display the native instruction sets executable on this platform
J
--------------------------------------------------------------
jar
javac

136
javadoc
javah
javald
javap
jdb
jobs, fg, bg, stop, notify - control process execution
join - relational database operator
jre
jsh - standard and job control shell and command interpreter
K
--------------------------------------------------------------
kbd - manipulate the state of keyboard, or display the type of keyboard, or change the
default keyboard abort sequence effect
kdestroy - destroy Kerberos tickets
kerberos - overview of Solaris Kerberos implementation
keylogin - decrypt and store secret key with keyserv
keylogout - delete stored secret key with keyserv
kill - send a signal to a process
kinit - obtain and cache Kerberos ticket-granting ticket
klist - list currently held Kerberos tickets
ksh, rksh - KornShell, a standard/restricted command and programming language
ksrvtgt -
L
--------------------------------------------------------------
last - display login and logout information about users and terminals
lastcomm - display the last commands executed, in reverse order
ld - link-editor for object files
ldapadd - ldap entry addition and modification tools
ldapdelete - ldap delete entry tool
ldapmodify, ldapadd - ldap entry addition and modification tools

137
ldapmodrdn - ldap modify entry RDN tool
ldapsearch - ldap search tool
ldd - list dynamic dependencies of executable files or shared objects
ld.so.1 - runtime linker for dynamic objects
let - shell built-in function to evaluate one or more arithmetic expressions
lex - generate programs for lexical tasks
limit, ulimit, unlimit - set or get limitations on the system resources available to the
current shell and its descendents
line - read one line
lint - a C program checker
listusers - list user login information
ln - make hard or symbolic links to files
loadkeys, dumpkeys - load and dump keyboard translation tables
locale - A localization class containing a polymorphic set of facets.
localedef - define locale environment
logger - add entries to the system log
login - sign on to the system
logname - return user's login name
logout - shell built-in function to exit from a login session
look - find words in the system dictionary or lines in a sorted list
lookbib - find references in a bibliographic database
lorder - find ordering relation for an object or library archive
lp - submit print request
lpc - line printer control program
lpq - display the content of a print queue
lpr - submit print requests
lprm - remove print requests from the print queue
lpstat - print information about the status of the print service
lptest - generate line printer ripple pattern
ls - list contents of directory

138
M
--------------------------------------------------------------
m4 - macro processor
mach - display the processor type of the current host
machid - get processor type truth value
mail, rmail - read mail or send mail to users
mailcompat - provide SunOS compatibility for Solaris mailbox format
mailq - print the mail queue
mailstats - print statistics collected by sendmail
mailx - interactive message processing system
make - maintain, update, and regenerate related programs and files
makefkey
man - find and display reference manual pages
mconnect - connect to SMTP mail server socket
mcs - manipulate the comment section of an object file
mesg - permit or deny messages
mkdir - make directories
mkmsgs - create message files for use by gettxt
mkstr - create an error message file by massaging C source files
more, page - browse or page through a text file
msgfmt - create a message object from a message file
mt - magnetic tape control
mv - move files
N
--------------------------------------------------------------
native2ascii
nawk - pattern scanning and processing language
newaliases - rebuild the data base for the mail aliases file
newform - change the format of a text file
newgrp - log in to a new group

139
news - print news items
nice - invoke a command with an altered scheduling priority
nis+, NIS+, nis - a new version of the network information name service
niscat - display NIS+ tables and objects
nischgrp - change the group owner of a NIS+ object
nischmod - change access rights on a NIS+ object
nischown - change the owner of a NIS+ object
nischttl - change the time to live value of a NIS+ object
nisdefaults - display NIS+ default values
niserror - display NIS+ error messages
nisgrep - utilities for searching NIS+ tables
nisgrpadm - NIS+ group administration command
nisln - symbolically link NIS+ objects
nisls - list the contents of a NIS+ directory
nismatch, nisgrep - utilities for searching NIS+ tables
nismkdir - create NIS+ directories
nispasswd - change NIS+ password information
nisrm - remove NIS+ objects from the namespace
nisrmdir - remove NIS+ directories
nistbladm - NIS+ table administration command
nistest - return the state of the NIS+ namespace using a conditional expression
nl - line numbering filter
nm - print name list of an object file
nohup - run a command immune to hangups
notify - control process execution
nroff - format documents for display or line-printer
O
--------------------------------------------------------------
od - octal dump
on - execute a command on a remote system with the local environment

140
onintr - shell built-in functions to respond to (hardware) signals
optisa - determine which variant instruction set is optimal to use
P
--------------------------------------------------------------
pack, pcat, unpack - compress and expand files
page - browse or page through a text file
pagesize - display the size or sizes of a page of memory
passwd - change login password and password attributes
paste - merge corresponding or subsequent lines of files
patch - apply changes to files
pathchk - check path names
pax - portable archive interchange
pcat - compress and expand files
pcmapkeys
pcred - proc tools
pdp11- get processor type truth value
pfiles - proc tools
pg - files perusal filter for CRTs
pgrep, pkill - find or signal processes by name and other attributes
pkginfo - display software package information
pkgmk - produce an installable package
pkgparam - display package parameter values
pkgproto - generate prototype file entries for input to pkgmk command
pkgtrans - translate package format
pkill - find or signal processes by name and other attributes
pldd - proc tools
plimit - get or set the resource limits of running processes
plot - graphics interface
pmap - display information about the address space of a process
popd - change working directory

141
postdaisy - PostScript translator for Diablo 630 daisy-wheel files
postdmd - PostScript translator for DMD bitmap files
postio - serial interface for PostScript printers
postmd - matrix display program for PostScript printers
postplot - PostScript translator for plot(4B) graphics files
postprint - PostScript translator for text files
postreverse - reverse the page order in a PostScript file
posttek - PostScript translator for Tektronix 4014 files
pr - print files
prex - control tracing and manipulate probe points in a process or the kernel
print - shell built-in function to output characters to the screen or window
printenv - display environment variables currently set
printf - write formatted output
priocntl - display or set scheduling parameters of specified process(es)
proc, pflags, pcred, pldd, psig, pstack, pfiles, pwdx, pstop, prun, pwait, ptime - proc
tools
prof - display profile data
sccs-prs, prs - display selected portions of an SCCS history
prun - proc tools
ps - report process status
proc, pflags, pcred, pldd, psig, pstack, pfiles, pwdx,pstop, prun, pwait, ptime - proc
tools
pushd - change working directory
pvs - display the internal version information of dynamic objects
pwait - proc tools
pwd - return working directory name
pwxd--Proc tools
R
--------------------------------------------------------------
ranlib - convert archives to random libraries

142
rcp - remote file copy
rdist - remote file distribution program
read - read a line from standard input
readonly - shell built-in function to protect the value of the given variable from
reassignment
red - text editor
refer - expand and insert references from a bibliographic database
regcmp - regular expression compile
rehash - evaluate the internal hash table of the contents of directories
remote - remote host description file
renice - alter priority of running processes
repeat- shell command interpreter built-in commands
reset - restore the value of a run-time parameter to the default value
return - shell built-in functions to enable the execution of the shell to advance
beyond its sequence of steps
rksh - KornShell, a standard/restricted command and programming language
rlogin - remote login
rm, rmdir - remove directory entries
rmail - read mail or send mail to users
rmdel - remove a delta from an SCCS file
rmdir - remove directory entries
rmic
rmiregistry
roffbib - format and print a bibliographic database
rpcgen - an RPC protocol compiler
rsh, remsh, remote_shell - remote shell
rup - show host status of remote machines (RPC version)
uptime - show how long the system has been up
rusage - print resource usage for a command
rusers - who is logged in on remote machines

143
rwho - who is logged in on local machines
S
--------------------------------------------------------------
sact - show editing activity status of an SCCS file
sag - system activity graph
sar - system activity reporter
sccs - front end for the Source Code Control System (SCCS)
sccs-admin, admin - create and administer SCCS history files
sccs-cdc, cdc - change the delta commentary of an SCCS delta
sccs-comb, comb - combine SCCS deltas
sccs-delta, delta - make a delta to an SCCS file
sccsdiff - compare two versions of an SCCS file
sccs-get, get - retrieve a version of an SCCS file
sccs-help, help - ask for help regarding SCCS error or warning messages
sccs-prs, prs - display selected portions of an SCCS historyc
sccs-prt, prt - display delta table information from an SCCS file
sccs-rmdel, rmdel - remove a delta from an SCCS file
sccs-sact, sact - show editing activity status of an SCCS file
sccs-sccsdiff, sccsdiff - compare two versions of an SCCS file
sccs-unget, unget - undo a previous get of an SCCS file
sccs-val, val - validate an SCCS file
script - make record of a terminal session
sdiff - print differences between two files side-by-side
sed - stream editor
select - shell command interpreter built-in commands
serialver
set - An associative container that supports unique keys. A set supports bidirectional
iterators.
settime - change file access and modification times
sh - fast execution of an sh shell command

144
shell_builtins - shell command interpreter built-in commands
shift - shell built-in function to traverse either a shell's argument list or a list of field-
separated words
shutdown - shut down system, change system state
size - print section sizes in bytes of object files
sleep - suspend execution for an interval
smart2cfg
soelim - resolve and eliminate .so requests from nroff or troff input
solregis
sort - A templatized algorithm for sorting collections of entities.
sortbib - sort a bibliographic database
sotruss - trace shared library procedure calls
source - shell built-in functions to execute other commands
sparc - get processor type truth value
spell, hashmake, spellin, hashcheck - report spelling errors
spline - interpolate smooth curve
split - split a file into pieces
srchtxt - display contents of, or search for a text string in, message data bases
stop - control process execution
strchg, strconf - change or query stream configuration
strings - find printable strings in an object or binary file
strip - strip symbol table, debugging and line number information from an object file
stty - set the options for a terminal
sum - print checksum and block count for a file
sun - get processor type truth value
suspend - shell built-in function to halt the current shell
switch - shell command interpreter built-in commands
symorder - rearrange a list of symbols
sysvV-make
T

145
--------------------------------------------------------------
t300, t300s, t4014, t450, tek, ver - graphics filters for various plotters
tabs - set tabs on a terminal
tail - deliver the last part of a file
talk - talk to another user
tar - create tape archives and add or extract files
tbl - format tables for nroff or troff
tcopy - copy a magnetic tape
tee - replicate the standard output
tek, ver - graphics filters for various plotters
telnet - user interface to a remote system using the TELNET protocol
test - evaluate condition(s)
tftp - trivial file transfer program
time - return system time
times - shell built-in function to report time usages of the current shell
timex - time a command; report process data and system activity
tip - connect to remote system
tnfdump - convert binary TNF file to ASCII
tnfxtract - extract kernel probes output into a trace file
touch, settime - change file access and modification times
tplot, t300, t300s, t4014, t450, tek, ver - graphics filters for various plotters
tput - initialize a terminal or query terminfo database
tr - translate characters
trap, onintr - shell built-in functions to respond to (hardware) signals
troff - typeset or format documents
true, false - provide truth values
truss - trace system calls and signals
tset, reset - establish or restore terminal characteristics
tsort - topological sort
tty - return user's terminal name

146
type - write a description of command type
typeset, whence - shell built-in functions to set/get attributes and values for shell
variables and functions
U
--------------------------------------------------------------
u3b - get processor type truth value
ucblinks - adds /dev entries to give SunOS 4.x compatible names to SunOS 5.x
devices
ul - do underlining
ulimit, unlimit - set or get limitations on the system resources available to the current
shell and its descendents
umask - get or set the file mode creation mask
unalias - create or remove a pseudonym or shorthand for a command or series of
commands
uname - print name of current system
uncompress, zcat - compress, uncompress files or display expanded files
unexpand - expand TAB characters to SPACE characters, and vice versa
unget - undo a previous get of an SCCS file
unhash, hashstat - evaluate the internal hash table of the contents of directories
unifdef - resolve and remove ifdef'ed lines from C program source
uniq - report or filter out repeated lines in a file
units - converts quantities expressed in standard scales to other scales
unix2dos - convert text file from ISO format to DOS format
unlimit - set or get limitations on the system resources available to the current shell and
its descendents
unpack - compress and expand files
unset - shell built-in functions to determine the characteristics for environmental
variables of the current shell and its descendents
until - shell command interpreter built-in commands
unzip - list, test and extract compressed files in a ZIP archive

147
uptime - show how long the system has been up
users - display a compact list of users logged in
uucp, uulog, uuname - UNIX-to-UNIX system copy
uuencode, uudecode - encode a binary file, or decode its encoded representation
uuglist - print the list of service grades that are available on this UNIX system
uulog, uuname - UNIX-to-UNIX system copy
uupick - public UNIX-to-UNIX system file copy
uustat - uucp status inquiry and job control
uuto, uupick - public UNIX-to-UNIX system file copy
uux - UNIX-to-UNIX system command execution
V
--------------------------------------------------------------
vacation - reply to mail automatically
sccs-val, val - validate an SCCS file
vax - get processor type truth value
vc - version control
vedit - screen-oriented (visual) display editor based on ex
ver - graphics filters for various plotters
vgrind - grind nice program listings
vi, view, vedit - screen-oriented (visual) display editor based on ex
view, vedit - screen-oriented (visual) display editor based on ex
vipw - edit the password file
volcancel - cancel user's request for removable media that is not currently in drive
volcheck - checks for media in a drive and by default checks all floppy media
volmissing - notify user that volume requested is not in the CD-ROM or floppy drive
volrmmount - call rmmount to mount or unmount media
vplot - graphics filters for various plotters
W
--------------------------------------------------------------
w - display information about currently logged-in users

148
wait - wait for a process to terminate
wc - display a count of lines, words and characters in a file
what - extract SCCS version information from a file
whatis - display a one-line summary about a keyword
whence - shell built-in functions to set/get attributes and values for shell variables and
functions
whereis - locate the binary, source, and manual page files for a command
which - locate a command; display its pathname or alias
while - shell command interpreter built-in commands
who - who is on the system
whoami - display the effective current username
whocalls - report on the calls to a specific procedure
whoisInternet
write - write to another user
X
--------------------------------------------------------------
xargs - construct argument lists and invoke utility
xgettxt
xstrt
Y
--------------------------------------------------------------
yacc - yet another compiler-compiler
ypcat - print values in a NIS database
ypmatch - print the value of one or more keys from a NIS map
ypasswd
ypwhich - return name of NIS server or map master
Z
--------------------------------------------------------------
zcat - compress, uncompress files or display expanded files
zipinfo - list detailed information about a ZIP archive

149
3.2 The Utility in Solaris 9
3.2.1 Admintool tools
Admintool is the tool which can install and remove the software with command
Package through graghical interface in Solaris2.x system.
Admintool can package the software to a collection ,which make the management
easier. Admintool call a package order. In the management of the software can use the
package orders and Admintool alternately. For example, you can use Admintool to
install a software ,and command pkgrm to delete the software. Can also use the
command pkgadd to install the software ,and Admintool to remove it. No matter how
the softwares are installed ,the Admintool will display all the software has been installed
in the system.Admintool provides the following features:
● Display software has been installed, the software full name, package name, icon and
the size of each package in the system .
● Can be used to install and remove software locally or remotely in the Solaris 2.x
system
● Can specify the directory to install the software.
Using admintool to add and remove software is very easy in the local system.
Admintool provide a graphical user interface can use commands pkgadd and pkgrm. It
also provides online help to enable users to get the information of using Admintool.
Admintool can look over the descriptions of the software packages which have already
been installed in the system or media .It can get a detailed information of every
package, including the name of the package.
Admintool don't allowed to add the package to the buffer directory, or abolish of user
interaction through the management documents. Must use the command Pkgadd to
complete these tasks.
【Note】 before in the Solaris 2.5, the software manager (using swmtool start) is
used to increase or delete graphical software. In Solaris 2.5 and the system after it,
Admintool (start with admintool) provide the corresponding functions. In Solaris
2.5 and 2.6 ,in command swmtool is linked to the command admintool .

150
3.2.1.1 Start Admintool
The executable program (admintool) of the Admintool is located in directory/ bin. The
executable program "swmtool"of the old manager is linked to the command / bin /
admintool . If input "swmtool &" , the Admintool will be activated. Use the following
steps to start Admintool.
【Note】 Must be super-user in UNIX or a member of sysadmin group in UNIX
(GID14) can install or remove software using Admintool.
1. To login in root, or become superuser.
Oak% su
Password: <your root password>
Oak #
2. Input "Admintool &" and enter, as shown in Figure 3-1 ,and show Admintool: Users
window.
# / Bin / admintool &

Figure 3-1 Admintool: Users window


3. Select Software in the Browse menu. As shown in Figure 3 - 2 , show Admintool:
Software window.

151
Figure 3-2 Admintool: Software window

3.2.1.2 Software Installation


the following part tell you how to access a file in the local CD-ROM , how to set up a
custom installation, and how to identify installation directory which can be choiced.
1. Access to the file in the local CD-ROM
Access the file in the local CD-ROM in the following steps
6.Put the CD in the CD-ROM drive. A few minutes later, there will appear a File
Manager window which containd the contains of the CD-ROM.
7.E d i t choose Add in the edit. If the Volume Manager can read the CD-ROM and CD-
ROM package is included in the top directory of the CD-ROM.As shown in the Figure
3 - 3,Admintool: Add Software window.
3) If Admintool can't find the software pachage in the top directory of CD-ROM or the
Volume Manager does not run, then it shows Admintool: Set Source Media window, as
shown in Figure 3 - 4. In this window, you can choose another media or designate
another path.

152
Figure 3-3 Admintool: Add Software window

Figure 3-4 Admintool: Set Source Media window


4) (if ness) in the Software Location list, select the HardDisk Manager or CD Volume
Manager. Default values is the CD Volume Manager.
5) (if required) in the CD Path column, input the subdirectory of the package in the
media.
6) Press the button OK. If Admintool can not find any package ,show Admintool: Error
window, as shown in Figure 3 - 5 below,and it tells that can not find the the package in
the specified package directory .

153
Figure 3-5 Admintool: error message window
3.adjust the path until discover subdirectory contains the software.
2. Customize
Before you start the installation, you can customize a number of installation
parameters to determine the minimum and maximum operating frequency druing the
installation
The steps of customize
1) Pitch on the customized package. The name of the package become highlight and
into the custom button is activated.
2) Pitch on the Customize button. As shown in Figure 14-6 ,hows Admintool:
Customize window.
3) By default, all packages are selected. Click on a single package to delete it from the
installation list, or click the Deselect All buttons to delete iall the packages in the
installation list.
4) The default directory of the installation package is/ opt. If you want to specify a
different directory, please creat the directory name to InstallationDirectory item.
5) When all the settings are correct, click the button to confirm. Customize Setup
window is closed.

154
Figure 3-6 Admintool: Customize window
3. Start Installation
Before this step, make sure the following work has been completed
● The source media has been set to the installation point directory of CD-ROM .
● Specify a installation directory (if you do not want to use the default installation
directory).
When all the characteristics and home directory have been set, you can install the
software. Please install the software in the following steps :
1) Click the Add button in Admintool: Add Software window,then a terminal window
will show the other installation guidance. Figure 3 - 7 shows the installation information
of package SUNWsadma.
2) Answer the questions asked by the package during the installation process. When
software was installed successfully, the package will appear in the list of Admintool
software.

155
Figure 3-7 Admintool: Add Software window
3.2.1.3 Remove software
Can use Admintool: Software window to show the installed software, and can also
remove the software in the system. Please delete the software in the following steps :
1. Become super-user.
2. if Admintool isn't running, input admintool & and enter .
3. Select Software in the Browse menu.
4. In the software window, select the software you want to delete,and the software will
be highlight.

156
Figure 3-8 Admintool: Warning window
5. In the Edit menu, select Delete,then show admintool
Warning window, and asked if confirm that you want to delete the software, as shown in
Figure 3-8.
6. Press Cance button to cancel delete, and press Delete button to delete the software.
As shown in figure 3 - 9 , Admintool: Delete Software window.

157
Figure 3-9 Admintool: Delete Software window
7. Input Y and ENTER to delete the software. Then continue to answer the qustion in
the deletion process.
8. When the deletion is complete, input ENTER once again to close Admintool: Delete
Software window.
3.2.2 program package command
This chapter describes how to use Solaris 2.X progran package command to install,
delete, and management software.
3.2.2.1 program package in command-line
In the command-line can use the command management software shown in Table 13-1 .
These program packages command is in the directory / usr / sbin . Only the super-user
can use the pkgadd and pkgrm commands.
Table 3-1:

158
Before joining a package , must insert the CD-ROM to the CD-ROM drive and load.
【 Note 】 There will be some problem in the process of increasing and deleting
progrem command package of a previous version before Solaris 2.5 . If it is failed
to dd and remove a package in the user interface or when use interface to
respondyour responses is ignored, please set the following environment variables:
NONABI-SCRIPTS = TURE
3.2.2.2 Configuration File of the Program Package
By default, pkgadd and pkgrm command uses the information of the file / var / sadm /
install / admin / default, as follows:

Parameters of this document are pairs parameter = value of the , and every pair take one
line. If you do not want to use these default values, you can create another admin files
and set up different values.

159
Table 3-2 liste and tell these parameters and make out which values are available.
Table 3-2 The Parameters option of package management

【Warning】 Do not edit the file/ var / sadm / install / admin / default . If you want
to change these default values, please create your own admin file.
If you create a custom admin documents and make a statement in the command-line
using the-a (admin) the option,command pkgadd and pkgrm will automatically seach
the current working directory , and then will seach in directory / var / sadm / install /
admin. If the put file in another directory, must make a staement about the absolute path
in the command-line. The following examples illustrate that a admin file is in the

160
dircetory / var / tmp:

You can use any editor to create admin file. In every line of the define a pair
parameter = value. Do not necessarily need all of the parameters. If there is no value in
the file but pkgadd need it, the the parameter will get the default value ask.
【Warning】Druing the non-interactive installation you can not use the ask to set
the variable to be default in the file admin. Otherwise the installation will be fail.
In the following examples, the file admin will be automatically installed to the directory
/ usr / apps / pkgs , and set the other parameters to default values.

2.Set up the basic directory of the installation (base directory)


Before software Installation beginning, we should decide where to install
the software. If you do not want it installed in the directory / opt , it is
necessary to creat an file admin in the directory/ var / sadm / install / and
set the parameters of the directory basedir to the dircetory you would like to
install the software in . If the basedir is the only parameter you want to
change, you can create admin file with only one parameter. All the other
parameters will be the default values. Reference Table 3-2 for parameter
values can be set.

161
The following steps show how to create an admin file to install the file in
the dircetory / usr / apps / pkgs and set the directory name and package
name to be the same.Understand how to use admin to control the
installation process:
1) Change to be super-user.
2) Input cd / var / sadm / install / admin and press Enter.
3) the use of any editor to create a document. The file named the name of
any you like(if not "default"). The proposed file name is "admin"
4) Input basedir = / usr / apps / pkgs / $ PKGINST in the document .
5) Save changes and exit.
2. Installation Package Can Use the Different Installation Management File

Unless there is a statement of different management file, pkgadd command will use
default file the / var / sadm / install / admin / , and it specified the basic directory is /
opt. If you want to use your own admin file, please use the following syntax

The following example is that install SUNWssser from the CD-ROM and use an
admian file named by admin:
3.2.2.4 Add Program Package
Using command pkgadd to install package. Default pkgadd command is interactive and
can tell some potential problem druing the precess of the installation.
【Note】 Only the super-user have the permissions to use the command pkgadd .
Syntax of command Pkgadd is as follows:
For example, install the package named SUNWpkgA from / cdrom/cdrom0 the
interactivly,you must input / usr / sbin / pkgadd-d / cdrom/cdrom0 SUNWssser and
press Enter. Install the same software package but using the same management file
named admin, then input / usr / sbin / pkgadd-d / cdrom/cdrom0-a admin SUNWssser
and press Enter. If you want to get more information of management package ,please
refer to "set up the package configuration file."

162
In the command-line, input a group of pkgids separated by a space to install more
package. The following examples is the example of installation SearchIt 2.0 from /
cdrom/cdrom0 .

163
164
165
When only use the command pkgadd, it will search package in the directory / var / spool
/ pkg . Therefore, all packages need to be copied to the directory waiting installation. If

166
the package is not in the directory/ var / spool / pkg , the installation will be fail, as in
the example below:

From the media such as CD-ROM to install the package directly, you must choice the-d
option statement (absolute) path in the equipment of packages want to install .
If the pkgadd encounte problems, the information about the problems and regard to the
information and the prompt Do you want to continue with this install-ation of the
package? will be shown together . Input yes, no or quit and press Enter. Type yes to
continue with the installation. If you specify more than one package, type no to stop the
installation of the current package, but can not stop the installation of other packages.
Type quit to stop all the installation packages. In the following examples, although the
command-line parameter has specified a CD-ROM directory , but the directory does not
contain the package, command pkgadd will return an error message:

In the following example, the command-line parameter specified a path which is exist
and contain the package in the CD-ROM :

167
In fact, you can use the command cd to change to the directory to the directory
containing the package , then type pkgadd-d and Enter to continue the installation, as
shown in the following examples:

168
In fact, you can use the command cd to change to the directory to the directory
containing the package , then type pkgadd-d and Enter to continue the installation, as
shown in the following examples:

169
3.2.2.5 Inspection of the Installation Package
Pkgchk command can be used to check the integrity, installation path, file content and
file attributes of the installed package. The following is the syntax of command
Pkgchk:

For example, in order to check the package SUNWman (online manual page), type
pkgchk SUNWman and Enter . If there is no prompt information show that the package
has been properly installed.

If there are some informations ,show that the package is not fully installed. As shown in
the following examples:

You can declare once there are more than one packages , as long as they are separaed
by partition. If we do not do declare ,pkgid will list all the package can be found.

170
Can use the-p option of Pkgchkto to check packages which are installed in the specified
path, syntax is as follows:

If you want to check more than one path ,can write a comma-separated path string .
Can use the-a of command Pkgchk
The option check properties of the file. Can use the-c of option command Pkgchk to
check the contents of the documents. The following is a specific syntax:

To check all the buffer (spooled) package, using the-d options of the command
pkgchk . This option check the oackage in the specified directory or the specified
equipment , such as:

In this instance, command pkgchk check all package contents in directory spool-dir
pkgA
【Note】The check of the packsge placed in the buffer the directory is limited, because
before the package was installed some of the billing information is not priored.
3.2.2.6 List Package
If you need to check whether a package has been installed in a system, can use the
command pkginfo . By default, it shows the installation information of the package has
been installed . Can also use the command pkginfo to display information of the
package installed in the local distribution media .
Can use the command pkgunfo with no parameters,can list the packages installed
in the directory. The following examples show some of package installed in the system :

171
Can use the following syntax shows information of a single package:

The following example shows the information of package SUNWsteNP:

To display the informating of the CD-ROM, please first load the CD-ROM. Use the
following syntax shows the list of the package in the CD-ROM :

Use the following syntax showspackage list of a single CD-ROM :

3.2.2.7 Delete package


In previous versions of SunOS, you can use the command rm (1) to delete the
classification software package. In Solaris 2.x system software,you should use the
command pkgrm to remove the package. Command pkgrm allows a single command
delete all the classification packages, so that management becomes easier.
Remove the package in the interactive mode in the following syntax :

172
In the following example, delete the package SUNWdiag:

173
If you want to remove a package in non-interactive mode , can use the the-n option of
the command pkgrm, as follows:

174
To delete a directory in the buffer package, use the - s option of command pkgrm to
delete a package in the buffer driectory , as follows:

In this instance, spooldir is the name of the buffer which package is located,but pkgid is
the name of the buffer which the package you want to delete is located which. If not
given identifier of the package , pkgrm will be interactively prompt the package to
delete or protect a buffer directory. 3.2.2.8 System Log file of The Package
Package command safeguard the list of the packeage installed in the file / var / sadm /
install / contents . Now we do not have the tool to show all the file in package . The
following example shows the first ten line of the file/ var / sadm / install / contents :

If you want to know a particular document in which a package, you can use the
command grep to search in system package files. In the following example, using
command grep to searches the information of the pkgadd, and we can know that it is
part of the SUNWcsu package and is located in the directory/ usr / sbin directory.
Command pkgadd is part of the package SUNWman, and is located in the directory/
usr/share/man/man1m .

175
3.2.3 Installation and Management of system patch
The management patch management include the installation and removal of the
Solaris system patches. It is also including deleting and recovering the unnecessary or
the wrong patch from the system.
Patches used to replace or upgrade the current existing files and directories, in order to
make the software can run collection of files and directories better. Existed software
packages is from a particular format, which is adapt to absorption of application
program (ABI) .
In Solaris 2.6 ,there is two patches used to manage the command:
● patchadd: used to installed patches with directory format in the Solaris 2.x system .
● patchrm: used to delete patch has been installed in the Solaris 2.x system, and make
the system recover to the state begfore install the patch.
These two commands instead of the previously released the command installpatch
and backoutpatch with patch. The detailed information of how to install and remove a
patch will be included in file Install.info of each patch. In each patch will also have a
README file contains special information of the patch. Before installing the patch,
make sure which patch has been installed in the system. Are listed in Table 3-3 list the
command used to get the information of the installed patch
Table 3-3 the useful commands of management of patches

176
3.2.3.1 Release of the Patch
All Sun customers can get the patchs about the security and the recommended patchs in
the way of the anonymous ftp or the World Wide Web . The customers who have
purchased the Sun service can get the expansion patches and the complete patch
information database. These information can be get from the World Wide Web or
anonymous ftp ,and the CD-ROM also contains these information. Table 3-4 shows the
client how to access the information of the patch.
Table 3-4 The Patch Information Users Can Access

1. How to get Sun patches


You can get Sun patchs through the World Wide Web or anonymous ftp . If you have
purchase the Sun service, can get the patchs from the patch releasing CD-ROM.
In order to get patchs from the Web page ,need a system can connect to the Internet
and a Web browser can run the program such as Mosaic or Netscape in the system.
In order to get the patch in the way of anonymous ftp , ,need a system can connect
to the Internet and a can run the Ftp program in the system.

F) Get the Patch from the Web page

Use the following Web address to receive patch from the Web page :
http://www.sun.com

177
1) When access to Sun's home page, press patch download page Patches & updates
under Download, As shown in Figure 3-10.

Figure 3-10 Sun Updates & Patches Web page


Sun patches in Sun System need company's authorization to download them.

G)Get the Patch in the Way of Ftp


Connect to any of the following servers in the way of ftp.:
● sunsolve1.sun.com (provided by Sun service sector).
● sunsite.unc.edu (maintained by North Carolina University).

178
When the command ftp prompt to enter the login name, enter anonymous,
and when prompt enter a password, enter the email address. After logging
in, you can find a patch in the public available path/ pubs / patches
directory.
【Note】Must transmit the patch in the binary mode. In the ftp prompt-line, type
bin to change the transfer mode to binary mode.
3.2.3.2 The Number of Patches
Patches have been signed by the only number-letters-string, including the basic code
and characters of patches, as well as the version of patches which indicated by numbers.
For example, 101977-02 is the Solaris 2.4 patch which is to correct the wizard process
named lockd. 101988 is the basic code of the patch for the lockd process. "-02"
Indicates that this is the second version of the patch.
3.2.3.3 Install a patch
When installing a patch, command patchadd copy file from the patch directory to the
local system disk. Command patchadd accomplish the following tasks.
● Confirme the Solaris version of the management host and objective host
● Use the information of a installed patch to update the pkginfo file, including the
patch needing any other patches, as well as the patch being not compatible with any
other patches.
In the process of installation, command patchadd will save the log of the patch
installation in / var / sadm / patch / patch-number / log files for Solaris 2.4 or the
operating system before. In Solaris 2.5 and 2.6, the log files will be stored in this
directory, but only the installation error will be saved.
In the following instance, command patchadd will not install the patch:
● The package has not been installed totally in the host.
● System structure is not consist with the structure which is supported by the installed
patch.
● The patch version does not match with the version of the installed software.
● There is already a patch a basic code and have the same version number higher patch

179
was installed.
● The patch is not compatible with a path which has been already installed(the
information of each patch is stored in the pkginfo file).
● The patch needs a patch that has not been installed yet as a support.
The following example is to install a patch into a stand-alone system

The following example is to install a patch into a clinet system named client1 from the
server console:

The following example is to install a patch into a service in the server console:

The following example is to install a few patches with the command patchadd:

The following example is to install a few patches with the command patchadd, but this
time the list of patches is in the pathclist document:

The following example is to install a few patches into a client system. And it will save
the reverse-recover data in a user-specified directory (instead of the default directory)

The following example is to install patches of Solaris2.6 or Net Install Image of a later
version:

The following example is to install patches of Solaris2.6 or Net Install Image of a later
version, and it will not retain the copys of the documents which have been updated or
replaced:

180
【Warning】 Do not use the -d option, because this option will have the expired
patches to be removed not easily.
3.2.3.4 Delete patch
When recover or delete a patch, command patchrm will restore all the files that the
patch changed, unless one of the following circumstances happens:
● Have used command patchadd to install a patch with -d option, and the patchadd
process have not saved the copys for the upgraded or replaced files.
● The patch has been updated by the upgraded patch.
● The patch needs the support of another patch.
Using command pkgadd, command patchrm restore the software to the prior state when
the patch has not been installed. In the process of installing the patch, command
patchrm stored the log files of the patch installation in / tmp / backoutlog.pid file. If the
patch is deleted successfully, then the file will also be deleted.
The following example shows how to delete a patch in a stand-alone system:

The following example shows how to remove the patch in the client system from the
server console:

The following example shows how to delete the patch from the serve area of the server:

The following example shows how to delete the patch from the network installation
files:

3.3 Shell programming instructions


This part uses two section to introduce shell programming: Section 3.3.1 introduces the

181
basic concept of shell programming and the available three shell in Solaris 2.x system.
And it describes the operation and programming elements of Shell, it also provides the
reference table of the shell grammar. Section 3.3.2 contains examples of shell scripts.
Understandind the shell programme helps to explain the system scripts, such as run-
control script (rc), and it helps to write your own scripts for managing system tasks
automatically. If you need to be familiar with the basic principles of shell programming
as well as to determine to use which kind of shell to perform specific tasks, please refer
to these two sections. This book will not make a in-depth discussion on how to use the
Bourne, Korn, Cshell programming language to programe. For details of the shell
programming language, please refer to the relevant books.
3.3.1 programme shell scripts
Solaris 2.x system software includes three shell: Bourne shell, Korn shell and C shell.
They all have the capacity of high-level programming to implement serial order, select
the operation, carry out the logic test and repeat the operation of the programme. Bourne
shell and K shell use almost the same grammar. The Korn shell is the expandsion of
Bourne shell, and it provides more function. Solaris 2.x system software uses the
Bourne shell script to install the software. The grammar that C shell uses is the same as
C uses, and C shell could provide the function that Bourne shell does not have, such as
historical record and array function.
In this chapter we will introduce the basic concepts of shell programming and three
shell, as well as how shell work, and will also make a comparison of the grammar
among the three shell. The table refered in this chapter will all present in section 3.3.2.
3.3.1.1 The basic concept
Shell is a tool for Solaris 2.x, which provides an interface between users and the
operating system kernel. Kernel is the core of the operating system and control the basic
state of the computer operating. It corresponds the execution of all processes and
supervises the system resources. Shell is the explanation of some special order, and
provides users with the execution of practical processes by the way of asking for and
answering the kernel.

182
The user will be appointed to a default shell when every time the user login the system
or open a new command tool or shell tool window. Shell will read in the order and
explain it. Type the command directly to the shell in the prompt line, or shell reads a
command the document. The files contain shell commands are called shell procedures
or shell scripts.
Shell is to interpret and execute, rather than compile and execute: reading and executing
these commands. But the compiled programs read in and convert itself into a format
that could be executed directly by CPU, and then finish executing once.
The fastest shell script also runs much slower than the equivalent compiled language,
such as C, because shell scripts are explanatory.
3.3.1.1.1 Introduce Bourne, Korn and Cshell
Bourne, Korn and C shell have their own environment and grammar. Table 16-1
compares the initialization files of shell environment which have been defined when
start.

In order to configure the user environment when shell starts, initialization files contain
the environmental variables and other settings. For more information please refer to the
"Environmental Variables" section. .profile (Bourne and Korn shell) and .login (C shell)
execute when the user login the system. The environmental documents of Korn shell
and .Cshrc (C shell) execute at the beginning each new shell. Use these environmental
documents to define the interactive aliases and functions, and to set variables for the
current use of the shell.
1.Bourne shell
Bourne shell, was written by Steve Bourne when he was at AT&T Bell Labs, is one of
the earliest UNIX shell. Because of its programming capability and extensive
availability, it becomes the preferred programming shell, but it lacks some features for
interactive use, such as built-in arithmetic functions and the ability to record an earlier

183
order(history records). Bourne shell is the default root-login shell. If other shell are
described in detail in the user's password document, Bourne shell would be the default
user-login shell. And Bourne shell is the managing script that the system provides.
The start command of Bourne shell is /bin/sh. The default prompt of Bourne shell is "$".
The prompt of root is "#".
2.Korn shell
Korn shell was written by David Korn when he was in the AT&T Bell Labs, it was
designed to be compatible with Bourne shell and to provide the interactive features that
could be compared with C shell. Korn shell contains the convenient programming
characteristics, such as built-in integer arithmetic, array and string operatingfunctions.
Korn shell runs faster than C shell, and could run all the scripts for Bourne shell in a
dummy way.
The start command of Korn shell is /bin/ksh. The default prompt of Korn shell is "$".
The prompt of root is "#".
3.C shell
C shell was written by Bill Joy when he was in the University of California, Berkeley, it
was designed to use interactive features such as aliases and command history. Its
programming characteristics is similar to C.
The start command of C shell is /bin/csh. The default prompt of C shell is the system
name followed by "%". The prompt of root is the system name followed by "#".
3.3.1.1.2 understand shell how to execute the command
Every shell creats sub-shell and sub-process to explain and execute commands--sub-
shell and sub-process run in the original parent shell. The following example shows the
sequence of command execution.
1) Analyse the command into units which are separated by fixed characters. Characters
include: space, Tab, new line, ()<>I&. Units include word, keyword, I/0 redirection
symbol, semicolon and so on.
2) Check the anterior part of the unit to determine whether it is shell keyword, such as
"function" or "if" statement or backslash. Once the keywords have been found, shell

184
will run this group of commands.
3) Search the list of aliases.
4) Expand all ~ expression.
5) Replace variables.
6) Replace command.
7) Replace arithmetic expression.
8) Split the items which are obtained by replacing those variables, commands and
arithmetic, and break them down into words once again.
9) Expand wildcard.
10) Check built-in command, function and executable document.
11) Set the I / O redirection.
12) Run command.
Bourne shell explains the command in the sane way, but would not check the aliases,
symbols or arithmetic. C shell explains the order with a different order.
3.3.1.1.3 Name Shell script
Name shell script under the general rules for naming files of Solaris 2.x. Script name
should describe the characteristics visually so that it is easy to be remembered. Script
name should be different from the name of Solaris 2.x's own processes, unless you want
to use your own script to replace these processes.
Each shell has its own built-in command. Avoid using built-in command as then name
of a shell script. If the file name is the same as built-in shell command, such as alias,
break, case, cd, continue, echo, else, exit, or history, the shell script will explain it as a
built-in command, and will run the built-in command instead of the script. For example,
in Bourne or Korn shell, if a script is named "test", you will be in trouble because test is
a built-in command of Bourne and Korn shell.
Refer to the part of the shell grammar of section 3.3.2 and sh (1), ksh (1) and csh (1)
reference page to get the full list of built-in commands.
3.3.1.1.4 Sign shell
The first line that the shell script used determines which interpreter to use.

185
Table 16-2 helps to identify the significance of the first lines of the shell script.

Use -f(fast) option to use /bin/csh to run scripts, but not to quote .cshrc document.
If you do not elaborate on the first line shell script, and it is an executable script, the
current shell interpreter will explain the script. After the first line of the script, the line
with # at the beginning is a remark, it is not a executable part of the script.
3.3.1.1.5 Make the script executable
Prior to running the shell script, we usually need to change its permission. We should at
least have reading and executing permission(chmod 555). When writing and debugging
scripts, in order to edit this document, we should have writing permission(chmod 755).
When the shell script is completed, it should be set with appropriate permissions. If the
script is not public or personal, limited permission should be used. If there is not a lot of
users to use a script in the same group, the script should have more relaxed permission.
3.3.1.1.6 Store shell script
When a shell script has been created, it could be executed only in the directory where
the script has been placed or by the way of using the entire path name, unless the path
variable contains the directory where the script locates. If you want to write a lot of
scripts, you can create ~/ bin directory in the home directory and make the search path
contains the directory. Using this method, you can use this script in any directory. If the
script is provided for many people, please ensure it is correct and it should be placed in
a directory where the users could easily access.
3.3.1.1.7 Write shell script
The following steps describe how to write a shell script:
1) Decide what you want to the script to do, list tasks that you want to accomplish and
commands needed.
2) Use editor to write commands into a script. Give the script a name which could

186
expresse the function of the script.
3) Add the identifier of the shell at the first line in the script.
4) At the beginning of the script, write some comments to describe the purpose of the
script and all the different parts of the script. These notes can help debugging scripts and
may explain the scripts which are used seldom. Notes can also help others to understand
the script.
5) Save the file and exit the editor.
6) Change the file permission so that there is at least reading and executing permission.
7) Check the path variable, confirm the directory where the script locates is in the search
path.
8) Type the name of the script. The script will execute line by line.
9) If an error occurs, please debug the script.
10) When the script is complete, please decide which directory to place(for example, in
the main directory, the local ~ / bin directory, or place it in the directory that a wider
range of users could access ).
3.3.1.2 Variables
Variable represents a temporary storage area in the memory. One variable keep one
value. Changing the value of a variable is called variable assignment. Two variables are
used in shell programming: shell variables and environment variables. Usually, shell
variables use lowercase letters and environment variables use capital letters.
3.3.1.2.1 Shell variables
Shell variables are maintained by shell and work in shell. shell variables are always
local and not transmitted from parent process to child process.
1. Display variables in the command line
Use command "set" without parameters to display the current shell variables and
environment variables. Bourne and Korn shell show variables as follow format:

187
C shell show variables as follow format:

188
2. Set and display shell variables
In Bourne or Korn shell, create a variable is to assign a value to a variable. If the value
contains space or characters that shell need to use some special way to deal with, it must
be quoted. Refer to "quote" section for more information.
Use the following grammar to assign variables:

In the following example of Bourne or Korn shell, the variable today is set to the output
of command date:

To show the variable's value in all shell, you can use the command "echo $variable".
Although Korn shell can identify command echo, but "print $variable" is the preferred
grammar. You can also put variables in the bracket({}). Use the brackets to separate the
variable and its following information to ensure the correctness of variables. In the
following example, the initiatory value of the variable named flower is rose. If you want
to show the content of the variable coupled with a "s" on the screen, the brackets must
be used at this time.

189
The previous example has already mentioned that you can set local variables in the
command line. Similarly, you can use scripts to set variables.
Use the following grammar to set variables of C shell. If the variable's value contains
space or characters which need to be explained in special method, you must use the
quote. Please refer to section "quote" for more information.
set variable = value
Variables can also be set to the value of the return value of another command. Use anti-
quotation marks ('') containing the command to achieve this function. Korn shell also
supports the "$ (command)" form. The following examples of C shell set the variable
today with the output of command date:

Refer to section "quote" for more information.

3. Delete shell variable settings


You can use the unset command to remove any shell variable, as the following example
of Bourne shell:

4. Strip the file name


Sometimes we need to modify the path, and remove the useless part of the path name
(including directory and file name). In Bourne shell, you can use command basename(1)

190
to return the file name and command
dirname(1) to return the directory prefix. Korn and C shell provide a built-in method to
modify the path name.

5. Strip the path of Korn shell


Korn shell provides pattern-matching operator(listed in Table 16-3), which could be
used to strip their components of the path name.

The following example explains how the operator work, use model /*/ to match any
content between the two /, and match all the content behind the point with .*:

6. Strip the path of C shell


C shell provides a set of modify command. You can use them to strip the useless part of
the variables. These modify command is very useful to strip the path name, they can
also modify the string variable.
Table 16-4 lists the variable modifier of C shell.

The following examples show the results of modifying the first four variables:

191
3.3.1.2.2 Built-in shell variables
All three shell have a group of single-character variables initialized by shell, as listed in
Table 16-5. You can use these variables to access the value of variables and return some
other information of variables.
In C shell, Bourne and Korn shell, the use of these variables are different.

In Bourne and Korn shell, you can get the command-line parameters by using the $*
variable in a script, and get the number of parameters by using the $# variable.
In the following example, shell use the $* variable to get all the command-line
parameters of the script:

If the script is named tryit and executes with three parameters, it will use $# to display
the number of parameters, and use $* to display the value of each parameter. The
entered string could contain quote. Refer to the reference page of sh(1) for more
information, which is about how the quote is explained.

192
In C shell, command "$#variable" will return the number of variables of the variable
array, which is as follows:

In Bourne shell, command "$?Variable" show the quit state of the last execute
command; The way that it shows this information is the same as C shell shows the state
variables. Refer to "exit status" section, which includes a example.
In C shell, you can use the variable $? Variable to test whether the variable has been set
up. If the return of "$?Variable" is 1, it indicates that the variable exist. If the return is 0,
it indicates that the variable does not exist.

【Note】 The value and status that you get by "$?Variable" is opposite, 0 indicates
success and 1 indicates failure.
For all the shell, the return of variables $$ is the pid of current shell. Because the pid is
exclusive, you can use this string to generate a exclusive temporary file name. For
example, when a file named "tmp.$$" is specfied by a script, then it will not be
confused with other files.
【Note】 If it is only concerned about that how to generate the exclusive file name,
you can use the format characteristics of command date(1) to generate a file name
which contains pid ,time and date.

193
Each shell contains a number of built-in commands used to enhance the efficiency.
Table 16-6 lists these built-in commands. Bourne shell relies more on the use of external
commands to work, so it has the least built-in commands. The built-in commands of
Korn shell added in the table behind is followed by (K). The job control variation
command "jsh" of Bourne shell has the same characteristics as Korn shell.
【Warning】The built-in commands can not be used as the name of a shell script. If
you use the name of built-in commands to name a shell script, shell will execute the
built-in command instead of the running script.

194
195
3.3.1.2.3 Environment Variables
Environment variables are used to define some initialization options, such as the default
login shell, user login name, searching path and terminal settings. Some environment
variables are set for each registration. You can also create your own variables and assign
them. In general, the name of environment variables should be capital letters.
Environment variables will be transmited from parent process to sub-process. For
example, a environment variable of shell is effective on the process running inside shell.
The environment variables of the foremost process are effective on the generated
additional process. In other words, the environment variables succeed from the parent
process to child process, from child process to the grandson process. They are unlikely
to succeed from the parent process to grandfather process or from child process to

196
parent process.
Use command env to display the current list of environment variables. Please refer to
"Solaris System Administrator's Guide" for more information on environmental
variables.
For Bourne and Korn shell, use the following grammar for the environment variable
assignment and output them. The variables must be outputed before Sub-process could
use these environments.
VARIABLE = value; export VARIABLE
For Korn shell, you can also use the following grammar:

For C shell, use command setenv and the following grammar to assign the environment
variables:

Use command unsetenv command and the following grammar to delete the environment
variables:

3.3.1.3 Input and Output


When writing shell scripts, we hope to get the input outside the script. For example,
from another document or from the keyboard input. The output of the script is also
available on the internal and the screen.
The following section describe how to use the standard input, output, errors and
redirects to control the input and output of shell scripts, how to accept users' input (from
keyboard input) to a script, how to create the "here" document, how to generate output
on the screen
3.3.1.3.1 Standard input, standard output and standard error
When writing shell scripts, you can control input/output redirection. Input redirection
foreces the commands to read the input from the document rather than read from the
keyboard. Output redirection foreces the commands to write the output in a document or

197
path rather than display it on the screen.
Each process which has been created by the shell script has three file descriptor, as
shown in Figure 16-1.

Figure 16-1 File descriptor

These file descriptor are standard input (STDIN), standard output (STDOUT) and
standard error (STDERR), which determine where the program get input and where to
sent the output and error.
Standard input (STDIN) is always the file descriptor 0. Standard input is where shell
searchs for its input data. Usually, standard input data is obtained from the keyboard.
We can use I/O redirection to indicate the other source of the input.
Standard output (STDOUT) is always the file descriptor 1. Standard output (default) is
used to place the results of the execute process.
In general, the results of the execute process will be displayed on the terminal screen.
We can redirect standard output to a document, or to
/dev/null.
Standard error (STDERR) is always the file descriptor 2. Standard error is where shell
places the error messages.
In general, the error messages is displayed on the terminal screen. We can redirect
standard error to a document, or to /dev/null.
In Bourne and Korn shell, we can use 0(STDIN), 1(STDOUT) and 2(STDERR) to
redirect the input and output. Table 16-7 describes some of the methods used to redirect
commonly.

198
If the STDIN and STDOUT have already been redirected in Bourne and Korn shell, we
could omitt descriptor 0 and 1 when redirecting. However, we should use the file
descriptor 2 to redirect error.
The file descriptor 0 and 1 is implied, it can not be used in C shell, the list of
redirections in C shell is the same as in Table 16-8.
Standard error(2) is expressed as & in C shell. STDERR could be redirected only after
the standard output has already been redirected.

3.3.1.3.2 Command-line input


We may require users to offer the input as a part of the command-line parameters when
running the script. In all three shell, we can use up to nine command-line parameters
(for example, $1, $2, $3, etc.).
$0 is a legitimate variable, and return the command name. See the following script of
Bourne shell named tryit:

【Note】 In Korn shell, you can use the marks such as $(10) and $(11) to describe
more than 9 command-line parameters.

199
The following methods can be used to rewrite the tryit script and make it could run in
the three shell. We can use these command-line parameters to pass the file name or
other information to the shell script.
【 Note 】 For C shell, we can not use "echo$#" in the script. But, we can use
"$#argv" to get the number of command-line parameters.

In the following example, "echo $0" replaces(display the name of the script) "$#argv":

Screen shows the command-line parameters as follows:

【 Note 】 If the parameters do not exist, $n will not return the error message.
Therefore, we can not be sure whether the $n contains a value, unless using $# to
check the number of parameters in Bourne and Korn shell.
C shell provides additional grammar for location parameters, as shown in table 16-9.

In the use of "$argv[n]" grammar shell check the scope, but in the use of $n grammar
shell does not check the scope. If shell can not find variables, it will get the error
message: Subscriptoutofrange (sub script out of range).
【Note】 "$argv[0]" does not have meaning, and can not return the name of script
like $0.

200
Table 16-10 shows an example of the script and its output:

1. shift command-line parameters


We could use the command shift to control the position parameter in the script in all
three shell. Command shift make all the $1 to $n move left to change the parameters list
earlier. It is very useful to use command shift to deal with the position parameters in the
while loop, that we can use these commands to deal with these position parameters by
turns.
In the following example of Bourne shell , the parameters display by turns. The
command shift makes the parameters move left and deletes the far left value in the list.
just as the following script lists:

The following example shows the output of this script:

201
Because the command shift shift position parameters, we only need to use $1 to show
(deal with) command-line parameters. The following example shows how to shift
position parameters in the command-line in Bourne shell:

Referto the section "the use of while loop" for more information on the while loop.
3.3.1.3.3 interactive input
It is ok to require users to type one-line input at anywhere in the script. In Bourne and
Korn shell, we use the command read followed by a variable name for interactive input.
【Note】 It is needless to define this variable before reading the parameter value by
using command read. The following example shows the grammar of using
interactive input in Bourne and Korn shell.
【Note】 Do not enter a new line after the prompt line, so that the user could type
input in the same line, when /usr/ bin is placed before /usr/ucb in the search path.
Add \c at the end of the string, in order to make sure that users could type in the
same line of prompt.
Command "echo -n" could complete the same work when /usr/ucb is located before
/usr/bin in the search path in SunOS 4.x. Refer to "echo (1)" reference page to get more
information.

When the prompt appears, the script starts waiting for the keyboard input. When the

202
user inputs and types enter, input will be assigned to the variable, and the script will
continue.

【Note】 must be prompt on the screen display so that users know that the script is
waiting for input screen.

For C shell, the special variables $< waits for the value from the standard input, and it
could be used in any place where using the variable. For C shell, use the $< is the same
as assign the variable, just as follows:

When the prompt appears, the script starts waiting for keyboard input. When the user
inputs and types enter, the input will be assigned to the variable, and the script will
continue.
3.3.1.3.4 Here document
Sometimes shell script needs to use some data. If the data is not put in a file in the
system, it can be placed in the shell script. Put the data in the script makes it much earier
to distribute and maintain this script. This data set is called here documents, the data is
in the shell script. Another strongpoint of document here is that we can replace the
parameters of shell in the document.
The general format of the document here is shown below. The format is the same in
three shell.

In the document here operator << indicates the beginning of the document. In order to
indicate the end of input, the operator must be followed by a delimiter, such as

203
<<DONE. List the input that you want behind. Input could be made up of any text and
variables. Because shell also replaces the variables in the document here. At the end of
the document here, we must write the delimiter at the beginning of the single line.
The contents, which is between the two delimiter, will be dealed with as the standard
input. In the following example, we will inform and invite the staff, whose name are
listed in the document stafflist, to participate in the evening. The contents of message
are included in the document here, and the delimiter is EOF.

3.3.1.3.5 Generate output


The following section describes how to use command echo, command quote and
command substitution.
【Note】 The command echo works in the script of Korn shell, but the command
print is the preferred command, The grammar of the command print is the same
as the grammar of the command echo.
1. command echo and print
Use echo command to generate the message and display the message on the terminal
screen. We can use command echo to display the variable value, and to display the text
information. There are already some examples before. The following is another example
of Bourne shell script.

If you want to use echo to display a number of messages in a line, you can use string \c
to stop generating a new line following the message. The following example has
changed the earlier script of Bourne shell, so that users could input after a colon, rather
than input in the next line behind the prompt message:

204
If you need to display control characters or metacharacters, you can put a backslash (\)
behind it. Refer to "echo (1)" to get more information of usage of the special control
characters (for example, \c, \n).
There is fewer restrictions for command echo to quote metacharacters in Bourne and
Korn shell rather than in C shell. The following script of Bourne shell displays the error
message in brackets only in the last line because it is not followed by a backslash to
transfer meaning. If the $ followed by a space, then it does not need to transfer meaning.

2. Quote
As listed in table 16-11, all the three shell use the same grammar for quote. Quoting
string incorrectly may lead to many unexpected results.
Table 16-11 quote

【Note】 Excalmatory mark (!) can not be used as metacharacters in Bourne and
Korn shell. If you do not quoted correctly, the problems appear in C shell will
generate.
The following example shows the results of different ways of quote:

205
3.3.1.3.6 Relpace command
Command output can be used to replace the command itself. This process is known as
command substitution. Use anti-quotation marks (``) to contain the command that you
would like to use. You can use command substitution to get the output of the command,
or use it as a variable value.

【Note】In Korn shell, you can use "$(command)" to replace anti-quotation marks.

In the first following example, the output of command date and the output of command
who filtered by wc constitute a greater output string, which determines the number of
users now log on the system. The second example is that command who displays the list
of users' name filtered by command cut and use command "uname -n" to display the
system name.

3.3.1.4 condition judge


When writing the script, we often want to judge the conditions. The simplest is to judge
wherther the condition is right or wrong. If the expression is correct, execute the
command followed by, if not correct, continue to execute the script. Table 16-12 shows
the grammar of condition determine.

206
Table 16-12 the grammar of condition judge

3.3.1.4.1 if-then-else-elif
In Bourne and Korn shell, we use "if-then-else-elif-fi" to determine the conditions. "If
test" with parameters added can be used to determine the conditions. You can also
determine the conditions by putting the conditions in the square brackets[]. You must
add a space before and after the determine conditions in brackets in order to ensure that
the interpreter can explain it correctly. For example:

The judge results of "-r filename" and "[-r filename]" are the same, refer to "judge and
C shell built-judge" to get the options of the judge command.
Use command if to determine whether the user has input parameters in the command in
Bourne shell:

If you want to use the script to make an additional judge when the first judge fails,
please use the else clause.
A example of Bourne shell is as follows:

207
You can use elif condition sentence in if condition sentence(the combination of else and
if) to determine the added conditions, elif clause just processes when the last if or else
clause have failed, each elif clause sets out the other judge command. The following
example is a script of Bourne shell contains one elif clause and one else clause:

3.3.1.4.2
3.3.1.4.2 if-else-else if-endif
C shell has some built-in structure, you can use them to judge. Refer to "judge and C
shell built-in judge" to get the options of command judge.
The following C shell process judges whether the user has typed one or more command-
line parameters whne execute the script:

【Note】 It must be placed at the end of the line, when then appears in C shell.

208
If you want to make an additional judge when the first judge fails, you can use the else
clause, such as the following C shell process does:

You can use "else if" to judge additional conditions in the condition sentence of "if".
"Else if" clause just processes when the last if or else clause have failed, each else if
clause sets out the other judge command. The following example is a script of C shell
contains one else if clause and one else clause:

3.3.1.4.3
3.3.1.4.3 Nested if structure
If statement contains additional if statements. When the script contains a nested if
statement, please use the indent statement to make the logic statement more easily to be
understood and it can be checked whether the required part has been included.

The following is the state method of the nested if statement in Bourne and Korn shell:

209
The following is the state method of the nested if statement in C shell:

3.3.1.4.4
3.3.1.4.4 Multi-branch
You may want to make some different operations when a variable or a parameter has
different value. Although condition judge can be used to judge a variety of value and
take actions, but we can use the case statement more easily, or use switch statement in C
shell , for such a judge. Table 16-13 shows the usage of it.
Table 16-13 Switch and Case grammar

210
The value of variable compares with some models until find the model that match so far.
The commands in the matching mode execute immediately until find ";;" (Bourne and
Korn shell) or "breaksw" (C shell) so far. Finally. The last judge "*)" (Bourne or Korn
shell) or "default:" (C shell) states the default action. Shell will execute the default
action if there is no match. In most of the scripts, the default action displays the error
message and exits from shell.
Statement "case" is very useful in dealing with the parameters of the function. The
following scripts of Bourne shell sets up the type of terminal:
The following example shows an interaction script of C shell how to set up the type of
the terminal:

211
3.3.1.5 Sequence Control
In the script, you can use the loop to control the implementation of process. The loop
repeats some ordinal commands in the repeating mechanism until meets the certain pre-
condition. We can use different types of loop. Loop "for/foreach" executes a set of
commands when the loop variable is each value. Loop while repeates a set of internal
commands until the test condition is no longer true. Bourne and Korn shell provides the
loop "until", which continues to execute commands until the expression becomes true.
Table 16-14 shows the grammar of the loop for/foreach, while, until.
Table 16-14 Loop grammar

3.3.1.5.1 Use for/foreach loop


Use loop for to operate on the options in a fixed list or options of the command-line
parameters. In the loop for of Bourne and Korn shell, it will execute the command
between do and done, when the value is in the string list after "in". The following is the
basic grammar of for loop:

In the first line of loop for, for variable, uses the position parameters $1, $2 and so on,
which are corresponding with $@ in the loop for.
The following script of Bourne shell contains two examples of loop for. The first
example copies a file to a backup directory. The second is to delete all the documents

212
with ".o" suffix.

In C shell, loop foreach can execute in the items of a fixed list or carry out interactively
by reading commands from the command-line. In C shell, the loop will execute a series
of commands, when there is a value in the (list).
The following script of C shell contains two examples of loop foreach. The first
example copies a file to a backup directory. The second is to delete all the documents
with ".o" suffix.

You can type the statement of loop foreach in the command-line prompt. Insert
command after ?. In the prompt, you can type the commands that you would like to
execute. When the command list has been ended, type the end to show the end.
Commands will execute by turns, and then the C shell prompt will occur again. The

213
following example shows and compilers the C source document in the directory and
renames the binary output document. ":r" modifier deletes the ".c" suffix. If there are 10
source documents in the current working directory, the loop will execute 10th. When the
directory does not have any C source files, the loop will end.

The following example converts the grid file to format GIF, and changes ".rs" suffix to
".gif" suffix:

3.3.1.5.2 Usage of while


Use loop while to carry out a set of commands inside the loop again and again until the
test condition of the loop is no longer true. In other words, it is that "When the
expression is true, execute these command".

For Bourne and Korn shell, loop while will always execute the commands between do
and done commands when initial command exits with the state 0.

The following are the basic grammar of while cycle:

In the following script of Bourne shell, the first example set the variable num to 0 and
add 1 to it each time when it is less than or equal to 4.

214
Please refer to section "mathematics" to get the information of how to use the command
expr. The following examples show the parameters on by one when there are parameters
in the command-line. Please refer to section "parameters of shift command-line" to get
the information of how to use the shift command .

In C shell, loop while will execute the commands between the while and end as long as
the value of the expression is true. The following is the basic grammar of loop while:

In the following script of C shell, the first example set the variable num to 0 and add 1
to it each time when it is less than or equal to 4.

215
The following is the output of the script.

The following example displays the parameters of command-line one by one.

3.3.1.5.3 Use loop until


In Bourne or Korn shell, loop until carries out test until the command get the success
state. The grammar of loop until is similar to the grammar of loop while:

【Note】The condition of until is judged at the beginning of the loop, rather than at
the bottom of the loop.
The following example prints from 1 to 5:

The results of this script is the same as the results of the example using loop while.
Refer to section "mathematics" to get the information of the using of command expr.
3.3.1.5.4 Jump out of the loop
All three types of shell have built-in command break and continue to jump out of the
loop for/foreach, while or until. Command break stops the loop constrainedly, and hands
control power to the next line of the statement of "done"(for Bourne and Korn shell) or

216
end (for C shell). In the following example of C shell, the script will continue running
the while loop until the user answers Yes (or yes, y or Y). When the user answeres yes,
break interrupts while (in this case) and exit, because there is no more command need to
be executed.

You can use the command continue to control loop for/foreach in a similar way as loop
while. Command continue only affects the innermost loop. Command continue will
transfer the control power back to while testing immediately and skip all subsequent
commands of the innermost circle. If it is used in the foreach loop, it will complete the
current loop constrainedly and deal with the next item of the list.
3.3.1.6 exit status
When a command or shell ends, it will return an exit status. Exit status is a value, it can
show whether the running of a program is successful and confirm what has happened
during the execution of the command.

The operation of command has a exit state, which is setted up in advance by the one
who writes the command. In general, the exit status of 0 indicates the success of the
execution. Non-0 value (usually 1 or -1) indicates that the process has failed.

However, the one who compile the command may not always comply with this
criterion. See the command reference page for the meaning of the exit state. For
example, command grep will return three state values: 0 indicates that the search mode
has been found, 1 indicates that it has not been found, 2 indicates that command grep
can not open the file you want to search.

For Bourne shell, variable $? save the exit state of the final executing command, it has

217
the same function as the state variables in C shell . In general, 0 indicates success and 1
indicates failure.

C shell set the variable state to the exit state of the final command automatically. We can
use command echo to display the exit state under prompt .

When writing shell scripts, you can add "exit 0" at the end of the script to show that it
has completed successfully. The other values indicate the error of the process.
3.3.1.7 Mathematical opertion
We can only carry out integer arithmetic in three shell. If you have to do more
complicated arithmetic, you can use the command awk. Carry out arithmetic in Bourne
shell , you can use the expr command.
The following is a grammar:
expr arguments
The mathematical operators (shown in Table 16-15) and the operands shold be separated
by a space.

Table 16-15 Mathematical Operators

218
Multiplication, division and remainder operators, have a higher priority than addition or
subtration operator. You can mix them in parentheses.
The following example uses the expr command

Korn shell has a built-in command "let" and "$ (())" to carry out the arithmetic
operation.
Command "@" in C shel has the same function as the command expr in Bourne and
Korn shell. Command @ calculates the value of the arithmetic expression and assigns it
to a shell variable, just as listed in Table 16-16. Expressions can be mathematical or
logical. The mathematical expressions use the operators shown in Table 16-15. Logical
expressions use the following operators, and generate a value of 1 (correct) or 0
(wrong):

The following examples show how C shell carries out numerical calculation:

219
Table 16-16 Mathematical operators in C shell

3.3.1.8 User-defined functions


We can write our own functions in Bourne and Korn shell which could be used in other
scripts.
【Note】 Not all Bourne shell support function. Bourne shell in Solaris2.x supports
function.

When we hope to repeat using a series of commands, it is very useful to define our own
function. The functions compiled for the application server is an example of user-
defined functions. Some examples of functions will be provided in section 3.3.2
"example script". When a function has been defined, we can use this function when we
hope to use the commands contained by this function.
We usually define functions at the beginning of the script, but we can also define them
in the other documents and share them among the scripts. We can use this function
many times as soon as the function has been defined.
Use the following grammar to define functions:

220
Shell functions and shell scripts use the positional parameters and special variables in
the same way, such as * and #. In general, we can define several different functions in a
shell script. Each function deals with the parameters as positional parameters. These
positional parameters "cover" the command-line parameters.
To call a function when the function would like to use the functions provided by the
local name to write on the function. The following script of Bourne shell defines and
uses a simple function:

The following shows the output of the script:

3.3.1.9 Debug shell scripts


The following sections provide some suggestions of debugging shell scripts.

3.3.1.9.1 Use debug symbol


The common problem is that we do not get the desired results after the shell scripts have

221
been explain by shell. When shell explains command-line , it will replace the variable
with the value and use the appropriate file to replace the wildcard of the file name and
carry out command substitution. If the interpreter converts the commands into the
unwished contents, the command may not be able to execute in the desired manner.
All the three shell provide the -x (echo) and-v (verbose) option, use which could help us
to find where the problems arise in the script. Option -v displays every line when the
script reads from the document. Option -x displays the contents of each line, which have
been treated by shell and wait to be executed. Combination of these two options could
provide more useful information for debugging scripts.

We can use these options in command-line, as follows:

Alternatively, we could set up options in the first line of the script, as follows:

The following example shows the regard script with the -x option, as well as its screen
output:

222
The following example shows the output of the same script with -v option setting:

The following example shows the output of the same script with -vx options setting:

223
3.3.1.9.2 analytic sequence of shell
Various analytic commands in shell, should be broken down into identifiable parts either
from the command line or in a script. Shell could carry out a variety of outspread and
replacement. These operations result in different anaylsis sequence in different shell.
For each shell, there is a clear grammar analytic in order to ensure the accuracy of the
writing of shell. Understanding grammar analytic sequence can help determine where
the problems happen in the script. Figure 16-2 shows a simple version of grammar
analytic sequence in Korn shell. When a command or a string is quoted, the grammar
analytic sequence will be affected. Analytic sequence of Bourne shell is very similar
with Korn shell, it ignores history record and alias replacement.

224
Figure 16-2 analytic sequence of Korn shell
Figure 16-3 shows a simple version of the grammar analytic sequence of C shell.
Because the outspread of the variable is after the redirection, the error occurres in the
following script of B shell.

225
Section 3.3.2 includes the reference table of shell programming and a number of
complex shell scripts.

Figure 16-3 Analytic sequence of C shell .


3.3.2 Reference table and script examples
3.3.2.1 Reference table
This section contains the elements list of grammar in the all three kind scripts and shell

226
script examples.
3.3.2.1.1 Environmental documents

3.3.2.1.2 First line of scripts

3.3.2.1.3 Directory operator in Korn shell

3.3.2.1.4 Variables modifiers in C shell

3.3.2.1.5 Variables initialized by shell

3.3.2.1.6 Built-in commands in shell

227
3.3.2.1.7 Redirection in Brurne and Korn shell

228
3.3.2.1.8 Redirection in C shell

3.3.2.1.9 Representation of the $argv in C shell

3.3.2.1.10 Quote

3.3.2.1.11 Syntax with no characters

229
3.3.2.1.12 Shell syntax on variables

3.3.2.1.13 I/O redirection and pipe function

3.3.2.1.14 Display the output on screen

3.3.2.1.15 Get input from keyboard

230
3.3.2.1.16 figures and calculations

3.3.2.1.17 Command replacement

3.3.2.1.18 Outspread of (~)

3.3.2.1.19 Syntax of alias

3.3.2.1.20 Syntax of history records

231
3.3.2.1.21 Function syntax

3.3.2.1.22 Syntax of control programming language

3.3.2.1.23 Judge and the built-in command of C shell

232
3.3.2.1.24 Mathematical operators in Bourne shell

3.3.2.1.25 Mathematical operators in C shell

233
3.3.2.2 Script examples
This section contains some examples of the Bourne shell script.

3.3.2.2.1 anonymous ftp script

234
235
236
237
238
239
3.3.2.2.2 function arch.sh.fctn
The script of arch.sh.fctn simulates the system architecture of SunOS 4.x .

240
FAQ Q & A:
1.
Any doubt about the contents of this chapter, please write the questions behind FAQ,
according to the sequence of 1,2,3, ..., and send the problem back to us, we will
respond as soon as possible, thank you! (Nanjing NARI Autocontrol Co., Ltd. /
Engineering Center / Technical Support)

241
Chapter IV Practical Help of Windows Operating System
4.1 DOS command
4.1.1 Commands of directory operation
4.1.1.1 MD - establish a subdirectory
1. Functions: create a new subdirectory
2. Type: internal command
3. Format: MD [drive:] [pathname] <subdirectory name>
4. Usage:
(1) "drive": specify the letter of the disk drive of the created subdirectory, which is the
current drive if omitted;
(2) "pathname": the higher level directory of the subdirectory that will be created, build
in the current directory if default.
Cases: (1) create a subdirectory named FOX in the C disk root directory ; (2) create a
subdirectory USER in the subdirectory FOX.
C: \> MD FOX (create a subdirectory FOX in the current drive C disk)
C: \> MD FOX\USER (create a subdirectory USER in the subdirectory FOX)

4.1.1.2 CD - change the current directory


1. Function: display the current directory
2. Type: internal command
3. Format: CD [drive:] [pathname] [subdirectory name]
4. Usage:
(1) If the path and subdirectory name have been omitted, show the current directory;
(2) If use the format of "CD," , go back to the root directory;
(3) If use the format of "CD..", go back to the previous directory;
Cases: (1) enter the subdirectory USER; (2) go back to the subdirectory from the USER
subdirectory ; (3)return to the root directory.
C: \> CD FOX\USER ( enter the USER subdirectory under the FOX subdirectory )
C: \FOX、USER> CD.. ( return to the higher level root directory )

242
C: \ FOX> CD\ ( return to the root directory )
C: \>

4.1.1.3 RD - delete a subdirectory


1. Functions: remove the directory from the specified disk.
2. Type: internal command
3. Format: RD [drive:] [pathname] [subdirectory name]
4. Usage:
(1) subdirectory must be empty before deleted, that is required to enter the subdirectory
first, use DEL (command deletes the file ) to delete the document under the
subdirectory, and then go back to the higher level directory, delete the directory itself
with command RD ;
(2) can not delete the root directory and the current directory.
For example: delete the USER subdirectory under the subdirectory FOX in C disk, the
operation is as follows:
The first step: delete all the documents under the USER subdirectory first;
C: \> DEL C:\FOX\USER、 *. *
The second step, delete the USER subdirectory.
C: \> RD C:\FOX\USER
4.1.1.4 PATH - the path setting up command
1. Function: the searth path of equipment executable documents, only effective to the
documents.
2. Type: Internal command
3. Format: PATH [drive 1] directory [path name 1] ([; driver 2:], <the directory path
name 2> ...)
4. Usage:
(1) When running an executable file, DOS will first search the file in the current
directory, if found run it; if not found, according to the path setting by command PATH,
search the file in the directory one by one and orderly;
(2) path in command PATH, if more than two, each path separated by a semicolon ";";

243
(3) there is three methods of using command PATH:
PATH [drive 1:] [path 1] [drive 2:] [Path 2] ... (set the searching path of the executable
files)
PATH: (abolition all paths)
PATH: (show the current setting path)

4.1.1.5 TREE - dispaly the disk directory structure


1. Function: show all the directory path in the specified drive and all the file names in
these directory.
2. Type: External command
3. Format: TREE [drive:] [/F] [ 》PRN]
4. Usage:
(1) use parameter /F to display all directories and all the documents in the directory,
when omitted, only show the directories, not show the documents in directories;
(2) choose parameter >PRN, print the directories listed and the name of files in the
directory.

4.1.1.6 DELTREE - delete the entire directory


1. Function: delate the entire directory and its subdirectories and files.
2. Type: External command
3. Format: DELTREE [drive:] <Path name>
4. Usage: by one step, the command can delete the directory and all files, subdirectories,
and the lower subdirectories all together, regardless of hidden, system or read-only file
attributes, as long as the file is located in the directory to be deleted soon. DELTREE
treats equally without discrimination, deletes all. Be careful when use! ! !

4.1.2 Disk operation command


4.1.2.1 FORMAT - format disk
1. Function: format the disk, carve up into tracks and sectors; check whether there is
defective track in the entire disk at the same time, add tags on Bad Track; create the

244
directory area and file allocation table, get the disk ready to receive from the DOS.
2. Type: External command
3. Format: FORMAT <Drive:> [/S] [/4] [/Q]
4. Usage:
(1) the drive can not be default, if format the hard disk, will be prompted as follows:
WARNING: ALL DATA ON NON - REMOVABLE DISK
DRIVE C: WILL BE LOST!
Proceed with Format (Y / N)?
(2) if format the floppy disk, will be prompted as follows: Insert mew diskette for drive
A; and press ENTER when ready ...
(3) choose parameter [/S], will copy IO.SYS, MSDOS.SYS and COMMAND.COM of
DOS system filesto the the disk, so that the disk can be used as DOS boot disk. If not
choose parameter /S, the formatted disk could only read and write information, and
could not be used as a boot disk;
(4) choose parameters [/4] format 360KB low-density disc in the 1.2MB high-density
floppy drive;
(5) choose parameter [/Q], quick format, this parameter will re-divide track and disk
sector, only clear the root directory of the disk, file allocation table and boot sector, the
format speed is much faster.
(6) choose parameter [/u], denote unconditional format, that is, destory all data on the
original disk. Without /U, is safe format, in this case establish a mirror file to restoret
the original FAT table and root directory, if necessary, use UNFORRMAT to restore the
original data.

4.1.2.2 UNFORMAT - restore format


1. Functions: recover the disk which has been formatted by mistake.
2. Type: External command
3. Format: UNFORMAT <drive> [/L] [/u]

245
[/TEST]
4. Usage: recover the "non-destructive" formatted disk. When the files are deleted in the
root directory or the subdirectory and the disk sectors of the system (including FAT, root
directory, BOOT sector and hard disk partition table), are damaged, we can also use
UNFORMAT to rescue .
(1) choose parameter /L to list the found subdirectory name, file name and so on, but
will not really FORMAT.
(2) choose parameter /P to send the report to the printer which is displayed on the
screen(include the information that parameter /L parameter generates). Screen will
appear: "Print out will be sent to LPT1" at the running time.
(3) choose parameter /TEST to simulate(TEST) but not write really. Using this
parameter the screen will display : "Simulation only"
(4) choose parameter /U in order to use the MIRROR image file data, directly
UNFORMAT base on the disk status.
(5) choose /PSRTN; repair the hard disk partition table.
Adding one of the parameters of /P, /L, /TEST after the drive, is the same as using
parameter /U, UNFORMAT will "suppose" there is no MIRROR image file in the disk
at this time.
【Note】UNFORMAT can totally retore the disk which is just formatted, but if you
have written other data after FORMAT, UNFORMAT could restore the data
totally. UNFORMAT is not a panacea, because using UNFORMAT will rebuild
FAT and root directory, it also has a higher risk of enlarging the loss by improper
operation. If you only delete a few documents or subdirectories by mistake, it is
enough to use UNDELETE.

4.1.2.3 CHKDSK - check the current state of the disk


1. Function: display disk status, memory status and under the specified path is not
specified for the number of documents.
2. Type: External command

246
3. Format: CHKDSK [drive:] [path] [filename] [/F] [/V]
4. Usage:
(1) choose parameter [filename], it will show the occupation of the disk by this file;
(2) choose parameter [/F], correct the specified logical disk error which has been found;
(3) choose parameter [/V], show all the files and path on the disk.

4.1.2.4 DISKCOPY - copy the entire disk


1. Function: copy the floppy disk of the same format and content.
2. Type: External command
3. Format: DISKCOPY [letter 1:] [letter 2:]
4. Usage:
(1) If the target floppy disk is not formatted, the system will automatically format when
copy.
(2) If the target floppy disk inheres documents, they will miss when copy has been
carried out.
(3) If it is a single drive copy, you will be prompted to replace the source and target disk
timely, please pay attention to distinguish between the source disk and the target disk.

4.1.2.5 LABEL - establish disk label


1. Function: establish, change, delete the disk label.
2. Type: External command
3. Format: LABEL [drive:] [label name]
4. Usage:
(1) the label name is the label name to be created, if default parameter, the system
prompte you to type the label name or ask whether to delete the original label;
(2) label is made up of characters of 1 to 11.

4.1.2.6 VOL - display disk label


1. Function: Show disk volume label.

247
2. Type: Internal command
3. Format: VOL [drive:]
4. Usage: omit the drive, show the current drive label.

4.1.2.7 SCANDISK - check, repair disk


1. Function: check whether there are any problems of FAT table, directory structure, file
system on the disk and repair the problems which have been detected.
2. Type: External command
3. Format: SCANDISK [drive 1:] ([drive 2:] ...) [/ALL]
4. Usage:
(1) CCANDISK applies to the hard disk and the floppy disk, you can specify more than
one disk or choose parameter [/ALL] to specify all the disk;
(2) automatically detect logical errors such as occurred cross connection, lost clusters
and directory structure, and repair them.

4.1.2.8 DEFRAG - reform disk


1. Function: reform the disk, eliminate disk fragments.
2. Type: External command
3. Format: DEFRAG [drive:] [/ F]
4. Usage: choose parameter /F, eliminate fragments exists on disk, and reform the
arrangements of the disk files, ensure that there is no gap between documents. Thus
speed up the reading speed and save disk space.

4.1.2.9 SYS - System Copy command


1. Function: send the DOS system files IO.SYS, MSDOS.SYS and COMMAND.COM
in the current drive to the designated drive.
2. Type: External command
3. Format: SYS [drive:]
* Usage: if there is not enough disk space for the storage of system files, then prompt:
No roomfor on destination disk.

248
4.1.3 File operation commands
4.1.3.1 COPY - copy files
1. Function: copy one or more files to the specified disk.
2. Type: Internal command
3. Format: COPY [source disk] [path] <source file name> [target disk] [path] [target file
name]
4. Usage:
(1) COPY copies the data by the way of file to file, the target disk should be formatted
before copied;
(2) in copy process, the old document will be replaced by the source file of the same
filename;
(3) when copy the files, you must first confirm there is enough room in the object,
otherwise there will appear "insufficient" error message, which suggest not enough disk
space;
(4) allow the use of wildcard "*" "?" in the file name, copy a few files at the same time;
(5) the source file name, which could not be omitted, must be pointed out in COPY
command.
(6) when copy, the target file name can be the same as the source file name, called the "
the same name copy," in this case the target file name could be omitted;
(7) when copy, the target file name can also different from the source file name, called
"synonyms copy," in this case, the target file name can not be omitted;
(8) when copy, you can also combine a number of documents into a single document,
called " combine copy", the format is as follows: COPY; [Source Disk] [path] <source
file name 1> <source file name 2> ... [target disk] [path] <target file name>;
(9) using COPY command, you can input data from the keyboard to create documents,
the format is as follows: COPY CON [drive:] [path] <file name>;
(10) Note: the using format of command COPY, there must be a space between the
source filename with the target filename!

249
4.1.3.2 XCOPY - copy directory command
1. Function: copy the specified directory and all files under the directory together with
the directory structure.
2. Type: External command
3. Format: XCOPY [source disk:] <source path name> [target drive:] [target path name]
[/S] [/V] [/E]
4. Usage:
(1) XCOPY is the expansion of COPY, which can copy the specified directory
containing files and the directory structure, but except the hidden files and system files;
(2) you must specify at least one of the source drive, target path name of the source, the
source filename;
(3) all files under the source directory and its subdirectories will be copied when
chosse /S. Unless specifing parameter /E, otherwise /S will not copy empty directories,
if not specify parameter /S, then XCOPY will only copy the source directory itself,
rather than involving subdirectorier under;
(4) choose parameter /V, inspect all the copied sector, but the speed will be reduced.

4.1.3.3 TYPE - display contents of the document


1. Function: display ASCII code document.
2. Type: Internal command.
3. Format: TYPE [drive:] [path] <file name>
4. Usage:
(1) Show the text file made up of the ASCII code. To the documents with the
extension .EXE or .COM, the displayed contents can not be read, because there is no
practical significance;
(2) The command could only show the contents of a file at one time, and can not use
wildcards;
(3) If the file has an extension, the extension must be written on;

250
(4) When a document is longer than one screen, you can show it as the following
format; TYPE [drive:] [path] <file name> | MORE. MORE is the dispart-screen display
command. Using these parameters, it will be suspended when the screen is full, and you
can press any key to continue the display.
(5) If you need to print the content of the document, you can use the following format:
TYPE [drive:] [path] <file name>,> PRN
At this time, the printer should be online.

4.1.3.4 REN - rename file


1. Function: change the file name
2. Type: Internal command
3. Format: REN [drive:] [path] <old file name> <new file name>
4. Usage:
(1) Can not add drive and path before the new file name, because the command could
only change the name of the files on the same disk;
(2) Allow using wildcards to change a set of file name or extension.

4.1.3.5 FC - file compare


1. Function: compare the similarities and differences between documents and sets out
the differences.
2. Type: External command
3. Format: FC [drive:] [pathname] <file name> [drive:] [pathname] [filename] [/A] [/C]
[/N]
4. Usage:
(1) choose parameter /A, compare in ASCII model;
(2) choose parameter /B, compare in binary model;
(3) choose parameter /C, regard the upper and lower characters as the same characters.
(4) choose parameter /N, show the different line number when compare in the ASCII
model

251
4.1.3.6 ATTRIB - modify file attribute
1. Function: Modify the attribute of the specified file. (refer to the section of file
attributes 2.5.4 (b))
2. Type: external command.
3. Format:
ATTRIB [filename] [R] [-R] [A] [-A] [H] [-H] [S] [-S] [/S]
4. Usage:
(1) choose parameter R to specify the document with read-only attribute, make the
document could only be read, could not be write or delete; choose parameter -R to
remove the read-only attribute;
(2) choose parameter A to set the file with file attributes; choose parameter -A to remove
the file attributes;
(3) choice parameter H to set the file with hidden attributes; choose parameter -H to
hide attribute;
(4) choice parameter S to set the file with system attributes; choose parameter -S to
remove the system attributes;
(5) choose parameter /S to set all subdirectories under the current directory.

4.1.3.7 DEL - delete the file


1. Function: delete the specified file.
2. Type: Internal command
3. Format: DEL [drive:] [path] <file name>
4. Usage:
(1) choose parameter /P , the system will ask whether you really want to delete the file.
If not use this parameter, it will delete automatically;
(2) the command can not be used to delete the files with hide attribute or read-only
attribute;
(3) you can use wildcards in the file name ;
(4) To delete all the files on disk (DEL *.* or DEL .), you will be prompted: (Arey ou

252
sure?) If answer Y, then delete. If answer N, then this delete operation will be canceled.

4.1.3.8 UNDELETE - recover the deletion


1. Function: recover the deletion
2. Type: external command.
3. Format: UNDELETE [drive:] [pathname] <file name> [/DOS] /LIST] [/ALL]
4. Usage: use UNDELETE can use wildcard "*" and "?" .
(1) choose parameter /DOS to restore files according to the residual records in the
directory. When the files have been deleted, the first character of the recorded filenames
will be replaced by E5. DOS finds the files, which will be restored, based on the
beginning E5 and its following characters. Therefore, UNDELETE will require users to
enter a character, in order to fill the document name. But the character do not have to be
the same as the character before, it will be ok if it is in line with the rules of naming
DOS file.
(2) choose /LIST to "list" the documents which are accord with the specified conditions,
and refuse to do the recovery, so it will not affect the contents of the disk.
(3) Choose /ALL to restore the document totally and automatically, which could be
totally restored, rather than ask the user one by one. When using this parameter, if
UNDELTE use residual records in the directory to restore the files, it will select a
character to fill with the name of the files automatically which is not the same as the
existing file name. The preferred order of choosing the characters is: #%--
0000123456789A ~ Z.
UNDELETE document also has the function of setting up the protective measures of the
files. But it has gone beyond the scope of this course, please refer to the DOS manual
when using these functions.

4.1.4 Other commands


4.1.4.1 CLS - clear screen
1. Functions: remove all the on-screen display, place the cursor in the upper left corner

253
of the screen.
2. Type: Internal command
3. Format: CLS
4.1.4.2 VER - see system version
1. Function: display the current system version
2. Type: Internal command
3. Format: VER
4.1.4.3 DATA - set date
1. Function: set or display system date.
2. Type: Internal command
3. Format: DATE [mm - dd - yy]
4. Usage:
(1) Omit [mm - dd - yy] to display the system date and it will prompt you to enter a new
date. You can press enter directly if you do not want to modify the date, [mm - dd - yy]
is the format of "month - day - year;
(2) When the machine begin to startup, automatical disposal file (AUTOEXEC.BAT)
will be executed. That's why the system do not prompt you to enter the system date.
Otherwise, it will prompt you to enter the new date and time.

4.1.4.4 TIME - set the system clock


1. Function: set or display system time
2. Type: Internal command
3. Format: TIME [hh: mm: ss: xx]
4. Usage:
(1) Omit [hh: mm: ss: xx] to display the system time and prompt you to enter a new
time. You can press enter directly if you do not want to modify, [hh: mm: ss: xx] is the
format of "hour: minute: second: centisecond ";
(2) When the machine begin to startup, automatical disposal file (AUTOEXEC.BAT)
will be executed. That's why the system do not prompt you to enter the system date.
Otherwise, it will prompt you to enter the new date and time

254
4.1.4.5 MEM - see the current memory usage
1. Function: Display the current memory usage
2. Type: External command
3. Format: MEM [/C] [/F] [/M]
4. Usage:
(1) choose parameter /C to list conventional memory and the length of the files of CMB,
and also show the usage of memory space and the largest available space;
(2) choose parameter /F to list the current remaining bytes of conventional memory and
the available area and size of UMB;
(3) choose parameter /M to show the address 、 size and chararcters of the memory
which the module uses;
(4) choose parameter /P to specify that when the output is more than one screen, it will
suspend for the user to view.

4.1.4.6 MSD - Display System Information


1. Function: display the status of the system hardware and the operating system.
2. Type: External command
3. Format: MSD [/S]
4. Usage:
(1) choose parameter /I to not detect the hardware;
(2) choose parameter /B to start the MSD by the way of black-and-white;

(3) choose parameter /S to show the concise report of the system.

4.2 Detail explain of utility command of windows


4.2.1 explanation of network command
4.2.1.1 the using skills of command Ping

255
Ping is a practical procedures of high using frequency, it is used to determine whether
the local host could exchange datawith another host(send and receive). According to the
returned information, we could be able to infer whether TCP/IP parameters have been
set correctly and whether it operates normally. Which need to pay attention is that the
successful exchange of data with another host one or two times does not mean that the
TCP/IP configuration is correct, we need to carry out a large number of data exchange
between the local host and remote host to make sure correct of TCP/IP.
In one word, Ping is a test procedure, if Ping is running correctly, we can on the whole
rule out the exist fault of the the network access layer, network card, the input and
output lines of MODEM, cables and routers, thereby reduce the scope of the problem.
However, as we can customize the size of data and send endlessly and high-speedly,
Ping is also used by some people with ulterior motives as a DDOS (denial of service
attacks) tools. For example, many large-scale website have been paralyzed by hacker
using hundreds of high-speed computer which could connect to the Internet to send a
large number of Ping Datagram.
According to the default settings, the running Ping in windows sends four ICMP
(Internet Control Message Protocol) echoplex request, each of which contains 32 bytes
of data. If everything goes well, we could be able to receive four responses. Ping can
display the amount of time between sending request and sending back response in
milliseconds. If the response time is short, that means the data do not have to go through
too many routers or network connections, and the speed is very fast. Ping also show
TTL (Time To Live) value. We could calculate how many routers the packets have gone
through according to the TTL value: the original TTL value of the source location (the
power number which is slightly larger than the return TTL ) - the return TTL value. For
example, if the return TTL value is 119, then we can calculate the original TTL value is
128 when the packets leave the source address. And there are 9 router net segment(128-
119) from the source location to the target location; If the return TTL value is 246, the
original TTL value is 256, and there are 9 router net segment from the source location to
the target location.

256
1. the typical sequence to detect network fault through Ping
Under normal circumstances, when we use the Ping command to find the problem or
test network performance, we need to use many Ping command. If all of them run
correctly, we can confirm that the connectivity and the basic configuration parameters
are ok; if some Ping command fail, they can also point out where to lookup the
question. The following is a typical look-over sequence and corresponding possible
failure:

● ping 127.0.0.1
The Ping command is sent to the local computer's IP software, the command will never
quit from the computer. If not, it means that the installation of TCP/IP or the run have
some most basic problems.

● ping the local IP


This command is sent to our own computer IP address, our computer should always
respond to the Ping command, and if not, that means the local configuration or
installation has problems. When this problem occurs, the uses of the LAN cable should
disconnect from the network, and then re-send the command. If the command is corret
after the reticle has been removed, that means another computer may be configured with
the same IP address.

● ping other LAN IP


This command will leave our computer, go through the network card and network
cables to other computers, and then return. Receiving responses indicates that the local
network card and the carrier run well. However, if receive 0 response, that means the
subnet mask (when divide subnet, the code separate the network part from the host part
of IP address) is not or the network card is incorrectly configured or the cable system
has problems.

257
● ping the gateway IP
If the response of this command is correct, that means the network gateway router of the
local area is running and it is able to respond.

● ping a remote IP
If you receive four responds, that means the successful use of the default gateway. For
dial-up users that means they could successfully access Internet (but do not rule out the
ISP's DNS will have issues).

● ping localhost
localhost is a network reserve name for the system, it is an alias for 127.0.0.1, each
computer should be able to convert the name into address. If not, that means the host
file (/Windows/host) is not correct.

● ping www.xxx.com (such as www.yesky.com)


Ping the domain name, which address is www.xxx.com, is usually through the DNS
server. If there is failure here, that means the DNS server IP address configuration is
incorrect or the DNS server has problem(for dial-up users, they do not need to set DNS
server for some ISP). By The way, We can also use the command to the domain name
conversion on the IP address.
If all the Ping conmmand listed above can normally operate, our own local and remote
computer communications function can be largely relieved. However, the success of
these commands does not mean that we have no problem with the network
configuration. For example, some certain subnet mask errors may not be able to detect
with these methods.

2. Ping command parameters of the commonly used options


● ping IP Ct
Ping the IP address with Ping command continuously, until the user interrupt it with Ctrl

258
+ C.

● ping IP-l 3000


Designate the length of data in Ping command by 3000 bytes, rather than the default of
32 bytes.

● ping IP Cn
Perform the Ping command specific times.

4.2.1.2 the using skills of Netstat command


Netstat is used to display the related statistics of protocol IP, TCP, UDP and ICMP , it is
generally used to test the local network connections of the port.
If received data of our computer will lead to the deletion of wrong data or failure
sometimes, we do not have to be surprised. TCP/IP could allow these types of errors,
and can automatically send data again. But if the number of cumulative errors accounted
for a considerable percent of the received IP datagram, or its number is rapidly
increasing, then we should use Netstat to check why there is such situation.
1. Some commonly option of netstat
● netstat Cs
The option could show the statistical data respectively according to each protocol. If our
applications (such as the Web browser) run slowly, or could not show the data such as
Web page, then we can use this option to view the information. We need to carefully
review each line of the statistical data, find the error keywords and identify where the
problem lies.

● netstat Ce
The option is to display the statistical data about the Ethernet. It lists the items,
including the total number of bytes, the number of errors, the number of deletions, the
number of data and the number of broadcast of the delivery data. Such statistical data

259
include both the number of sent data and the number of received data. This option can
be used to calculate some of the basic network flux).

● netstat Cr
This option displays information about the routing table, which is similar to the
information when using the route print command. Besides the effective router, it also
show the current effective connection.

● netstat Ca
This option displays a information list of all the valid connections, including the
established connections(ESTABLISHED), and the connections which is used to monitor
requests(LISTENING).

● netstat Cn
Show all the valid established connections.
The following sample is the output of command netstat:
C: \> netstat-e
Interface Statistics
Received Sent
Bytes 3995837940 47224622
Unicast packets 120099 131015

Non-unicast packets  7579544    3823


  Discards        0       0
  Errors         0       0
  Unknown protocols   363054211
  C:\>netstat -a
  Active Connections
  Proto Local Address   Foreign Address    State
  TCP CORP1:1572    172.16.48.10:nbsession  ESTABLISHED

260
  TCP CORP1:1589    172.16.48.10:nbsession  ESTABLISHED
  TCP CORP1:1606    172.16.105.245:nbsession ESTABLISHED
  TCP CORP1:1632    172.16.48.213:nbsession ESTABLISHED
  TCP CORP1:1659    172.16.48.169:nbsession ESTABLISHED
  TCP CORP1:1714    172.16.48.203:nbsession ESTABLISHED
  TCP CORP1:1719    172.16.48.36:nbsession  ESTABLISHED
  TCP CORP1:1241    172.16.48.101:nbsession ESTABLISHED
  UDP CORP1:1025    *:*
  UDP CORP1:snmp    *:*
  UDP CORP1:nbname   *:*
  UDP CORP1:nbdatagram *:*
  UDP CORP1:nbname   *:*
  UDP CORP1:nbdatagram *:*
  C:\>netstat -s
  IP Statistics
  Packets Received       = 5378528
  Received Header Errors    = 738854
  Received Address Errors   = 23150
  Datagrams Forwarded     = 0

 Unknown Protocols Received  = 0


  Received Packets Discarded  = 0
  Received Packets Delivered  = 4616524
  Output Requests       = 132702
  Routing Discards       = 157
  Discarded Output Packets   = 0
  Output Packet No Route    = 0
  Reassembly Required     = 0
  Reassembly Successful       = 0
  Reassembly Failures        =

261
  Datagrams Successfully Fragmented = 0
  Datagrams Failing Fragmentation  = 0
  Fragments Created         = 0
  ICMP Statistics
  Received Sent
  Messages         693    4
  Errors          0     0
  Destination Unreachable 685    0
  Time Exceeded      0     0
  Parameter Problems    0     0
  Source Quenches     0     0
  Redirects        0     0
  Echoes          4     0
  Echo Replies       0     4
  Timestamps        0     0
  Timestamp Replies    0     0
  Address Masks      0     0
  Address Mask Replies   0     0
  TCP Statistics
  Active Opens         = 597
  Passive Opens        = 135
  Failed Connection Attempts  = 107
  Reset Connections      = 91
  Current Connections     = 8
  Segments Received      = 106770
  Segments Sent        = 118431
  Segments Retransmitted    = 461
  UDP Statistics
  Datagrams Received  = 4157136
  No Ports       = 351928

262
  Receive Errors    = 2
  Datagrams Sent    = 13809

2. Artful Use of Netstat


People who access to the Internet frequently usually use ICQ. We are annoyed by
someone sometimes, and we want to complaint but do not know where to start? In fact,
we just need to know the ip of the other side, then we could complain to which ISP he
belongs. But how can we know the his IP through ICQ? We could not see his IP in the
information column, if he choose not to show the IP address when setting up ICQ. In
fact, we could do it conveniently through Netstat: when he connects us through ICQ or
other tools(for example, we send him a ICQ message or he send a message to us). Under
DOS command prompt, enter netstat-n or netstat-a immediately, then we can see the
used IP or ISP domain name, even the used Port.

4.2.1.3 the using skills of IPConfig command


IPConfig utility process and its equivalent graphical user interface ---- WinIPCfg can be
used to display the current TCP/IP configuration in Windows 95/98. This information is
used to test whether the configuration of TCP/IP settings are correct. However, if our
computer and the local area network where our computer locates use Dynamic Host
Configuration Protocol (DHCP), the shown information this procedure may be more
practical. At this time, IPConfig enable us to understand whether our own computers
have rented a IP address successfully, if rented, we can know what address it is assigned
to. Know the computer's current IP address, subnet mask and default gateway is the
necessary items to test and carry out failure analysis.

1 the most commonly option of IPConfig


● ipconfig
When using IPConfig without any parameters, it shows the configured IP address,
subnet mask and default gateway values of each interface.

263
● ipconfig /all
When using option all, IPConfig shows the configuration and the used addtional
information of DNS and WINS server(such as IP address, etc), and shows the built-in
MAC address of the local network. If the IP address is leased from the DHCP server,
IPConfig will show the IP address of DHCP server and the intending ineffective date.

● ipconfig /release and ipconfig /renew


These are two additional options, which could only be effective to the computers that
lease IP address from the DHCP server. If we enter ipconfig /release, then all interface
IP address of the rental will re-deliver to the DHCP server (return IP address). If we
enter ipconfig /renew, the local computer will try to get in touch with the DHCP server
and lease a IP address . Please note that in most cases the network card will be re-
entrusted with the same IP address as the one given previously.

The following is an example of the output of ipconfig /all, the computer is configured to
use DHCP server to dynamically allocates TCP/IP, and use WINS and DNS servers to
resolve names.

Windows 2000 IP Configuration


Node Type .........: Hybrid
IP Routing Enabled .....: No
WINS Proxy Enabled .....: No

 Ethernet adapter Local Area Connection:


  Host Name.. . . . . . . . : corp1.microsoft.com
  DNS Servers . . . . . . . : 10.1.0.200
  Description. . . . . . . : 3Com 3C90x Ethernet Adapter
  Physical Address. . . . . : 00-60-08-3E-46-07
  DHCP Enabled.. . . . . . . : Yes

264
  Autoconfiguration Enabled.: Yes
  IP Address. . . . . . . . . : 192.168.0.112
  Subnet Mask. . . . . . . . : 255.255.0.0
  Default Gateway. . . . . . : 192.168.0.1
  DHCP Server. . . . . . . . : 10.1.0.50
  Primary WINS Server. . . . : 10.1.0.101
  Secondary WINS Server. . . : 10.1.0.102
Lease Obtained.. . . . . . : Wednesday, September 02, 1998 10:32:13 AM
Lease Expires.. . . . . . : Friday, September 18, 1998 10:32:13 AM

If we are using Windows 95/98, then we should be more accustomed to using winipcfg
instead of ipconfig, because it is a graphical user interface, and shows the same
information as ipconfig, and also provides the options of releasing and updating
dynamic IP address.

4.2.1.4 ARP (ARP) of the use of skills


ARP is an important TCP/IP protocol and is used to determine the corresponding MAC
of the card to the IP address. Using arp command, we are able to view the current
content of the ARP cache in the local computer or another computer. In addition, using
arp command, you can manually enter a static physical network card/IP address, which
way we may use for the default gateway and the local server, and this will help to
reduce the the amount of information on the net.

In accordance with the default setting, the items in ARP cache is dynamic, when
sending a designated location and the data does not exist in the current items of the
cache, ARP will automatically add the item. Once the the items of the cache has been
input, they have begun to move toward a state of failure. For example, in Windows
NT/2000 networks, if not use the items further after input, physical/IP address will be
ineffective in within 2-10 minutes . Therefore, please do not surprised when there is

265
little or no items in the ARP cache, we can add by ping command from another
computer or router. Therefore, if you need to view the contents of the cache through the
arp command, please ping the computer first(not the ping command from this machine).

the commonly options of ARP command:


● arp-a or arp Cg
View all the items of the high-speed cache. The result is the same by using -a or -g
parameters. Over years the option -g has been used to display all the items in the ARP
cache on a UNIX platform, and arp -a in Windows(-a can be regarded as all, that is the
meaning of all), but it can also accept more traditional option -g.

● arp-a IP
If we have more than one card, then use arp-a added by the IP address of the interface,
you can display nothing but the items in the ARP cache associated with the interface.

● arp-s IP Physical Address


We can manually enter a static item to the ARP cache. This item will maintain an
effective state during the gudie process of the computer. Or in errors, the manual
configuration will automatically update the physical address of the item.

● arp-d IP
Using this command, we could manually delete a static item.

For example, in the command prompt, type Arp Ca; if we have used the Ping command
to test and verify the connectivit from the computer to the host with the IP address
10.0.0.99, then the ARP cache would display the following items:

Interface: 10.0.0.1 on interface 0x1


Internet Address Physical Address Type

266
10.0.0.99 00-e0-98-00-7c-dc dynamic

In this example, the cache points out the MAC address which is resolved into 00-e0-98-
00-7c-dc by the remote host locates at 10.0.0.99. It is assigned on the remote computer's
network adapter hardware. MAC address is physical communication address for the
computer wiht the remote TCP/IP on the net.

Thus we can use the command ipconfig and ping to see our own network configuration
and determine whether it is correct, use netstat to view the connections established
between other people and us, and to find the ICQ users' hidden IP information, use arp
to view the MAC address of the network card.

4.2.1.5 the using skills of Tracert, Route and NBTStat


1. The using skills of Tracert
If there are network connectivity issues, you can use the tracert command to check the
path to the destination IP address and record the results. Command tracert displays a
group of IP routers which is used to transmit the packets from the computer to the target
location, and each hop time. If packets could not get to the target, tracert command will
display the last router which transmits successfully. When the data is sent to the
destination from our computer through multiple gateway, Tracert command can be used
to track the used routing(path). The path the utility tracks is one path from the source
computer to the destination, and the data can not be guaranteed to always follow the
path. If we use the configuration of DNS, then we will often get the name of
cities 、 address and common communications company. Tracert is very slow(if the
designated destination address is very far), each router we need to give it about 15
seconds.
The usage of Tracert is very simple, we only need to add a IP address or URL to go after
tracert, Tracert will convert the corresponding domain name.
The most common use of tracert:

267
tracert IP address [-d]
This command return the list of router which is gone through to reach the IP address. By
using the-d option, it will display the router path faster, because tracert will not attempt
to resolve the name of the router path.
Tracert is used to detect the location of the failure generally, we can use tracert IP to
detect which part a problem occurs. Although we can not confirm what the problem is,
but it has told us where the problem lies, we could be able to tell others---- where the
problem is.
2. the using skills of Route
Most of the host generally stay on the network segment which only connects to one
router. Since there is only one router, so there is no doubt to use which router to send the
data to the remote computer, the router's IP address can be used as the the default
gateway of all the computers on the network segment.
However, when the network has two or more routers, we may not want to rely solely on
the default gateway. In fact we may want some of our remote IP address transmit
through a specific router, while the other remote IP transmit through another router.
In this case, we need the corresponding routing information, which is stored in the
routing table, and each host and each router are equipped with its own unique routing
table. Most routers use routing dedicated protocols to the exchange and dynamically
update routing tables between routers. However, in some cases, items must be manually
added to the routing table of the routers and hosts. Route is used to show 、manually add
and modify the items of routing table.
The general options:
● route print
This command is used to show the the current items in the routing table and the output
on the network segment which has a single router; as a result of using IP address to
configure the network card, all of these items are added automatically.

● route add

268
Using this command, we can add routing items to the routing table. For example, if we
want to set a routing to the network 209.98.32.33, which has to go through 5 router
network segment. First it will go through a router on the local network, whose IP is
202.96.123.5, subnet mask is 255.255.255.224, then we should enter the following
command:

route add 209.98.32.33 mask 255.255.255.224 202.96.123.5 metric 5

● route change
We can use this command to modify the data transmission route, but we can not use this
command to change the data destination. The following example of the data routing can
be changed to another router, it uses a more direct path which contains three network
segment:

route add 209.98.32.33 mask 255.255.255.224 202.96.123.250 metric 3

● route delete
We could use this command to delete the routing from the routing table. For example:
route delete 209.98.32.33

3. The using skills of NBTStat

Use nbtstat command to release and refresh NetBIOS names. The utility NBTStat (the
NetBIOS statistical data of TCP/IP) provides statistical data on the NetBIOS. Using
NetBIOS, we can view the NetBIOS name table of the local computer or remote
computer.

Commonly options:

269
● nbtstat Cn
Show the names and service procddures which are stored in the local.

● nbtstat Cc
This command is used to show the contents of the NetBIOS name cache . NetBIOS
name cache is used to store the NetBIOS computer names and IP addresses which
communicate with this computer recently.

● nbtstat Cr
This command is used to clear and reload the NetBIOS name cache.

● nbtstat-a IP
display another computer's physical address and the list of names through IP, the
contents that we show are the same as the contents that their own run the command
nbtstat-n.

● nbtstat-s IP
Show the NetBIOS connection table of another computer who uses the IP address.

For example, under the command prompt, we type nbtstat CRR to release and refresh
the progress of the process and output it in the command line form. This information
indicates that whether all the local NetBIOS names, which have registered in this
computer's WINS recently, have used WINS server to release and renew the
registration.

4.2.2 Windows command Guinness


accwiz.exe > Accessibility Wizard for walking you through setting up your machine for
your mobility needs.
acsetups.exe > ACS setup DCOM server executable

270
actmovie.exe > Direct Show setup tool
append.exe > Allows programs to open data in specified directories as if they were in
the current directory.
arp.exe > NETWORK Display and modify IP - Hardware addresses
at.exe > AT is a scheduling utility also included with UNIX
atmadm.exe > Displays statistics for ATM call manager.
attrib.exe > Display and modify attributes for files and folders
autochk.exe > Used to check and repair Windows File Systems
autoconv.exe > Automates the file system conversion during reboots
autofmt.exe > Automates the file format process during reboots
autolfn.exe > Used for formatting long file names
bootok.exe > Boot acceptance application for registry
bootvrfy.exe > Bootvrfy.exe, a program included in Windows 2000 that notifies the
system that startup was successful.
Bootvrfy.exe can be run on a local or remote computer.
cacls.exe > Displays or modifies access control lists (ACLs) of files.
calc.exe > Windows Calculators
cdplayer.exe > Windows CD Player
change.exe > Change { User | Port | Logon }
charmap.exe > Character Map
chglogon.exe > Same as using "Change Logon"
chgport.exe > Same as using "Change Port"
chgusr.exe > Same as using "Change User"
chkdsk.exe > Check the hard disk for errors similar to Scandisk 3 Stages must specify a
Drive Letter
chkntfs.exe > Same as using chkdsk but for NTFS NTFS
cidaemon.exe > Component of Ci Filer Service
cipher.exe > Displays or alters the encryption of directories [files] on NTFS partitions.
cisvc.exe > Content Index -- It's the content indexing service for I
ckcnv.exe > Cookie Convertor

271
cleanmgr.exe > Disk Cleanup, popular with Windows 98
cliconfg.exe > SQL Server Client Network Utility
clipbrd.exe > Clipboard viewer for Local will allow you to connect to other clipboards
clipsrv.exe > Start the clipboard Server
clspack.exe > CLSPACK used to create a file listing of system packages
cluster.exe > Display a cluster in a domain
_cmd_.exe > Famous command prompt
cmdl32.exe > Connection Manager Auto-Download
cmmgr32.exe > Connection Manager
cmmon32.exe > Connection Manager Monitor
cmstp.exe > Connection Manager Profile Manager
comclust.exe > about cluster server
comp.exe > ComClust Add, Remove, or Join a cluster.
compact.exe > Displays or alters the compression of files on NTFS partitions.
conime.exe > Console IME
control.exe > Starts the control panel
convert.exe > Convert File System to NTFS
convlog.exe > Converts MS IIS log files
cprofile.exe > Copy profiles
cscript.exe > MS Windows Scripts Host Version 5.1
csrss.exe > Client Server Runtime Process
csvde.exe > Comma Separated Variable Import/Export Utility
dbgtrace.exe > Terminal Server
dcomcnfg.exe > Display the current DCOM configuration.
dcphelp.exe > ?
dcpromo.exe > Promote a domain controller to ADSI
ddeshare.exe > Display DDE shares on local or remote computer
ddmprxy.exe >
debug.exe > Runs Debug, a program testing and editing tool.
dfrgfat.exe > Defrag FAT file system

272
dfrgntfs.exe > Defrag NTFS file system
dfs_cmd_.exe > configures a Dfs tree
dfsinit.exe > Distributed File System Initialization
dfssvc.exe > Distributed File System Server
diantz.exe > MS Cabinet Maker
diskperf.exe > Starts physical Disk Performance counters
dllhost.exe > dllhost is used on all versions of Windows 2000. dllhost is the hedost
process for all COM+ applications.
dllhst3g.exe >
dmadmin.exe > Disk Manager Service
dmremote.exe > Part of disk management
dns.exe > DNS Applications DNS
doskey.exe > recalls Windows command lines and creates macros
dosx.exe > DOS Extender
dplaysvr.exe > Direct Play Helper
drwatson.exe > Dr Watson for 2000 Fault Detector
drwtsn32.exe > Dr Watson for 2000 viewer and configuration manager
dtcsetup.exe > Installs MDTC
dvdplay.exe > Windows 2000 DVD player
dxdiag.exe > Direct-X Diagnostics
edlin.exe > line-oriented text editor.
edlin.exe > line-oriented text editor.
esentutl.exe > MS Database Utility
eudcedit.exe > Private character editor Ture
eventvwr.exe > Windows 2000 Event Viewer
evnt_cmd_.exe > Event to trap translator; Configuration tool
evntwin.exe > Event to trap translator setup
exe2bin.exe > Converts EXE to binary format
expand.exe > Expand Files that have been compressed
extrac32.exe > CAB File extraction utility

273
fastopen.exe > Fastopen tracks the location of files on a hard disk and stores the
information in memory for fast access.
faxcover.exe > Fax Cover page editor
faxqueue.exe > Display Fax Queue
faxsend.exe > Fax Wizard for sending faxes
faxsvc.exe > Starts fax server
fc.exe > Compares two files or sets of files and their differences
find.exe > Searches for a text string in file or files
findstr.exe > Searches for strings in files
finger.exe > Fingers a user and displays statistics on that user Finger
fixmapi.exe > Fix mapi files
flattemp.exe > Enable or disable temporally directories
fontview.exe > Display fonts in a font file
forcedos.exe > Forces a file to start in dos mode.
freecell.exe > Popular Windows Game
ftp.exe > File Transfer Protocol used to transfer files over a network connection
gdi.exe > Graphic Device Interface
grovel.exe >
grpconv.exe > Program Manager Group Convertor
help.exe > displays help for Windows 2000 commands
hostname.exe > Display hostname for machine. Hostname
ie4uinit.exe > IE5 User Install tool
ieshwiz.exe > Customize folder wizard
iexpress.exe > Create and setup packages for install
iisreset.exe > Restart IIS Admin Service
internat.exe > Keyboard Language Indicator Applet
ipconfig.exe > Windows 2000 IP configuration.
ipsecmon.exe > IP Security Monitor
ipxroute.exe > IPX Routing and Source Routing Control Program
irftp.exe > Setup FTP for wireless communication

274
ismserv.exe > Intersite messaging Service
jdbgmgr.exe > Microsoft debugger for java 4
jetconv.exe > Convert a Jet Engine Database
jetpack.exe > Compact Jet Database.
jview.exe > Command-line loader for Java J
krnl386.exe > Core Component for Windows 2000
label.exe > Change label for drives
lcwiz.exe > License Compliance Wizard for local or remote systems.
ldifde.exe > LDIF cmd line manager
licmgr.exe > Terminal Server License Manager
lights.exe > display connection status lights
llsmgr.exe > Windows 2000 License Manager
llssrv.exe > Start the license Server
lnkstub.exe >
locator.exe > RPC Locator
lodctr.exe > Load perfmon counters
logoff.exe > Log current user off.
lpq.exe > Displays status of a remote LPD queue
lpr.exe > Send a print job to a network printer.
lsass.exe > LSA Executable and Server DLL
lserver.exe > Specifies the new DNS domain for the default server
macfile.exe > Used for managing MACFILES
magnify.exe > Used to magnify the current screen
makecab.exe > MS Cabinet Maker
mdm.exe > Machine Debug Manager
mem.exe > Display current Memory stats
migpwd.exe > Migrate passwords.
mmc.exe > Microsoft Management Console
mnmsrvc.exe > Netmeeting Remote Desktop Sharing
mobsync.exe > Manage Synchronization.

275
mountvol.exe > Creates, deletes, or lists a volume mount point.
mplay32.exe > MS Media Player
mpnotify.exe > Multiple Provider Notification application
mq1sync.exe >
mqbkup.exe > MS Message Queue Backup and Restore Utility
mqexchng.exe > MSMQ Exchange Connector Setup
mqmig.exe > MSMQ Migration Utility
mqsvc.exe > ?
mrinfo.exe > Multicast routing using SNMP
mscdexnt.exe > Installs MSCD (MS CD Extensions)
msdtc.exe > Dynamic Transaction Controller Console
msg.exe > Send a message to a user local or remote.
mshta.exe > HTML Application HOST HTML
msiexec.exe > Starts Windows Installer Program
mspaint.exe > Microsoft Paint
msswchx.exe >
mstask.exe > Task Schedule Program
mstinit.exe > Task scheduler setup
narrator.exe > Program will allow you to have a narrator for reading.
nbtstat.exe > Displays protocol stats and current TCP/IP connections using NBT
nddeapir.exe > NDDE API Server side NDDE
net.exe > Net Utility
net1.exe > Net Utility updated version from MS
netdde.exe > Network DDE will install itself into the background
netsh.exe > Creates a shell for network information
netstat.exe > Displays current connections.
nlsfunc.exe > Loads country-specific information
notepad.exe > Opens Windows 2000 Notepad
nslookup.exe > Displays information for DNS
ntbackup.exe > Opens the NT Backup Utility

276
ntbooks.exe > Starts Windows Help Utility
ntdsutil.exe > Performs DB maintenance of the ADSI
ntfrs.exe > NT File Replication Service
ntfrsupg.exe >
ntkrnlpa.exe > Kernel patch
ntoskrnl.exe > Core NT Kernel
ntsd.exe >
ntvdm.exe > Simulates a 16-bit Windows environment
nw16.exe > Netware Redirector
nwscript.exe > runs netware scripts
odbcad32.exe > ODBC 32-bit Administrator
odbcconf.exe > Configure ODBC driver's and data source's from command line
os2.exe > An OS/2 Warp Server (os2 /o) OS/2
os2srv.exe > An OS/2 Warp Server OS/2
os2ss.exe > An OS/2 Warp Server OS/2
osk.exe > On Screen Keyboard
packager.exe > Windows 2000 Packager Manager
pathping.exe > Combination of Ping and Tracert
pax.exe > is a POSIX program and path names used as arguments must be specified in
POSIX format. Use "//C/Users/Default"
instead of "C:\USERS\DEFAULT."
pentnt.exe > Used to check the Pentium for the floating point division error.
perfmon.exe > Starts Windows Performance Monitor
ping.exe > Packet Internet Groper
posix.exe > Used for backward compatibility with Unix
print.exe > Cmd line used to print files
progman.exe > Program manager
proquota.exe > Profile quota program
psxss.exe > POSIX Subsystem Application
qappsrv.exe > Displays the available application terminal servers on the network

277
qprocess.exe > Display information about processes local or remote
query.exe > Query TERMSERVER user process and sessions
quser.exe > Display information about a user logged on
qwinsta.exe > Display information about Terminal Sessions.
rasadmin.exe > Start the remote access admin service
rasautou.exe > Creates a RAS connection
rasdial.exe > Dial a connection
ras.exe > Starts a RAS connection
rcp.exe > Copies a file from and to a RCP service.
rdpclip.exe > RdpClip allows you to copy and paste files between a terminal session and
client console session.
recover.exe > Recovers readable information from a bad or defective disk
redir.exe > Starts the redirector service
regedt32.exe > 32-bit register service
regini.exe > modify registry permissions from within a script
register.exe > Register a program so it can have special execution characteristics.
regsvc.exe >
regsvr32.exe > Registers and unregister's dll's. As to how and where it register's them I
dont know.
regtrace.exe > Options to tune debug options for applications failing to dump trace
statements

Trace setting
regwiz.exe > Registration Wizard
remrras.exe >
replace.exe > Replace files
reset.exe > Reset an active section
rexec.exe > Runs commands on remote hosts running the REXEC service.
risetup.exe > Starts the Remote Installation Service Wizard.

278
route.exe > display or edit the current routing tables.
routemon.exe > no longer supported
router.exe > Router software that runs either on a dedicated DOS or on an OS/2 system.
rsh.exe > Runs commands on remote hosts running the RSH service
rsm.exe > Mounts and configures remote system media
rsnotify.exe > Remote storage notification recall
rsvp.exe > Resource reservation protocol
runas.exe > RUN a program as another user 允
rundll32.exe > Launches a 32-bit dll program
runonce.exe > Causes a program to run during startup
rwinsta.exe > Reset the session subsystem hardware and software to known initial
values
savedump.exe > Does not write to e:\winnt\user.dmp
scardsvr.exe > Smart Card resource management server
schupgr.exe > It will read the schema update files (.ldf files) and upgrade the schema.
(part of ADSI)
secedit.exe > Starts Security Editor help
services.exe > Controls all the services
sethc.exe > Set High Contrast - changes colours and display mode Logoff to set it back
to normal
setreg.exe > Shows the Software Publishing State Key values
setup.exe > GUI box prompts you to goto control panel to configure system components
setver.exe > Set Version for Files
sfc.exe > System File Checker test and check system files for integrity
sfmprint.exe > Print Services for Macintosh
sfmpsexe.exe >
sfmsvc.exe >
shadow.exe > Monitor another Terminal Services session.
share.exe >
shmgrate.exe >

279
shrpubw.exe > Create and Share folders
sigverif.exe > File Signature Verification
skeys.exe > Serial Keys utility
smlogsvc.exe > Performance Logs and Alerts
smss.exe >
sndrec32.exe > starts the Windows Sound Recorder
sndvol32.exe > Display the current volume information
snmp.exe > Simple Network Management Protocol used for Network Mangement
snmptrap.exe > Utility used with SNMP
sol.exe > Windows Solitaire Game
sort.exe > Compares files and Folders
SPOOLSV.EXE > Part of the spooler service for printing
sprestrt.exe >
srvmgr.exe > Starts the Windows Server Manager
stimon.exe > WDM StillImage- > Monitor
stisvc.exe > WDM StillImage- > Service
subst.exe > Associates a path with a drive letter
svchost.exe > Svchost.exe is a generic host process name for services that are run from
dynamic-link libraries (DLLs).
syncapp.exe > Creates Windows Briefcase.
sysedit.exe > Opens Editor for 4 system files
syskey.exe > Encrypt and secure system database
sysocmgr.exe > Windows 2000 Setup
systray.exe > Starts the systray in the lower right corner.
taskman.exe > Task Manager
taskmgr.exe > Starts the Windows 2000 Task Manager
tcmsetup.exe > telephony client wizard
tcpsvcs.exe > TCP Services
.exe > Telnet Utility used to connect to Telnet Server
termsrv.exe > Terminal Server

280
tftp.exe > Trivial FTP
tftpd.exe > Trivial FTP Daemon
themes.exe > Change Windows Themes
tlntadmn.exe > Telnet Server Administrator
tlntsess.exe > Display the current Telnet Sessions
tlntsvr.exe > Start the Telnet Server
tracert.exe > Trace a route to display paths
tsadmin.exe > Terminal Server Administrator
tscon.exe > Attaches a user session to a terminal session.
tsdiscon.exe > Disconnect a user from a terminal session
tskill.exe > Kill a Terminal server process
tsprof.exe > Used with Terminal Server to query results.
tsshutdn.exe > Shutdown the system
unlodctr.exe > Part of performance monitoring
upg351db.exe > Upgrade a jet database
ups.exe > UPS service
user.exe > Core Windows Service
userinit.exe > Part of the winlogon process
usrmgr.exe > Start the windows user manager for domains
utilman.exe > This tool enables an administrator to designate which computers
automatically open accessibility tools
when Windows 2000 starts.
verifier.exe > Driver Verifier Manager Driver Verifier Manager
vwipxspx.exe > Loads IPX/SPX VDM
w32tm.exe > Windows Time Server
wextract.exe > Used to extract windows files
winchat.exe > Opens Windows Chat
winhlp32.exe > Starts the Windows Help System
winlogon.exe > Used as part of the logon process.
winmine.exe > windows Game

281
winmsd.exe > Windows Diagnostic utility
wins.exe > Wins Service
winspool.exe > Print Routing
winver.exe > Displays the current version of Windows
wizmgr.exe > Starts Windows Administration Wizards
wjview.exe > Command line loader for Java
wowdeb.exe > . For starters, the 32-bit APIs require that the WOWDEB.EXE task runs
in the target debugee's VM
wowexec.exe > For running Windows over Windows Applications
wpnpinst.exe > ?
write.exe > Starts MS Write Program
wscript.exe > Windows Scripting Utility
wupdmgr.exe > Starts the Windows update Wizard (Internet)
xcopy.exe > Used to copy directories

FAQ Q & A:
1.
Any doubt about the contents of this chapter, please write the questions behind FAQ,
according to the sequence of 1,2,3, ..., and send the problem back to us, we will
respond as soon as possible, thank you! (Nanjing NARI Autocontrol Co., Ltd. /
Engineering Center / Technical Support)

282

You might also like