M2000 Command Reference(V200_02)
description
Transcript of M2000 Command Reference(V200_02)
M2000
V200
Command Reference
Issue 02
Date 2009-10-31
Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Huawei Technologies Co., Ltd. provides customers with comprehensive technical support and service. For anyassistance, please contact our local office or company headquarters.
Huawei Technologies Co., Ltd.Address: Huawei Industrial Base
Bantian, LonggangShenzhen 518129People's Republic of China
Website: http://www.huawei.com
Email: [email protected]
Copyright © Huawei Technologies Co., Ltd. 2009. All rights reserved.No part of this document may be reproduced or transmitted in any form or by any means without prior writtenconsent of Huawei Technologies Co., Ltd. Trademarks and Permissions
and other Huawei trademarks are the property of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respective holders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei and thecustomer. All or part of the products, services and features described in this document may not be within thepurchase scope or the usage scope. Unless otherwise specified in the contract, all statements, information,and recommendations in this document are provided "AS IS" without warranties, guarantees or representationsof any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute the warranty of any kind, express or implied.
Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Contents
About This Document.....................................................................................................................1
1 M2000 Commands......................................................................................................................1-11.1 kill_svc............................................................................................................................................................1-31.2 start_svc...........................................................................................................................................................1-31.3 stop_svc...........................................................................................................................................................1-41.4 svc_adm -cmd reload......................................................................................................................................1-41.5 svc_adm -cmd status.......................................................................................................................................1-51.6 svc_adm -cmd status -sysagent all..................................................................................................................1-51.7 svc_profile.sh Script........................................................................................................................................1-61.8 svc_ps..............................................................................................................................................................1-61.9 svc_stacks........................................................................................................................................................1-7
2 Operating System Commands.................................................................................................2-12.1 Files and Directories........................................................................................................................................2-3
2.1.1 cd............................................................................................................................................................2-42.1.2 chgrp.......................................................................................................................................................2-42.1.3 chmod.....................................................................................................................................................2-52.1.4 chown.....................................................................................................................................................2-72.1.5 cp............................................................................................................................................................2-82.1.6 ls.............................................................................................................................................................2-82.1.7 mkdir....................................................................................................................................................2-102.1.8 mv.........................................................................................................................................................2-102.1.9 pwd.......................................................................................................................................................2-112.1.10 rm.......................................................................................................................................................2-112.1.11 rmdir...................................................................................................................................................2-12
2.2 Backup and Compression..............................................................................................................................2-132.2.1 compress...............................................................................................................................................2-132.2.2 gtar........................................................................................................................................................2-142.2.3 gzip.......................................................................................................................................................2-152.2.4 pack......................................................................................................................................................2-162.2.5 tar..........................................................................................................................................................2-162.2.6 uncompress...........................................................................................................................................2-182.2.7 unpack..................................................................................................................................................2-18
Command Reference Contents
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
i
2.3 File View and Modification..........................................................................................................................2-192.3.1 cat.........................................................................................................................................................2-202.3.2 clear......................................................................................................................................................2-202.3.3 diff........................................................................................................................................................2-212.3.4 echo......................................................................................................................................................2-222.3.5 grep.......................................................................................................................................................2-232.3.6 head......................................................................................................................................................2-232.3.7 less........................................................................................................................................................2-242.3.8 more......................................................................................................................................................2-242.3.9 tail.........................................................................................................................................................2-252.3.10 vi.........................................................................................................................................................2-26
2.4 Account Management...................................................................................................................................2-282.4.1 groupadd...............................................................................................................................................2-292.4.2 groupdel................................................................................................................................................2-292.4.3 groupmod.............................................................................................................................................2-292.4.4 passwd..................................................................................................................................................2-302.4.5 useradd.................................................................................................................................................2-302.4.6 userdel..................................................................................................................................................2-312.4.7 usermod................................................................................................................................................2-32
2.5 Find and Help................................................................................................................................................2-332.5.1 find.......................................................................................................................................................2-342.5.2 man.......................................................................................................................................................2-362.5.3 whereis.................................................................................................................................................2-372.5.4 which....................................................................................................................................................2-37
2.6 System Information.......................................................................................................................................2-382.6.1 date.......................................................................................................................................................2-392.6.2 df...........................................................................................................................................................2-402.6.3 du..........................................................................................................................................................2-412.6.4 hostname...............................................................................................................................................2-422.6.5 prtconf..................................................................................................................................................2-432.6.6 uname...................................................................................................................................................2-452.6.7 who.......................................................................................................................................................2-46
2.7 Process-Related.............................................................................................................................................2-472.7.1 kill.........................................................................................................................................................2-472.7.2 prstat.....................................................................................................................................................2-492.7.3 ps..........................................................................................................................................................2-492.7.4 top.........................................................................................................................................................2-50
2.8 Network Communications.............................................................................................................................2-512.8.1 finger....................................................................................................................................................2-512.8.2 ftp.........................................................................................................................................................2-522.8.3 ifconfig.................................................................................................................................................2-542.8.4 netstat...................................................................................................................................................2-56
Contents Command Reference
ii Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.8.5 ping.......................................................................................................................................................2-582.8.6 route......................................................................................................................................................2-592.8.7 telnet.....................................................................................................................................................2-62
2.9 Other Common Commands...........................................................................................................................2-632.9.1 bc..........................................................................................................................................................2-632.9.2 script.....................................................................................................................................................2-642.9.3 pkgadd..................................................................................................................................................2-652.9.4 pkgrm...................................................................................................................................................2-65
3 Summary of Commonly Used Cluster Commands.............................................................3-1
4 Common Commands and Parameters of the Veritas Cluster............................................4-1
5 Common VVR Commands and Parameters..........................................................................5-1
Command Reference Contents
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
iii
Tables
Table 2-1 Common options in symbol mode of the chmod command ...............................................................2-6Table 2-2 Option description of the ls command.................................................................................................2-9Table 2-3 Descriptions of gtar command options..............................................................................................2-14Table 2-4 Option description for the tar command...........................................................................................2-17Table 2-5 Option description about the diff command options..........................................................................2-21Table 2-6 Option description of the echo command..........................................................................................2-22Table 2-7 Option description of the more command..........................................................................................2-25Table 2-8 Operations in the text input mode......................................................................................................2-27Table 2-9 Operations related to moving the cursor in the text input mode........................................................2-27Table 2-10 Operation for exiting the text input mode and switching to the command mode............................2-27Table 2-11 Operations related to deleting characters in the command mode.....................................................2-27Table 2-12 Commands for exiting the vi editor.................................................................................................2-28Table 2-13 Option description of the useradd command...................................................................................2-31Table 2-14 Option description of the usermod command..................................................................................2-32Table 2-15 Conditions for file search.................................................................................................................2-34Table 2-16 Logical operators of conditions........................................................................................................2-35Table 2-17 Format of the command output........................................................................................................2-39Table 2-18 Description of the uname options....................................................................................................2-46Table 2-19 Examples of the finger command....................................................................................................2-52Table 2-20 Common ftp commands...................................................................................................................2-53Table 2-21 Description of routing flags.............................................................................................................2-57Table 2-22 Description of the route commands.................................................................................................2-59Table 2-23 Description of routing flags.............................................................................................................2-61Table 3-1 Common maintenance commands of the Cluster3.0............................................................................3-1Table 4-1 Common maintenance commands of the VCS....................................................................................4-1Table 5-1 Common VVR commands and parameters..........................................................................................5-1
Command Reference Tables
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
v
About This Document
PurposeThis document provides the M2000 system routine maintenance common commands.
Related VersionsThe following table lists the product versions related to this document.
Product Name Version
M2000 V200
Intended AudienceThe intended audiences of this document are network administrators.
Update History
02(2009-10-31)Second commercial release.
Compared with V200 01 issued on June 30 of 2009, this version has the following modifications:
The content descriptions are optimized in 3 Summary of Commonly Used ClusterCommands.
01(2009-06-30)Initial release. Also, the first formal release.
Command Reference About This Document
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
1
Organization1 M2000 Commands
This describes the functions of common commands related to the M2000 service, along withapplication examples. The path M2000 Server Installation Path/bin stores all the commandsused for the M2000 system maintenance. Before running commands, ensure that the databaseworks properly and that you already run the M2000 environment setting script svc_profile.sh.M2000 commands can run both the Solaris operating system and Linux operating system.
2 Operating System Commands
This provides the reference to the common commands on the Solaris and Linux operatingsystems. The commands consist of files and directories commands, backup and compressioncommands, file view and modification, account management commands, find and helpcommands, system information commands, process-related commands, networkcommunication commands, and other common commands.
3 Summary of Commonly Used Cluster Commands
This describes the common maintenance commands of the Cluster 3.0.
4 Common Commands and Parameters of the Veritas Cluster
This describes the common commands and parameters of the Veritas Cluster.
5 Common VVR Commands and Parameters
The following table describes the common VVR commands and parameters.
ConventionsSymbol Conventions
The symbols that may be found in this document are defined as follows.
Symbol Description
Indicates a hazard with a high level of risk, which if notavoided,will result in death or serious injury.
Indicates a hazard with a medium or low level of risk, whichif not avoided, could result in minor or moderate injury.
Indicates a potentially hazardous situation, which if notavoided,could result in equipment damage, data loss,performance degradation, or unexpected results.
Indicates a tip that may help you solve a problem or savetime.
Provides additional information to emphasize or supplementimportant points of the main text.
General Conventions
Organization Command Reference
2 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
The general conventions that may be found in this document are defined as follows.
Convention Description
Times New Roman Normal paragraphs are in Times New Roman.
Boldface Names of files, directories, folders, and users are inboldface. For example, log in as user root.
Italic Book titles are in italics.
Courier New Examples of information displayed on the screen are inCourier New.
Command Conventions
The command conventions that may be found in this document are defined as follows.
Convention Description
Boldface The keywords of a command line are in boldface.
Italic Command arguments are in italics.
[ ] Items (keywords or arguments) in brackets [ ] are optional.
{ x | y | ... } Optional items are grouped in braces and separated byvertical bars. One item is selected.
[ x | y | ... ] Optional items are grouped in brackets and separated byvertical bars. One item is selected or no item is selected.
{ x | y | ... }* Optional items are grouped in braces and separated byvertical bars. A minimum of one item or a maximum of allitems can be selected.
[ x | y | ... ]* Optional items are grouped in brackets and separated byvertical bars. Several items or no item can be selected.
GUI Conventions
The GUI conventions that may be found in this document are defined as follows.
Convention Description
Boldface Buttons, menus, parameters, tabs, window, and dialog titlesare in boldface. For example, click OK.
> Multi-level menus are in boldface and separated by the ">"signs. For example, choose File > Create > Folder.
Keyboard Operations
Command Reference Organization
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
3
The keyboard operations that may be found in this document are defined as follows.
Format Description
Key Press the key. For example, press Enter and press Tab.
Key 1+Key 2 Press the keys concurrently. For example, pressing Ctrl+Alt+A means the three keys should be pressed concurrently.
Key 1, Key 2 Press the keys in turn. For example, pressing Alt, A meansthe two keys should be pressed in turn.
Mouse Operations
The mouse operations that may be found in this document are defined as follows.
Action Description
Click Select and release the primary mouse button without movingthe pointer.
Double-click Press the primary mouse button twice continuously andquickly without moving the pointer.
Drag Press and hold the primary mouse button and move thepointer to a certain position.
Organization Command Reference
4 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
1 M2000 Commands
About This Chapter
This describes the functions of common commands related to the M2000 service, along withapplication examples. The path M2000 Server Installation Path/bin stores all the commandsused for the M2000 system maintenance. Before running commands, ensure that the databaseworks properly and that you already run the M2000 environment setting script svc_profile.sh.M2000 commands can run both the Solaris operating system and Linux operating system.
1.1 kill_svcThis describes the function of the kill_svc command and the users authorized to run thiscommand. This also gives examples for the application of this command. Use the kill_svccommand only in the case of a deadlock and an abnormal process.
1.2 start_svcThis describes the function of the start_svc command and the users authorized to run thiscommand. This also gives examples for the application of this command.
1.3 stop_svcThis describes the function of the stop_svc command and the users authorized to run thiscommand. This also gives examples for the application of this command.
1.4 svc_adm -cmd reloadThis describes the function and user identity of the svc_adm -cmd reload command. Thecommand is used to update the M2000 configuration information. This also gives an exampleto explain the application of the command.
1.5 svc_adm -cmd statusThis describes the function of the svc_adm -cmd status command and the users authorized torun this command. It also provides an example to explain the application.
1.6 svc_adm -cmd status -sysagent allThis describes the function of the svc_adm -cmd status -sysagent all command used for viewingthe status of the M2000 services and the users authorized to run this command. This also providessome application examples for the command. This command is applicable to only the Solarisoperating system.
1.7 svc_profile.sh Script
Command Reference 1 M2000 Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
1-1
This describes the function, path, and method of running the svc_profile.sh script. Before yourun the commands on the M2000, you must run svc_profile.sh to set the operating environment.
1.8 svc_psThis describes the function of the svc_ps command and the users authorized to run this command.This also gives examples for the application of this command.
1.9 svc_stacksThis describes the function of the svc_stacks command and the users authorized to run thiscommand. It also provides an example to explain the application of this command.
1 M2000 Commands Command Reference
1-2 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
1.1 kill_svcThis describes the function of the kill_svc command and the users authorized to run thiscommand. This also gives examples for the application of this command. Use the kill_svccommand only in the case of a deadlock and an abnormal process.
FunctionThe kill_svc command stops services and processes of the M2000 system through the processkilling mechanism supported by the primary layer operating system. Running this commandmay lead to service data loss or abnormal services. Therefore, use this command only when allother measures to restore the services of the system fail.
Generally, the stop_svc command is used to stop the M2000 services. Therefore, run kill_svconly in the case of a deadlock and an abnormal process.
Permitted UsersUser root is authorized to run the kill_svc command.
Example# kill_svc
1.2 start_svcThis describes the function of the start_svc command and the users authorized to run thiscommand. This also gives examples for the application of this command.
FunctionThe start_svc command starts all M2000 services. After the system starts, this command attemptsto start each service again and displays a message to indicate that the service is started.
NOTE
If the installed match version is of V200R0051.a.0.0.XX or of earlier, run the start_svc command. Thefollowing message is displayed.iManagerM2000_SGSN_MATCH_ENG_V200R005C01B002 has not been executed commands{DcNeIns and DcInit}, please run them if necessary!OMCSTMATCH-GGSN_1.a.0.0.30 has not been executed commands{DcNeIns and DcInit}, please execute them if necessary!Ensure that the M2000 system services are stopped. Initiate the mediation layer.
# cd /opt/OMC/med/RNCNE/iManagerM2000_RNC_MATCH_ENG_V200R008C03SPC001
# DcNeIns -i .
# DcInit
Run the command start_svc to start the M2000 system service.
Permitted UsersUser root is authorized to run the start_svc command.
Command Reference 1 M2000 Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
1-3
Example
# start_svc
==================== Starting Services ...TAO Naming Service is running TAO Notification Service is running Monitor_Service already running. imapsysd already running. LogServer [starting... ] svc_adm:info:service with this name is already running ... ============================ Finished Starting Services.
1.3 stop_svcThis describes the function of the stop_svc command and the users authorized to run thiscommand. This also gives examples for the application of this command.
Function
The stop_svc command stops all M2000 services. If the system is not started, this commandattempts to stop each service and then displays error messages.
Permitted Users
User root is authorized to run the stop_svc command.
Example
# stop_svc
============= Stopping System ...SystemMonitor [stopped ]EventManager [stopped ]LogServer [stopped ]...==================== Finished Stopping System.
1.4 svc_adm -cmd reloadThis describes the function and user identity of the svc_adm -cmd reload command. Thecommand is used to update the M2000 configuration information. This also gives an exampleto explain the application of the command.
Function
This command loads the configuration file to the configuration module to update theconfiguration in real time. This means that the M2000 services are not stopped when the systemupdates the configuration information.
Permitted Users
Users root and omcuser are authorized to run the svc_adm -cmd reload command.
1 M2000 Commands Command Reference
1-4 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Example-bash-3.00$ svc_adm -cmd reload
After you run the command, the data in the configuration module is the same as the data in theconfiguration files.
1.5 svc_adm -cmd statusThis describes the function of the svc_adm -cmd status command and the users authorized torun this command. It also provides an example to explain the application.
FunctionThe svc_adm -cmd status command is used to check the operational status of all the M2000services.
Permitted UsersUsers root and omcuser are authorized to run the svc_adm -cmd status command.
Example-bash-3.00$ svc_adm -cmd status
The status of the M2000 services is Running, or Not Running.
1.6 svc_adm -cmd status -sysagent allThis describes the function of the svc_adm -cmd status -sysagent all command used for viewingthe status of the M2000 services and the users authorized to run this command. This also providessome application examples for the command. This command is applicable to only the Solarisoperating system.
FunctionThis command is used for viewing the current running status of the M2000 services in theM2000 single-server system, HA system, or SLS system.
Authorized UsersUsers root, omcuser, and dbuser are authorized to run this command.
Application Examplel In the M2000 single-server system
Log in to the server and run the following command:# svc_adm -cmd status -sysagent all
The system output displays the running status of the services. The status can beRunning, or Not Running.
Command Reference 1 M2000 Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
1-5
l In the M2000 HA systemLog in to the active node and run the following command:# svc_adm -cmd status -sysagent all
The system output displays the running status of the services on the active and standbynodes. The status can be Running, or Not Running.
l In the M2000 SLS systemLog in to the master node and any of the slave node and run the following command:# svc_adm -cmd status -sysagent all
The system output displays the running status of the services on each node. The status canbe Running, or Not Running.
1.7 svc_profile.sh ScriptThis describes the function, path, and method of running the svc_profile.sh script. Before yourun the commands on the M2000, you must run svc_profile.sh to set the operating environment.
Function
Before you run the commands on the M2000, run svc_profile.sh. This script sets the useroperating environment such as the searching path and the dynamic searching path.
Path
The script is saved in the M2000 Server Installation Directory.
Operating Method
There are two ways to run the script: manually and automatically.
l Run the script manually
Take the M2000 default directory /opt/OMC as an example. To manually run the script, run thefollowing command:
-bash-3.00$ . /opt/OMC/svc_profile.sh
NOTE
The symbol . exists before the command, and a space exists between the mark . and the mark /.
l Run the script automatically
After the system is installed correctly, the script is added to the .profile file of user omcuser anduser root. If you log in to the system as user omcuser or user root, the system automatically runsthe script.
1.8 svc_psThis describes the function of the svc_ps command and the users authorized to run this command.This also gives examples for the application of this command.
1 M2000 Commands Command Reference
1-6 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
FunctionThe svc_ps command is used to check the operational status of the M2000 service processes.
Permitted UsersUsers root, omcuser are authorized to run the svc_ps command.
Example-bash-3.00$ svc_ps
The command result shows all the M2000 processes that are running.
1.9 svc_stacksThis describes the function of the svc_stacks command and the users authorized to run thiscommand. It also provides an example to explain the application of this command.
FunctionThe svc_stacks command collects the stack information on the M2000 service processes forlocating and debugging system faults.
Permitted UsersUser root is authorized to run this command.
Example# svc_stacks
The queried stack information is stored in the file /M2000 server installation path/var/logs/imap_stacks.YY_MM_DD__HH_NN_SS.trace. The default installation path of the M2000server software is /opt/OMC.
The result file is identified on the basis of the query time. In the file name, YY stands for year,MM for month, DD for day, HH for hour, NN for minute, and SS for second.
Command Reference 1 M2000 Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
1-7
2 Operating System Commands
About This Chapter
This provides the reference to the common commands on the Solaris and Linux operatingsystems. The commands consist of files and directories commands, backup and compressioncommands, file view and modification, account management commands, find and helpcommands, system information commands, process-related commands, networkcommunication commands, and other common commands.
2.1 Files and DirectoriesThis describes the reference of the Files and Directories common commands. This also givesfunction descriptions and examples.
2.2 Backup and CompressionThis describes the functions of the commands used for backup and compression and providessome application examples.
2.3 File View and ModificationThis describes the functions of the file view and modification and provides some applicationexamples.
2.4 Account ManagementThis describes the functions of the account management commands and provides someapplication examples. Only user root and authorized users can add, modify, or delete users anduser groups.
2.5 Find and HelpThis describes the functions of the find and help commands and provides some applicationexamples.
2.6 System InformationThis describes the system information commands and provides some application examples.
2.7 Process-RelatedThis describes the process-related commands and provides some application examples.
2.8 Network CommunicationsThis describes the commands used for network communications and provides some applicationexamples.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-1
2.9 Other Common CommandsThis describes the functions of other common commands and provides some applicationexamples.
2 Operating System Commands Command Reference
2-2 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.1 Files and DirectoriesThis describes the reference of the Files and Directories common commands. This also givesfunction descriptions and examples.
2.1.1 cdThis describes the function and example of the cd command. The usage of the command is thesame on the Solaris operating system and the Linux operating system.
2.1.2 chgrpThis describes the function, format, option, parameter, and example of chgrp command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
2.1.3 chmodThis describes the function, format, option, and example of the chmod command. The usage ofthe command is the same on the Solaris operating system and the Linux operating system.
2.1.4 chownThis describes the function, format, option, parameter, and example of the chown command.The usage of the command is the same on the Solaris operating system and the Linux operatingsystem.
2.1.5 cpThis describes the function, format, option, and parameter of the cp command. It also providesan example of the cp command. The usage of the command is the same on the Solaris operatingsystem and the Linux operating system.
2.1.6 lsThis describes the function, format, option, parameter, and example of the ls command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
2.1.7 mkdirThis describes the function and example of the mkdir command. The usage of the command isthe same on the Solaris operating system and the Linux operating system.
2.1.8 mvThis describes the function, format, and example of the mv command. The usage of the commandis the same on the Solaris operating system and the Linux operating system.
2.1.9 pwdThis describes the function and example of the pwd command. The pwd command is used toview the current working folder. The usage of the command is the same on the Solaris operatingsystem and the Linux operating system.
2.1.10 rmThis describes the function, format, option, and example of the rm command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.1.11 rmdirThis describes the function and example of the rmdir command. The usage of the command isthe same on the Solaris operating system and the Linux operating system.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-3
2.1.1 cdThis describes the function and example of the cd command. The usage of the command is thesame on the Solaris operating system and the Linux operating system.
FunctionThe cd command is used to switch the current folder to another folder. This command appliesto both absolute and relative paths.
Examplel To switch to the home folder, run the following command:
# cd
l To switch to the system root directory, run the following command:
# cd /
l To switch back one folder, run the following command:
# cd ..
l To switch back two folders, run the following command:
# cd ../..
l To switch to the /export/home folder by the absolute path, run the following command:
# cd /export/home
NOTE
If you run the cd command that is not followed by any parameter, the system is switched back to the homefolder.
2.1.2 chgrpThis describes the function, format, option, parameter, and example of chgrp command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
FunctionThe chgrp command is used to move all files from the user group to which you belong, to anotheruser group. That is, you belong to at least two user groups at the same time.
Command Formatchgrp Option group file
Option Descriptionl -f: runs the command forcibly without displaying errors
l -R: recursive folder
2 Operating System Commands Command Reference
2-4 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Parameter Descriptionl Group: the modified user group
l File: the file the user group of which is to be modified
Example
To change the user group file to new_group, run the following command:
# chgrp new_group file
CAUTIONThe new user group to which a file is moved should be created. Run the groups command tolist the groups to which you belong.
After the owner or group of a folder is changed, the folder does not belong to that user or usergroup any more. The attributes of the subfolders and files in the folder, however, are retained.
Run the chown command to modify the owner and the user group of a file at the same time:
# chown omc:staff file1
For example, run the command to modify the owner of file1 to omc and the group to staff.
2.1.3 chmodThis describes the function, format, option, and example of the chmod command. The usage ofthe command is the same on the Solaris operating system and the Linux operating system.
Function
The chmod command is used to change the access rights of a directory or a file.
Format
chmod option directory or file
Based on different notation methods of the option in the command, two modes are available:
l Symbol mode
chmod objectoperatorrights file
l Digit mode
chmod lmn file
Option Descriptionl Symbol mode
Table 2-1 lists common options in symbol mode of the chmod command.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-5
Table 2-1 Common options in symbol mode of the chmod command
Option Option Detail Description
Object u Owner of a file
g Users sharing the same groupwith the file owner
o Other users except the file ownerand the users sharing the samegroup with the file owner
a All users
Operator + Add a right
- Cancel a right
= Set a right
l Digit mode
The option lmn represents the following digits:
– l: the rights of the owner
– m: the rights of the users sharing the same group with the owner
– n: the rights of other users in the system
The value of each digit is equal to the sum of the values of r (read right), w (write right),x (execute right), or - (no right) in each group. In each group, r = 4, w = 2, x = 1, and - =0. In the following example -rwxr-xr-- 1 rms sbsrms 46098432 May 1216:02 sdh*, the access rights of the file sdh is represented by the symbols rwxr-xr--. The nine symbols are divided into three groups, with three symbols as a group. Thethree groups represent the rights of the file owner, the rights of the users sharing the samegroup with the file owner, and the rights of other users in the system. The three groups canbe represented in digits 754, which is calculated according to the formulas: 7 = 4 + 2 + 1,5 = 4 + 0 + 1, and 4 = 4 + 0 + 0.
Parameter Description
File: indicates the name of the file whose rights are changed.
Examplel Symbol mode
Authorize the file1 owner with the read, write, and execute rights. Authorize the userssharing the same group with the file owner with the read and execute rights. Authorizeother users with the read and execute rights. Run the following command:
# chmod u=rwx,go=rx file1
To authorize all the users with the read and write rights, run the following command:
# chmod a=rw file2
l Digit mode
2 Operating System Commands Command Reference
2-6 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Authorize the file1 owner with the read, write, and execute rights. Authorize the userssharing the same group with the file owner with the read and execute rights. Authorizeother users with the read and execute rights. Run the following command:# chmod 755 file1To authorize all the users with the read and write rights, run the following command:# chmod 666 file2
NOTE
l To configure the rights of a file for users in a group and other users in the system in symbol mode,you must authorize these users with the execute right of the directory where a file exists. Run thefollowing command for the directory that requires you to set rights:# chmod u=rw,+x .
You can also run the following command:# chmodu=rwx,go=x .
In this command, the symbol "." indicates the current directory.
l In digit mode, r = 4, w = 2, x = 1, and - = 0. These mappings are set according to the binary mode.For the three symbols in a group, which represent the read right, the write right, and the execute right,assign the binary value 1 if a symbol has the corresponding right and assign the binary value 0 if asymbol does not have the corresponding rights. Take the previous file sdh as an example. The filerights are represented by the symbols rwxr-xr--. After converting the symbols into a binary value,you can obtain "111101100". The binary value is divided into three 3-digit groups, with each grouprepresenting a file right. After converting the binary value of each group into a decimal value, youcan obtain three values: 7, 5, and 4.
2.1.4 chownThis describes the function, format, option, parameter, and example of the chown command.The usage of the command is the same on the Solaris operating system and the Linux operatingsystem.
FunctionThe chown command is used to modify the owner of a file. In most Unix/Linux systems, thiscommand can be run only by the super user.
Command Formatchown Option owner file
Option Descriptionl -f: runs the command forcibly without displaying errors
l -R: recursive folder
Parameter Descriptionl Owner: the modified owner
l File: the file of the owner to be modified
Examplel Assume that there is a user new_owner and a file in the system. Run the following command
to change the owner of the file to new_owner:
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-7
# chown new_owner filel Assume that there is a user M2000 in the system. Change the owner of all files in the /
export/home folder and the subfolders to M2000:# chown -R M2000 /export/home
2.1.5 cpThis describes the function, format, option, and parameter of the cp command. It also providesan example of the cp command. The usage of the command is the same on the Solaris operatingsystem and the Linux operating system.
FunctionThe cp command is used to copy the contents of a file to another file.
Command Formatcp option source file object file
Option DescriptionThe option -r indicates recursively copying a folder. That is, when copying a folder, copy thefiles and subfolders included in the folder, and files and subfolders in the subfolders until thelast level of the folder.
ExampleTo copy the old_filename file in the current folder to the file new_filename, run the followingcommand:
# cp old_filename new_filename
2.1.6 lsThis describes the function, format, option, parameter, and example of the ls command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
FunctionThe ls command is used to list the files and subfolders in a folder. Run the ls command withoutany parameter to list the content of the current folder. Run the ls command with parameters tolist the information about the size, type, and privileges of the file, and the date when the file wascreated and modified.
Command Formatls Option Directory or File
Option DescriptionSeveral individual options and a combination of options can be used for the ls command. Placethe prefix - before the options. Table 2-2 lists some common options.
2 Operating System Commands Command Reference
2-8 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Table 2-2 Option description of the ls command
Option Description
-a Lists all files including the hidden files, that is, the files starting with adot ., for example, the .login file.
-F Specifies the type of a file by suffix signs.The meaning of the suffixes are as follows:l /: for folder files
l =: for pipe files
l @: for sign-linking files
l *: for executable files
-l Lists the detailed information about a file, such as the file type, privileges,number of links, owner, file group, file size, file name, and the date of the lastmodification.
If the file is a sign-linking file, then the -> sign is added at the end of the file name for pointingto the linked file.
Example
To view the long-form content of the files in the current folder, run the following command:
# ls -l |more
total 11094632drwxr-xr-x 2 root staff 1024 Sep 5 2001 bindrwxr-xr-x 14 root staff 512 Sep 5 2001 charsetsdrwxr-xr-x 3 root staff 512 Sep 5 2001 collatedrwxr-xr-x 2 root staff 512 Sep 5 2001 config-rw-r--r-- 1 root staff 2048000000 Mar 6 09:50 data_dev.datdrwxr-xr-x 2 root staff 512 Sep 5 2001 devlibdrwxr-xr-x 7 root staff 512 Sep 5 2001 diagdrwxr-xr-x 2 root staff 512 Sep 5 2001 hs_datadrwxr-xr-x 2 root staff 512 Sep 5 2001 includedrwxr-xr-x 7 root staff 512 Sep 5 2001 initdrwxr-xr-x 3 root staff 512 Sep 5 2001 install-rw-r--r-- 1 root staff 268 Sep 5 2001 interf.old-rw-r--r-- 1 root staff 402 Oct 29 15:25 interfacesdrwxr-xr-x 2 root staff 1024 Sep 5 2001 libdrwxr-xr-x 2 root staff 512 Sep 5 2001 licensedrwxr-xr-x 6 root staff 512 Sep 5 2001 locales-rw-r--r-- 1 root staff 2048000000 Mar 6 10:51 log_dev.dat-rw-r--r-- 1 root staff 2048000000 Mar 6 10:36 log_dev1.datdrwxr-xr-x 5 root staff 512 Sep 5 2001 pad-rw-r--r-- 1 root staff 5242880 Feb 19 10:10 phase2.datdrwxr-xr-x 8 root staff 512 Sep 5 2001 sample--More--
After you run the ls -l command, the result may be displayed in several screens. To view the filecontents, one screen at a time, run one of the following commands:
l # ls -la | more
l $ ls -la>ccc
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-9
Save the command output to the ccc file, and then run the following command to view theoutput on screen at a time:
# more ccc
After you run the ls -l command, seven columns of information are displayed, which aredescribed as follows:
l The first column consists of 10 characters. The first character indicates the file type. Forexample, the character - refers to a common file and the character d refers to a folder. Thefollowing nine characters are three triplets indicating the access privileges of the file owner.The first triplet pertains to the owner, the middle triplet pertains to members of the usergroup, and the right-most one pertains to other users in the system. For example, thecharacters r, w, and x indicate that the user has the privileges to read, write, and execute afile, whereas the character - indicates that the user does not have any relevant privilegesfor the file.
l The second column indicates the number of links of the file.
l The third and fourth columns display information such as the owner of the file, and the usergroup to which the file belongs.
l The fifth column shows the size of the file in bytes.
l The sixth column shows the time and date when the file is last modified.
l The seventh column shows the file name.
2.1.7 mkdirThis describes the function and example of the mkdir command. The usage of the command isthe same on the Solaris operating system and the Linux operating system.
Function
The mkdir command is used to create a folder. When the path to the created folder is determined,absolute and relative paths can be used.
Example
To create a subfolder data in /home1/omc, run the following command:
# mkdir /home1/omc/data
If the current folder is /home1/omc, run the following command:
# mkdir data
2.1.8 mvThis describes the function, format, and example of the mv command. The usage of the commandis the same on the Solaris operating system and the Linux operating system.
Function
The mv command is used to move and rename a file.
2 Operating System Commands Command Reference
2-10 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
CAUTIONl After you run the mv command, only the target file instead of the source file exists.
l After you run the cp command, the source file still exists and the target file is generated.
Command Formatmv source file object file
ExampleTo move the old_filename file in the root directory to the /home1/omc folder, and rename thesource file to new_filename, run the following command:
# mv old_filename /home1/omc/new_filename
2.1.9 pwdThis describes the function and example of the pwd command. The pwd command is used toview the current working folder. The usage of the command is the same on the Solaris operatingsystem and the Linux operating system.
FunctionView the current working folder.
Example# pwd
/export/home
NOTE
Unlike DOS, the Solaris/Linux system does not always display the folder name. You must run the pwdcommand periodically to view the current working folder.
2.1.10 rmThis describes the function, format, option, and example of the rm command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe rm command is used to delete a file.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-11
CAUTIONl In the Unix/Linux system, a file, once deleted, cannot be restored. Therefore, use the -i
option to avoid the deletion of a file by mistake.l To delete a folder, run either of the following commands: rmdir or rm -r. The difference
between the two commands is: rmdir deletes only empty folders but rm -r deletes anyfolder.
Command Formatrm Option file
Option Descriptionl -i: refers to interactive operations. Your confirmation is required before a command is run.
l -r: recursively deletes a folder. That is, when deleting a folder, delete the files and subfoldersincluded in the folder, and files and subfolders in the subfolders until the root folder.
ExampleTo delete the old_filename file in the current folder, run the following command:
# rm -i old_filename
2.1.11 rmdirThis describes the function and example of the rmdir command. The usage of the command isthe same on the Solaris operating system and the Linux operating system.
FunctionThe rmdir command is used to delete an empty folder.
CAUTIONl If the folder to be deleted is not empty, you must delete the files in the folder before running
the rmdir command.l To delete the current folder, you must switch to the upper-level folder.
ExampleTo delete the data subfolder in the /home1/omc folder, run the following command:
# rmdir /home1/omc/data
If the current folder is /home1/omc, run the following command:
# rmdir data
2 Operating System Commands Command Reference
2-12 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.2 Backup and CompressionThis describes the functions of the commands used for backup and compression and providessome application examples.
2.2.1 compressThis describes the function, format, and example of the compress command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.2.2 gtarThis describes the function, format, parameter options, and instance of the gtar command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
2.2.3 gzipThis describes the function, format, parameter options, and application example of the gzipcommand. You can run the gzip command to compress files. The command is only used on theLinux operating system.
2.2.4 packThis describes the function, format, and example of the pack command. The pack command isused to compress files and save memory space. The usage of the command is the same on theSolaris operating system and the Linux operating system.
2.2.5 tarThis describes the function, format, option, and example of the tar command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.2.6 uncompressThis describes the function, format, and example of uncompress command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.2.7 unpackThis describes the function, format, and example of the unpack command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.2.1 compressThis describes the function, format, and example of the compress command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe compress command is used to compress files and save the memory space. The name of thecompressed files ends with .Z. The command for decompressing such files is uncompress.
Command Formatcompress file
ExampleTo compress a file, run the following command:
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-13
# compress file
CAUTIONThe difference between the tar command and the file compressing commands is as follows:
The tar command packs or combines files and packs many folders or files into a package. Tocompress the combined files *.tar, use the compress or pack command.
2.2.2 gtarThis describes the function, format, parameter options, and instance of the gtar command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
Function
The gtar command can merge multiple files into an archive and store it in tapes or disks. Youcan obtain the required files from an archive, if required.
Format
gtar function options modification options file to be backed up or restored
Option Description
l Function option: sets the actions of the gtar command, such as read or write.
l Modification option: modifies the actions of the gtar command.
Table 2-3 lists some options.
Table 2-3 Descriptions of gtar command options
Option Example Description
Function option r Adds the specified file to end of an archive.
x Reads a file in the archive. If the name is a directory, its subdirectories are also read. This option is common.
c Creates a new archive. This option is common.
g Creates a file from the beginning of the archive instead ofthe end of the last file.
Modificationoption
v Starts the display mode. The gtar command can display allnames of the processed file. This option is common.
w Activates the confirm mode. The gtar command requestsyou to confirm before processing each file.
2 Operating System Commands Command Reference
2-14 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Option Example Description
f Indicates that the archive is a file. Omission of this optionindicates that the object is the preset disk or tape. This optionis common.
Instancel Run the gtar command to back up files.
In the current directory, back up all the files and folders in /export/home/sybdev to thedefault device. During the backup, the file information is displayed.# gtar cv /export/home/sybdev
In the current directory, back up all the files and folders in /export/home/sybdev and savethem as databak.tar. During the backup, the file information is displayed.# gtar cvf databak.tar /export/home/sybdev
l Run the gtar command to restore files.Restore the files of default devices in the backup files to a hard disk. During the restoration,the file information is displayed.# gtar xv
In the current directory, decompress the backup file databak.tar to /export/home/sybdev. During the restoration, the file information is displayed.# gtar xvf databak.tar
CAUTIONl There is no - symbol before the function option and modification option of gtar.
l The gtar command can pack multiple files. The command is as follows:# gtar cvf filebak.tar file1 file2 file3
l This command packs the three files, that is, file1, file2, and file3, into the file namedfilebak.tar.
l Under different UNIX systems, when using gtar to back up or restore files, note that namesof the floppy disk and tape are different. Ensure that you use the right names.
2.2.3 gzipThis describes the function, format, parameter options, and application example of the gzipcommand. You can run the gzip command to compress files. The command is only used on theLinux operating system.
Function
The gzip command can compress files. To extract files, use the gunzip command. Thecompressed files are in .gz format.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-15
Formatgzip file name
Application ExampleThe command for compressing filename file is as follows:
# gzip filename
2.2.4 packThis describes the function, format, and example of the pack command. The pack command isused to compress files and save memory space. The usage of the command is the same on theSolaris operating system and the Linux operating system.
FunctionRun the pack command to compress files. The name of the compressed files ends with .Z. Thespace achieved through compression depends on file types. To extract files, use the unpackcommand.
Command Formatpack file
ExampleTo pack a file, run the following command:
# pack file
CAUTIONl Do not run the pack command to compress files of small sizes. To compress such files, use
the pack command with the option -f for forced compression.# pack -f filename
l The difference between the tar command and the file compression commands is as follows:The tar command packs or combines files and packs many folders or files into a package.To compress the combined files *.tar, use the compress or pack command.
2.2.5 tarThis describes the function, format, option, and example of the tar command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe tar command is used to combine several files into one archive and save it to a tape or disk.When one of the files is required, obtain the file directly from an archive.
2 Operating System Commands Command Reference
2-16 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Format
tar function options modification options file
Option Description
l function options: sets the actions, such as read and write, of the tar command
l modification options: modifies the actions of the tar command
Table 2-4 describes the options of the tar command.
Table 2-4 Option description for the tar command
Option SpecifiedOption
Description
Function options r Adds the specified file to an archive.
x Reads a file in an archive. If the file name is afolder, this option reads the subfolders includedin the folder. This option is often used.
c Creates an archive. This option is often used.
g Creates a file at the beginning of an archive ratherthan add the file in the last file.
Modificationoptions
v Activates the display mode. The names of all theprocessed files are displayed. This option is oftenused.
w Activates the confirmation mode. Yourconfirmation is required before each file isprocessed.
f Indicates that an archive is a file. If this parameteris skipped, the preset tape or disk is used as theobject. This option is often used.
Examplel Run the tar command to back up files.
To back up all the files and subfolders in the /export/home folder in the current folder tothe default device and view the file information during the backup, run the followingcommand:
# tar cv /export/home
In current folder, back up all the files and subfolders in the /export/home folder to thedatabak.tar file, and to view the file information during the backup, run the followingcommand:
# tar cvf databak.tar /export/home
l Use tar to restore files.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-17
To restore the files in the default device to a hard disk, and to view the file informationduring the restoration, run the following command:
# tar xv
In current folder, restore the databak.tar file to the /export/home folder, and to view thefile information during the restoration, run the following command:
# tar xvf databak.tar
CAUTIONl Do not enter "-" on the left of the function and modification options in the tar command.
l Run the following tar command to pack several files into a package:
# tar cvf filebak.tar file1 file2 file3
l Run the previous command to pack file1, file2, and file3 into a package namedfilebak.tar.
l The names of the disk and tape devices used in file backup and restoration in the tarcommand may vary according to the operating system. Check carefully before running thecommand.
2.2.6 uncompressThis describes the function, format, and example of uncompress command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The uncompress command is used to decompress the compressed files. The command forcompressing files is compress.
Command Format
uncompress compressed file ending with ".Z"
Example
To decompress the file.Z file, run the following command:
# uncompress file.Z
2.2.7 unpackThis describes the function, format, and example of the unpack command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The unpack command is used to extract the packed files. To pack files, use the pack command.
2 Operating System Commands Command Reference
2-18 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Format
unpack compressed file ending with ".Z"
Example
To extract the file.Z file, run the following command:
# unpack file.Z
2.3 File View and ModificationThis describes the functions of the file view and modification and provides some applicationexamples.
2.3.1 catThis describes the function, format, option, and example of the cat command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.3.2 clearThis describes the function and example of the clear command. The command is only used onthe Solaris operating system.
2.3.3 diffThis describes the function, format, parameter options, and application example of the diffcommand. You can run the diff command to compare files. The command is only used on theLinux operating system.
2.3.4 echoThis describes the function, format, option, and example of the echo command. The commandis only used on the Solaris operating system.
2.3.5 grepThis describes the function, format, and example of the grep command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.3.6 headThis describes the function, format, and example of the head command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.3.7 lessThis describes the function, format, parameter options, and application example of the lesscommand. You can run the less command to view files. The command is only used on the Linuxoperating system.
2.3.8 moreThis describes the function, format, option, and example of the more command. The morecommand is used to view a file one screen at a time. The usage of the command is the same onthe Solaris operating system and the Linux operating system.
2.3.9 tailThis describes the function, format, and example of the tail command. The usage of the commandis the same on the Solaris operating system and the Linux operating system.
2.3.10 vi
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-19
This describes the function and format of the vi command. The vi command can be used to createand modify text files. The usage of the command is the same on the Solaris operating systemand the Linux operating system.
2.3.1 catThis describes the function, format, option, and example of the cat command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The cat command is used to view the contents of a text file.
Command Format
cat option file
Option Descriptionl -n: number of each line of the displayed text
l -v: to view nonprinting characters rather than TAB and RETURN
Example
To view the contents of the cat_Table.txt file, run the following command:
# cat cat_Table.txt
Name Owner Object_type ------------------------------ ------------------------------ ---------------------- tbl128Addr cat user table tbl128IP cat user table tbl128Name cat user table tblAdapterIP cat user table tblAdjCell cat user table... ... ...
NOTE
To view several files at the same time, run the following command:
# cat file1 file2 file3
2.3.2 clearThis describes the function and example of the clear command. The command is only used onthe Solaris operating system.
Function
The clear command is used to clear the contents on the screen.
2 Operating System Commands Command Reference
2-20 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
ExampleTo clear the screen, run the following command:
# clear
2.3.3 diffThis describes the function, format, parameter options, and application example of the diffcommand. You can run the diff command to compare files. The command is only used on theLinux operating system.
FunctionYou can run the diff command to compare files and display differences between the files. It canbe used to compare single files or directories.
NOTE
The diff command is applicable to text files.
Formatdiff option file1 file2
Option DescriptionFor details about options of the diff command, see Table 2-5.
Table 2-5 Option description about the diff command options
Option Description
-b Compare any number of space characters that are regarded as new line tagsat the end of each line with other space character strings except new line tags.The space characters in front of new line characters are ignored.
-w Ignore the spaces and TAB characters and consider all the strings of blanksas the same. For example, "if ( a == b )" is considered the same as "if(a==b)".
-s Inform you of identical files. The different files are not mentioned.
-i Be not case sensitive. For example, letter "a" in lower case is considered thesame as letter "A" in upper case.
If the file is a sign-linking file, then the -> sign is added at the end of the file name for pointingto the linked file.
System OutputThe system outputs of the diff command are as follows:
l If 0 is displayed, you can infer that no difference is found.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-21
l If 1 is displayed, you can infer that differences are found.
l If >1 is displayed, you can infer that errors occur.
Application ExampleTo compare the chap1.bak file and the chap1 file, run the following command:
# diff chap1.back chap1
The system output displays the differences between the chap1.bak file and the chap1 file.
2.3.4 echoThis describes the function, format, option, and example of the echo command. The commandis only used on the Solaris operating system.
FunctionThe echo command is used to send a character string to a standard output device such as themonitor screen.
Command Formatecho character string option
Option DescriptionTable 2-6 lists five options that are frequently used.
Table 2-6 Option description of the echo command
Option Description
\c The RETURN character is not displayed.
\0n n is an 8-digit ASCII character code.
\t The TAB character is displayed.
\n The RETURN character is displayed.
\v The vertical TAB character is displayed.
Example# echo $HOME
/export/home/export/home displayed on the screen is the meaning of the character string "$HOME".
To prevent the system from displaying RETURN, run the following command:
# echo $HOME "\c"
2 Operating System Commands Command Reference
2-22 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
/export/homeOr:
# echo "$HOME \c"
/export/home
NOTE
The options \c, \0n, \t, \n, and \v are displayed in the character string enclosed in quotation marks. Thequotation marks can quote either one option or multiple options.
2.3.5 grepThis describes the function, format, and example of the grep command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe grep command is used to search for a character string in a text file and to print all the linesthat contain the character string.
Command Formatgrep character string file
ExampleTo search the character string operation in the ifconfig.txt file, run the following command:
# grep operation ifconfig.txt
used to control operation of dhcpagent(1M), the DHCP client operation, be used to modify the address or characteristics dhcpagent wakes up to conduct another DHCP operation on the given, and the operation is one that requested operation will continue.
To search the character string "The following options are supported" in the ifconfig.txt file, runthe following the command:
# grep "The following options are supported" ifconfig.txt
The following options are supported:
NOTE
The character string "The following options are supported" includes spaces. Remember to enclose thecharacter string within quotation marks in the command line.
2.3.6 headThis describes the function, format, and example of the head command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe head command is used to view the first few lines of a text file. By default, the first 10 linesare displayed.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-23
Command Formathead value file
ExampleTo view the first three lines of the A_Table.txt file, run the following command:
# head -3 A_Table.txt
Name Owner Object_type ------------------------------ ------------------------------
2.3.7 lessThis describes the function, format, parameter options, and application example of the lesscommand. You can run the less command to view files. The command is only used on the Linuxoperating system.
FunctionA text file is displayed on a PC by page. The function of the less command is the same as thatof the more command. You can run either command to view a file by page. The difference isthat, the less command enables you to turn to the previous or next page. For details about themore, see 2.3.8 more.
Formatless option file
Application ExampleTo view the contents of the cat_Table.txt file on screen at a time, run the following command:
# less cat_Table.txt
NOTE
To view a file on screen at a time, press the following keys to perform relevant operations:
l b: Turn to the previous page.
l p: Turn to the next page.
l q: Exit.
2.3.8 moreThis describes the function, format, option, and example of the more command. The morecommand is used to view a file one screen at a time. The usage of the command is the same onthe Solaris operating system and the Linux operating system.
FunctionView a file one screen at a time. You can also use this command to browse the previous screensand to search for character strings.
2 Operating System Commands Command Reference
2-24 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Formatmore option file
Option DescriptionRemember to insert the prefix - before the options when multiple options and combination ofoptions are used. Table 2-7 lists four options that are frequently used.
Table 2-7 Option description of the more command
Option Description
-c Clears the screen before the content is displayed.
-w Indicates that the system does not exit at the end of the input but waits for theprompt.
-lines Displays the number of lines on each screen.
+/mode Searches files in a preset mode.
ExampleTo view the contents of the cat_Table.txt file on screen at a time, run the following command:
# more cat_Table.txt
Name Owner Object_type ------------------------------ ------------------------------ ---------------------- tbl128Addr cat user table tbl128IP cat user table tbl128Name cat user table tblAdapterIP cat user table tblAdjCell cat user table... ... ...
NOTE
l To view a file on screen at a time, press the following keys to perform relevant operations:Space key: to view the next screenReturn key: to view the next lineq: to exith: to view the online helpb: to switch back to the previous screen/word: to search the character string "word" backward
2.3.9 tailThis describes the function, format, and example of the tail command. The usage of the commandis the same on the Solaris operating system and the Linux operating system.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-25
FunctionThe tail command is used to view the last few lines of a text. By default, the last 10 lines aredisplayed.
Command Formattail value file
ExampleTo view the last ten lines of the cat_Table.txt file, run the following command:
# tail cat_Table.txt
Name Owner Object_type ------------------------------ ------------------------------ ---------------------- tbl128Addr cat user table tbl128IP cat user table tbl128Name cat user table tblAdapterIP cat user table tblAdjCell cat user table... ... ...
NOTE
A special function of the tail command is to view the latest changes of a log file, because all the latestchanges are added at the end of the log file. The command format is as follows:
# tail -f commdrv.log
The option -f refers to the function of monitoring a file.
2.3.10 viThis describes the function and format of the vi command. The vi command can be used to createand modify text files. The usage of the command is the same on the Solaris operating systemand the Linux operating system.
FunctionAs a powerful text editing tool, the vi editor is used to create and modify text files.
The vi editor works in two modes:l Text input mode: to enter the text
l Command mode: to enter the control command
Formatl To start the vi editor, enter the following command:
vi file name
2 Operating System Commands Command Reference
2-26 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
l Table 2-8 lists the operations in the text input mode.
Table 2-8 Operations in the text input mode
Command Function
a Insert text immediately after the cursor (append).
A Insert text at the end of the line where the cursor is.
i Insert text immediately before the cursor (insert).
I Insert text before the first nonblank character in the line where thecursor is.
o Insert a new line below the current one and insert text (open).
O Insert a new line above the current one and insert text.
l Table 2-9 lists the operations related to moving the cursor in the text input mode.
Table 2-9 Operations related to moving the cursor in the text input mode
Command Function
h Move the cursor one character left.
j Move the cursor one character down.
k Move the cursor one character up.
l Move the cursor one character right.
Line No. G Move the cursor to a specified line. For example, 1G meansthat the cursor is moved to the first line.
G Move the cursor to the end of the text.
l Table 2-10 lists the operation for exiting the text input mode and switching to the command
mode.
Table 2-10 Operation for exiting the text input mode and switching to the command mode
Command Function
ESC Exit the text input mode and switches to the command mode.
l Table 2-11 lists the operations related to deleting characters in the command mode.
Table 2-11 Operations related to deleting characters in the command mode
Command Function
x Delete a character.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-27
Command Function
dd Delete a line.
l Exit the vi editor.
All the commands that exit vi editor must be run in the command mode. Therefore pressESC before running the commands. Table 2-12 describes the commands for exiting the vieditor.
Table 2-12 Commands for exiting the vi editor
Command Function
:wq Save a file and exit the vi editor.
:q Exit from the vi editor without saving the file.
:q! Exit from the vi editor and discard all the changes.
:w Save a file other than exit the vi editor.
2.4 Account ManagementThis describes the functions of the account management commands and provides someapplication examples. Only user root and authorized users can add, modify, or delete users anduser groups.
2.4.1 groupaddThis describes the function, format, and example of the groupadd command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.4.2 groupdelThis describes the function, format, and example of the groupdel command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.4.3 groupmodThis describes the function, format, parameter, and example of the groupmod command. Thecommand is only used on the Solaris operating system.
2.4.4 passwdThis describes the function, format, and example of the passwd command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.4.5 useraddThis describes the command function, command format, command option, and example of theuseradd command. The usage of the command is the same on the Solaris operating system andthe Linux operating system.
2.4.6 userdelThis describes the function, format, and example of the userdel command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.4.7 usermod
2 Operating System Commands Command Reference
2-28 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
This describes the function, format, parameter, and example of the usermod command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
2.4.1 groupaddThis describes the function, format, and example of the groupadd command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe groupadd command is used to add a user group in the operating system.
Command Formatgroupadd user group name
ExampleTo add the user group staff1 in the operating system, run the following command:
# groupadd staff1
2.4.2 groupdelThis describes the function, format, and example of the groupdel command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe groupdel command is used to delete a user group in the Unix/Linux system.
Command Formatgroupdel user group name
ExampleTo delete the user group staff1, run the following command:
# groupdel staff1
2.4.3 groupmodThis describes the function, format, parameter, and example of the groupmod command. Thecommand is only used on the Solaris operating system.
FunctionThe groupmod command is used to modify the information about a user group.
Command Formatgroupmod user group name
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-29
Parameter Description-n name: the name of the modified user group
ExampleTo modify the name of the user group staff1 to staff2, run the following command:
# groupmod -n staff2 staff1
2.4.4 passwdThis describes the function, format, and example of the passwd command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe passwd command is used to set a password for an added user or to change the user password.
Command Formatpasswd user name
ExampleAssume that the user omc1 is added. To set the password of omc1, run the following command:
# passwd omc1
New Password:Re-enter new Password:passwd: password successfully changed for omc1
NOTE
The input password is not displayed.
2.4.5 useraddThis describes the command function, command format, command option, and example of theuseradd command. The usage of the command is the same on the Solaris operating system andthe Linux operating system.
FunctionThe useradd command is performed to add a user in the Unix/Linux system.
Command Formatuseradd option new user name
Option DescriptionYou can combine options of the useradd command. Add the prefix - before these options. Table2-13 lists the common options.
2 Operating System Commands Command Reference
2-30 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Table 2-13 Option description of the useradd command
Option Remark
-c comment Indicate the comment.
-d directory Indicate the home folder.
-m Indicate the automatic creation of a homefolder if the home folder does not exist.
-g group Indicate the user group that the user belongsto.
-s shell Indicate the shell that the user uses.
-u uid indicates the user ID. A user account has aunique ID.
-k directory indicates that a template file in a specifieddirectory is copied to the main directory.Common template files include .profileand .cshrc. Template files enable each user tooperate in the same environment. If you planto run the useradd command to copy atemplate file to the main directory, you mustcheck whether the main directory exists. If themain directory does not exist, run theuseradd -m command to create one. If themain directory exists, the user group to whichthe created user belongs must have the read,write, and execute rights over the maindirectory.
ExampleCreate a user named omc1 in the Unix/Linux system. The user omc1 belongs to the staff usergroup and the home folder is /home1/omc that is created automatically. In addition, the commentis Test User and B shell is applied. To create a user named omc1 in the Unix/Linux system, runthe following commands:
# useradd -c "Test User" -d /home1/omc -m -g staff -s /bin/bash omc1
CAUTIONAfter a user is added, set the password for the added user. For details of setting the password,refer to 2.4.4 passwd. After the password is set, the user can log in as a new user.
2.4.6 userdelThis describes the function, format, and example of the userdel command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-31
FunctionThe userdel command is used to delete a user. Some operating system systems do not allowdeleting users completely. Run the userdel command to revoke the privileges granted to the user.
Command Formatuserdel user name
ExampleAssume that there is user omc1 in the system. To delete user omc1, run the following command:
# userdel omc1
If the following message is displayed, you can infer that no timing task created by the user isbeing performed.
no crontab for omc1
CAUTIONWhen a user has logged in, do not run the userdel command to delete the user. If you run theuserdel command, the following error message is displayed:UX: userdel: ERROR: omc1 is in use. Cannot remove it.
2.4.7 usermodThis describes the function, format, parameter, and example of the usermod command. Theusage of the command is the same on the Solaris operating system and the Linux operatingsystem.
FunctionThe usermod command is used to modify the user login information.
Command Formatusermod option user name
Option DescriptionThe combined option of the usermod command can be used. Add the prefix - before the options.Table 2-14 lists the common options.
Table 2-14 Option description of the usermod command
Option Description
-c comment Modified comment
2 Operating System Commands Command Reference
2-32 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Option Description
-d directory Modified home folder
-m Create a home folder automatically if thehome folder does not exist
-g group Modified user group
-s shell Used shell
-l new_logname Modified user name
ExampleTo modify the login information about omc1, you need modify the user name to test, user groupto new_group, home folder to /home1, and comment to Tester. Run the following command:
# usermod -c "Test User" -d /home1 -g new_group -l test omc1
CAUTIONDo not run the usermod command to modify a user when the user has logged in. If you use theusermod command, the following error message is displayed:UX: usermod: ERROR: omc1 is in use. Cannot change it.
2.5 Find and HelpThis describes the functions of the find and help commands and provides some applicationexamples.
2.5.1 findThis describes the function, format, parameter, and example of the find command. The usageof the command is the same on the Solaris operating system and the Linux operating system.
2.5.2 manThis describes the function, format, and example of the man command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.5.3 whereisThis describes the function, format, option, parameter, and example of the whereis command.The whereis command is used to view the location of a source file, binary file, and online helpof a command. The command is only used on the Solaris operating system.
2.5.4 whichThis describes the function, format, and example of which command. The command is only usedon the Solaris operating system.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-33
2.5.1 findThis describes the function, format, parameter, and example of the find command. The usageof the command is the same on the Solaris operating system and the Linux operating system.
Function
The find command is used to search for a file that meets the preset conditions in the specifiedfolders and subfolders. By using this command, you can find the file even if you forget the correctpath of the file.
Command Format
find folder condition
Parameter Descriptionl Folder: indicates the folder to be searched. You can enter multiple folder names. Separate
the folder names by using spaces.l Condition: indicates the conditions for file search, such as the file name, owner, and time
of the last modification.
Table 2-15 describes the conditions for file search.
Table 2-15 Conditions for file search
Condition Description
-name name The name of the file or folder to be searched.Wildcards, such as -name '*.c', can be used.
-print Prints the path that meets the conditions.
-size n Searches for the files that use n blocks.
-type x Searches for files by file type. The file type x includes:l d: directory
l f: file
l b: block
l c: character
l p: pipe
-user user Searches all files of user. The value of user can be auser name or UID.
-group group Searches all files of the user group. The value of groupcan be a user group name or GID.
-links n Searches all files with the number of links as n.
-atime n Searches the files accessed before n days.
-mtime n Searches the files modified before n days.
2 Operating System Commands Command Reference
2-34 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Condition Description
-exec command {}\; Uses the found file as the object of the command to berun. Put the parameters to be used in the commandexecution between { and }.
Table 2-16 describes the logical operators of conditions.
Table 2-16 Logical operators of conditions
LogicalOperator
Meaning
Example Description
! non ! -name "*.c" All the files except those withthe extension name as .c
-o or -size +10 -o -links 3 All the files with more than 10blocks or with 3 links
and -size +10 -links 3 All the files with more than 10blocks and with 3 links
In the preceding table, +10 stands for more than 10 blocks and -10 for fewer than 10 blocks.
ExampleTo search for files in the /tmp folder with the file name starting with c, and then print the paths,run the following command:
# find /tmp -name "c*" -print
/tmp/ctisql_0WBJgt/tmp/ctisql_0dznJ_/tmp/ctisql_0CpW34/tmp/ctisql_0FO4vs
To search the file test in the current folder and then print the paths, run the following command:
# find . -name test -print
./Report/reloc/resin1.2.0/conf/test
./Report/reloc/resin1.2.0/doc/examples/login/WEB-INF/classes/test
./Report/reloc/resin1.2.0/doc/examples/tags/WEB-INF/classes/test
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-35
NOTE
l The search may take several minutes. To save time, you can run this command in the background.That is, the output for the command is exported to a file for later query. End the command line with& so that the operating system runs the command in the background. For example,
# find / -name "abc*" -print > abc.file &
l After the search is complete, run the following command to view the result of the search:
# cat abc.file
l Different users may have different privileges for the same file. Therefore, ordinary users may findonly some files of the system. To list all the files that meet the set conditions, log in as a super userand search from the root directory.
2.5.2 manThis describes the function, format, and example of the man command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The man command is used to view the online help about a command.
Command Format
man option command
Example
To view the online help about the pwd command, run the following command:
# man pwd
Reformatting page. Wait... done
User Commands pwd(1)
NAME pwd - return working directory name
SYNOPSIS /usr/bin/pwd
DESCRIPTION pwd writes an absolute path name of the current working directory to standard output.
Both the Bourne shell, sh(1), and the Korn shell, ksh(1), also have a built-in pwd command.
ENVIRONMENT See environ(5) for descriptions of the following environment variables that affect the execution of pwd: LC_MESSAGES and NLSPATH.
EXIT STATUS--More--(30%)
NOTE
Not all parameters in the man command are command names. For example, the man ascii commanddisplays all the ASCII characters and their expressions.
2 Operating System Commands Command Reference
2-36 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.5.3 whereisThis describes the function, format, option, parameter, and example of the whereis command.The whereis command is used to view the location of a source file, binary file, and online helpof a command. The command is only used on the Solaris operating system.
Function
The whereis command is used to view the location of a source file, binary file, and online helpof a command.
Command Format
whereis option command
Option Descriptionl -b : to view the location of the binary file
l -m: to view the location of the help manual
l -s: to view the location of the source file
Parameter Description
command: the command for which the location is to be displayed
Examplel To view the exact location of files of various versions for the ls command, run the following
command:# whereis lsls: /usr/bin/ls /usr/ucb/ls /usr/man/man1/ls.1 /usr/man/man1b/ls.1b
l To view the exact location of the binary file for the ls command, run the followingcommand:# whereis -b lsls: /usr/bin/ls /usr/ucb/ls
l To view the exact location of the help manual for the ls command, run the followingcommand:# whereis -m lsls: /usr/man/man1/ls.1 /usr/man/man1b/ls.1b
2.5.4 whichThis describes the function, format, and example of which command. The command is only usedon the Solaris operating system.
Function
The which command is used to view the location where a command is run. The result may bean absolute path or alias of the command found in the user environment variant PATH.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-37
Command Format
which command
Example
To view the position where the commands pwd, who, and which are run, run the followingcommand:
# which pwd who which
/usr/bin/pwd/usr/bin/who/usr/bin/which
NOTE
If the command to be located does not exist in the file, the following error messages are displayed afteryou run the which command:
# which qqqqno qqqq in /usr/bin /usr/ucb /etc
2.6 System InformationThis describes the system information commands and provides some application examples.
2.6.1 dateThis describes the function, format, parameter options, and application examples of the datacommand. The data command is used to view the current date and time of the system. The usageof the command is the same on the Solaris operating system and the Linux operating system.
2.6.2 dfThis describes the function, format, option, and example of the df command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.6.3 duThis describes the function, format, option, and example of the du command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.6.4 hostnameThis describes the function, format, and example of the hostname command. The command isonly used on the Solaris operating system.
2.6.5 prtconfThis describes the function, format, parameter options, and instances of the prtconf command.The command is only used on the Solaris operating system.
2.6.6 unameThis describes the function, format, parameter options, and application examples of the unamecommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
2.6.7 whoThis describes the functions, command format, option description, parameter description, andexample of the who command. The usage of the command is the same on the Solaris operatingsystem and the Linux operating system.
2 Operating System Commands Command Reference
2-38 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.6.1 dateThis describes the function, format, parameter options, and application examples of the datacommand. The data command is used to view the current date and time of the system. The usageof the command is the same on the Solaris operating system and the Linux operating system.
FunctionThe data command is used to view the current date and time of the system. The super user canrun the date command to set the system date and time.
Formatdate option +format
Option Descriptionl -u: to use the Greenwich mean time.
l +format: to specify the command output format.
Table 2-17 describes the format of the command output.
Table 2-17 Format of the command output
Format Description
%h Abbreviation of the month: from January to December
%j A day in a year: from 001 to 366
%n Switch to next line
%t The tab key
%y The last two digits of the year: from 00 to 99
%D Output format of the date: month/date/year
%H Hour: from 00 to 23
%M Minute: from 00 to 59
%S Second: from 00 to 59
%T Output format of time: hour:minute:second
Examplel To view the current date and time of the system, run the following command:
dateMon Feb 4 20:26:16 GMT 2002
l To view the current system date and time in the Greenwich Mean Time, run the followingcommand:date -u
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-39
Mon Feb 4 12:27:26 GMT 2002
l To view the current date of the system in the format of month/day/year, run the followingcommand:
date +%D02/04/02
2.6.2 dfThis describes the function, format, option, and example of the df command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The df command is used to view the free disk space. The system administrator runs this commandfrequently to check the usage of the disk space to avoid disk failure due to data overflow.
Command Format
df option file system
Option Descriptionl -l : the local file system
l -k: to view the free disk space (unit: KB)
Example
To check the free disk space, run the following command:
# df -k
Filesystem kbytes used avail capacity Mounted on/dev/dsk/c0t0d0s0 2053605 997684 994313 51% //proc 0 0 0 0% /procfd 0 0 0 0% /dev/fd/dev/dsk/c0t1d0s7 35009161 2562019 32097051 8% /export/homeswap 3431792 6664 3425128 1% /tmp
The command result contains the following information:
l File system name
l File size (unit: KB)
l Used space
l Free space
l Capacity percentage of the filled file system and the mounting point
When you run the df command without any parameters, the free disk space in each mounteddevice is displayed.
When the free disk space is reduced to the bottom line, the system administrator must takeimmediate measures to locate the faulty file system.
2 Operating System Commands Command Reference
2-40 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.6.3 duThis describes the function, format, option, and example of the du command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The du command is used to view the disk space used by a specific folder or file.
Command Format
du option folder or file
Option Descriptionl -a : to view the disk space used by each file
l -s: to view the used total disk space
l -k: to view the result (unit: KB)
Examplel To view the disk space used by the files in the /etc folder, run the following command:
# du -k /etc |more4 /etc/X11/fs4 /etc/X11/twm84 /etc/X11/xdm/pixmaps157 /etc/X11/xdm721 /etc/X11/xkb/rules52 /etc/X11/xkb/types16 /etc/X11/xkb/semantics8 /etc/X11/xkb/geometry/ibm_vndr44 /etc/X11/xkb/geometry/digital_vndr44 /etc/X11/xkb/geometry/sgi_vndr285 /etc/X11/xkb/geometry81 /etc/X11/xkb/compat28 /etc/X11/xkb/symbols/sun_vndr16 /etc/X11/xkb/symbols/fujitsu_vndr84 /etc/X11/xkb/symbols/macintosh_vndr8 /etc/X11/xkb/symbols/nec_vndr32 /etc/X11/xkb/symbols/digital_vndr4 /etc/X11/xkb/symbols/sony_vndr12 /etc/X11/xkb/symbols/xfree68_vndr4 /etc/X11/xkb/symbols/hp_vndr4 /etc/X11/xkb/symbols/sgi_vndr850 /etc/X11/xkb/symbols40 /etc/X11/xkb/keymap/sun_vndr8 /etc/X11/xkb/keymap/digital_vndr93 /etc/X11/xkb/keymap/sgi_vndr181 /etc/X11/xkb/keymap16 /etc/X11/xkb/keycodes/digital_vndr12 /etc/X11/xkb/keycodes/sgi_vndr108 /etc/X11/xkb/keycodes2345 /etc/X11/xkb4 /etc/X11/xsm4 /etc/X11/lbxproxy16 /etc/X11/fvwm24 /etc/X11/xserver/C/print/ddx-config/raster4 /etc/X11/xserver/C/print/ddx-config12 /etc/X11/xserver/C/print/attributes
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-41
245 /etc/X11/xserver/C/print/models/PSdefault/fonts--More―
l To view the disk space used by all file systems in the current folder and send the results tothe sort command for sorting, run the following command:
# du -s * |sort -rn |more28672 opt3757 X112522 cups1282 bootsplash822 xscreensaver808 sysconfig661 services661 init.d473 postfix428 apparmor416 mono389 joe193 profile.d165 ssl165 apparmor.d164 ssh145 pam.d145 lvm112 fonts109 xinetd.d--More―
l To list the first ten file systems according to the file size, run the following command:
# du -s * |sort -rn |head -1028672 opt3757 X112522 cups1282 bootsplash822 xscreensaver808 sysconfig661 services661 init.d473 postfix428 apparmor
2.6.4 hostnameThis describes the function, format, and example of the hostname command. The command isonly used on the Solaris operating system.
Function
The hostname command is used to view or set the host name.
Command Format
hostname host name
Example
To view the host name, run the following command:
# hostname
2 Operating System Commands Command Reference
2-42 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
NOTE
If you run the hostname command without parameters, the host name of the equipment is displayed. Ifyou run the hostname command with parameters, the host name is set. Only the super user can run thehostname command.
2.6.5 prtconfThis describes the function, format, parameter options, and instances of the prtconf command.The command is only used on the Solaris operating system.
FunctionThe prtconf command is used to check the system configuration information.
Formatprtconf option device path
Instancel Check all the configuration information about the system.
# prtconfSystem Configuration: Sun Microsystems sun4uMemory size: 4096 MegabytesSystem Peripherals (Software Nodes):
SUNW,Netra-240 scsi_vhci, instance #0 packages (driver not attached) SUNW,builtin-drivers (driver not attached) deblocker (driver not attached) disk-label (driver not attached) terminal-emulator (driver not attached) dropins (driver not attached) kbd-translator (driver not attached) obp-tftp (driver not attached) SUNW,i2c-ram-device (driver not attached) SUNW,fru-device (driver not attached) SUNW,asr (driver not attached) ufs-file-system (driver not attached) chosen (driver not attached) openprom (driver not attached) client-services (driver not attached) options, instance #0 aliases (driver not attached) memory (driver not attached) virtual-memory (driver not attached) SUNW,UltraSPARC-IIIi, instance #0 (driver not attached) memory-controller, instance #0 SUNW,UltraSPARC-IIIi, instance #1 (driver not attached) memory-controller, instance #1 pci, instance #0 network, instance #0 network, instance #1 pci, instance #1 isa, instance #0 flashprom (driver not attached) rtc (driver not attached) i2c, instance #0 i2c-bridge (driver not attached) i2c-bridge (driver not attached) motherboard-fru-prom, instance #0 (driver n
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-43
chassis-fru-prom, instance #1 (driver not a alarm-fru-prom, instance #2 (driver not att power-supply-fru-prom, instance #3 (driver power-supply-fru-prom, instance #4 (driver dimm-spd, instance #5 (driver not attached) dimm-spd, instance #6 (driver not attached) dimm-spd, instance #7 (driver not attached) dimm-spd, instance #8 (driver not attached) rscrtc (driver not attached) nvram, instance #9 (driver not attached) idprom (driver not attached) gpio, instance #0 (driver not attached) gpio, instance #1 (driver not attached) gpio, instance #2 (driver not attached) gpio, instance #3 (driver not attached) gpio, instance #4 (driver not attached) gpio, instance #5 (driver not attached) power, instance #0 serial, instance #0 serial, instance #1 (driver not attached) rmc-comm, instance #0 pmu, instance #0 i2c, instance #0 gpio, instance #0 usb, instance #0 ide, instance #0 disk (driver not attached) cdrom (driver not attached) sd, instance #3 pci, instance #2 scsi, instance #0 disk (driver not attached) tape (driver not attached) sd, instance #0 sd, instance #1 (driver not attached) sd, instance #2 (driver not attached) sd, instance #4 (driver not attached) sd, instance #5 (driver not attached) sd, instance #6 (driver not attached) sd, instance #7 (driver not attached) sd, instance #8 (driver not attached) sd, instance #9 (driver not attached) sd, instance #10 (driver not attached) sd, instance #11 (driver not attached) sd, instance #12 (driver not attached) sd, instance #13 (driver not attached) sd, instance #14 (driver not attached) sd, instance #15 (driver not attached) st, instance #1 (driver not attached) st, instance #2 (driver not attached) st, instance #3 (driver not attached) st, instance #4 (driver not attached) st, instance #5 (driver not attached) st, instance #6 (driver not attached) ses, instance #1 (driver not attached) ses, instance #2 (driver not attached) ses, instance #3 (driver not attached) ses, instance #4 (driver not attached) ses, instance #5 (driver not attached) ses, instance #6 (driver not attached) ses, instance #7 (driver not attached) ses, instance #8 (driver not attached) ses, instance #9 (driver not attached) ses, instance #10 (driver not attached) ses, instance #11 (driver not attached) ses, instance #12 (driver not attached) ses, instance #13 (driver not attached) ses, instance #14 (driver not attached) ses, instance #15 (driver not attached)
2 Operating System Commands Command Reference
2-44 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
scsi, instance #1 disk (driver not attached) tape (driver not attached) sd, instance #16 (driver not attached) sd, instance #17 (driver not attached) sd, instance #18 (driver not attached) sd, instance #19 (driver not attached) sd, instance #20 (driver not attached) sd, instance #21 (driver not attached) sd, instance #22 (driver not attached) sd, instance #23 (driver not attached) sd, instance #24 (driver not attached) sd, instance #25 (driver not attached) sd, instance #26 (driver not attached) sd, instance #27 (driver not attached) sd, instance #28 (driver not attached) sd, instance #29 (driver not attached) sd, instance #30 (driver not attached) st, instance #8 (driver not attached) st, instance #9 (driver not attached) st, instance #10 (driver not attached) st, instance #11 (driver not attached) st, instance #12 (driver not attached) st, instance #13 (driver not attached) ses, instance #16 (driver not attached) ses, instance #17 (driver not attached) ses, instance #18 (driver not attached) ses, instance #19 (driver not attached) ses, instance #20 (driver not attached) ses, instance #21 (driver not attached) ses, instance #22 (driver not attached) ses, instance #23 (driver not attached) ses, instance #24 (driver not attached) ses, instance #25 (driver not attached) ses, instance #26 (driver not attached) ses, instance #27 (driver not attached) ses, instance #28 (driver not attached) ses, instance #29 (driver not attached) ses, instance #30 (driver not attached) ses, instance #31 (driver not attached) pci, instance #3 network, instance #2 network, instance #3 iscsi, instance #0 pseudo, instance #0
2.6.6 unameThis describes the function, format, parameter options, and application examples of the unamecommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
FunctionThe uname command is used to view the information about the operating system. If you run thiscommand without parameters, only the name of the operating system is displayed. If you runthis command with parameters, more details about the operating system are displayed.
Formatuname option
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-45
Option Description
The options of the uname command can be combined. Add the prefix - before the options. Table2-18 lists some frequently used options.
Table 2-18 Description of the uname options
Option Description
-a Views all the information.
-i Views hardware information.
-m Views the name of the equipment hardware.It is recommended that -p be used instead of-m.
-n Views the name of the network equipment.
-p Views the ISA of the host or the type of theprocessor.
-r Views the serial number of the operatingsystem of the host.
-s Views the name of the operating system of thehost (it is the default option).
-v Views the version of the operating system ofthe host.
-S system_name Sets the host name of the machine.
Example
To view the name, version, and serial number of the operating system on the host, run thefollowing command:
# uname -svr
2.6.7 whoThis describes the functions, command format, option description, parameter description, andexample of the who command. The usage of the command is the same on the Solaris operatingsystem and the Linux operating system.
Function
The who command reports the login information about all the users in the current system.
Command Format
who Option
2 Operating System Commands Command Reference
2-46 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Option Descriptionl -b : display the system date and time of the last startup
l -m: display the related information about the users who run the command (the same as thecommand who with two parameters am i
Parameter Description
am i: display the login information about the users who run the command
Examplel Display the login information about all the users in the current system:
# whoroot pts/3 Feb 4 10:08 (10.129.16.60)root pts/5 Feb 4 08:45 (10.129.28.44)root pts/6 Feb 4 11:25 (10.129.16.60)
l Display the login information about the users who run the command:
# who am iroot pts/5 Feb 4 08:45 (10.129.28.44)
or:
# who -mroot pts/5 Feb 4 08:45 (10.129.28.44)
2.7 Process-RelatedThis describes the process-related commands and provides some application examples.
2.7.1 killThis describes the function, format, option, and example of the kill command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.7.2 prstatThis describes how to use the CPU to check the function and user identity of the prstat command.It also provides an example to explain the application. The command is only used on the Solarisoperating system.
2.7.3 psThis describes the function, format, option, and example of the ps command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.7.4 topThis describes the function and application example of the top command. It also describes theusers authorized to run the top command. You can run the top command to view the CPU usage.The command is only used on the Linux operating system.
2.7.1 killThis describes the function, format, option, and example of the kill command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-47
FunctionThe kill command is used to terminate a process.
Command Formatkill option process No.
Option Descriptionl -l : lists the names of all the signals
l -s signal: sends a signal named signal to the processes
Parameter DescriptionProcess No.: the ID of the process to be terminated, that is, the process ID
Examplel To list all the signal names on the Solaris operating system, run the following command:
# kill -lEXIT HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM USR1 USR2 CLD PWR WINCH URG POLL STOP TSTP CONT TTIN TTOU VTALRM PROF XCPU XFSZ WAITING LWP FREEZE THAW CANCEL LOST RTMIN RTMIN+1 RTMIN+2 RTMIN+3 RTMAX-3 RTMAX-2 RTMAX-1 RTMAX
l To list all the signal names on the Linux operating system, run the following command:# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR213) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+439) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+843) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+1247) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-1451) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-1055) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-659) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-263) SIGRTMAX-1 64) SIGRTMAX
l To terminate the process with PID as 256, run the following command:# kill -s KILL 256
2 Operating System Commands Command Reference
2-48 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
NOTE
l The previous signal names can be expressed by code.
For example, -1 for HUP, -2 for INT, -3 for QUIT, -9 for KILL, -15 for TERM. The signalKILL can be replaced with -9.
This signal is the most frequently used one in the kill command, and thus it has the highest priority.
The default signal 15 is used when no option is specified for the kill command. Run the followingcommand to terminate the process with the PID as 256:
# kill -9 256
l Run the ps command to check the execution of the kill command by listing the PIDs of the terminatedprocesses.
l The kill command may lead to a data loss. Run this command with care.
2.7.2 prstatThis describes how to use the CPU to check the function and user identity of the prstat command.It also provides an example to explain the application. The command is only used on the Solarisoperating system.
FunctionThe CPU usage may be high when a large number of NE alarms are reported in a short period.This command is used to find out the cause of these alarms.
Permitted UsersUsers root, omcuser, and dbuser are authorized to run the prstat command.
Example-bash-3.00$ prstat
The command result contains the CPU usage of each process.
2.7.3 psThis describes the function, format, option, and example of the ps command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionThe ps command is used to view the status of the processes currently running in the system..
Command Formatps option
Option Descriptionl -e : to view the status of all the processes that are running in the system
l -l: to view the running processes in a long-form list
l -u user: to view the process status of a specific user
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-49
l -f : to view all the status information about the processes that are running in the system
Examplel To view the status of all the running processes controlled by the login device (the terminal),
run the following command:
# ps PID TTY TIME CMD 13726 pts/5 0:00 ksh
l To view the complete information about the active processes, run the following command:
# ps -f UID PID PPID C STIME TTY TIME CMDroot 1489 1426 0 Jun24 pts/4 00:00:00 -bash
l To view the process related to the "xinetd", run the following command:
# ps -ef | grep xinetdroot 26930 1 0 Oct15 ? 00:00:00 /usr/sbin/xinetdroot 4346 29413 0 10:01 pts/1 00:00:00 grep xinetd
NOTE
l After you run the ps command without any parameters, the screen displays information about allrunning processes that are controlled by the login device (terminal).
l After you specify the -f parameter, more information is displayed. The information includes the username (UID), process ID (PID), parent process ID (PPID), technical number that indicates therunning time of the process (C), process start time (STIME), name of the terminal that activates theprocess (TTY), and the process name (CMD). If TTY displays ?, infer that this process is not associatedwith the terminal.
l To view all the processes related to specific characters, for example, the process related to the"xinetd", run the grep command with the ps command.
2.7.4 topThis describes the function and application example of the top command. It also describes theusers authorized to run the top command. You can run the top command to view the CPU usage.The command is only used on the Linux operating system.
Function
The CPU usage may be high when a large number of NE alarms or performance data are reportedin a short period. This command is used to find out the cause of these alarms.
Authorized Users
User root and user omcuser are authorized to run the top command.
Application Example
# top
The system output contains the CPU usage of each process.
2 Operating System Commands Command Reference
2-50 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
2.8 Network CommunicationsThis describes the commands used for network communications and provides some applicationexamples.
2.8.1 fingerThis describes the function, format, parameters, and example of the finger command. Thecommand is only used on the Solaris operating system.
2.8.2 ftpThis describes the function, format, parameter options, and application example of the ftpcommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
2.8.3 ifconfigThis describes the function, format, option, and example of the ifconfig command. The usageof the command is the same on the Solaris operating system and the Linux operating system.
2.8.4 netstatThis describes the function, format, options, and example of the netstat command. The usageof the command is the same on the Solaris operating system and the Linux operating system.
2.8.5 pingThis describes the function, format, parameter options, and application examples of the pingcommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
2.8.6 routeThis describes the function, format, parameter options, and application example of the routecommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
2.8.7 telnetThis describes the functions, format, parameters, and example of the telnet command. Thetelnet command is used to log in to remote hosts through network connection. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.8.1 fingerThis describes the function, format, parameters, and example of the finger command. Thecommand is only used on the Solaris operating system.
FunctionThe finger command is used to view the information about online users of the UNIX system.
Command Formatfinger user name@host domain|IP address
Parameter Descriptionl user nam: the user that has currently logged in to the local system.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-51
l host domain: the UNIX host domain.
l IP address: the IP address of the UNIX host.
ExampleTable 2-19 lists some common examples of the finger command.
Table 2-19 Examples of the finger command
Example Description
# finger View the information about all local users.
# finger root View the information about user root.
# finger @omcsyb2 View the information about all users in thehost omcsyb2.
# finger @omcsyb2.Huawei.com.cn View the information about all users in thehost omcsyb2.Huawei.com.cn.
# finger abc@omcsyb2 View the information about user abc in thehost omcsyb2.
# finger [email protected] View the information about user abc in thehost 129.6.114.202.
2.8.2 ftpThis describes the function, format, parameter options, and application example of the ftpcommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
FunctionThe ftp command is used to transfer files between the local computer and the remote host. Youcan transfer one or multiple files at a time between the remote operating system and the localcomputer.
Formatftp IP address or domain
Parameter Descriptionl IP address: the IP address of the remote host
l Domain name: the domain name of the remote host
ExampleRun the ftp command on the local computer. Assume that the IP address of the remote host is129.9.169.143.
2 Operating System Commands Command Reference
2-52 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Choose Start > Run on the local computer. In the displayed dialog box, enter ftp129.9.169.143 and click OK. When the ftp window is displayed, enter the operating system username and password.
User (129.9.169.143: (none) : ) ftpuser
Password:password of ftpuser230 Login successful.ftp>
NOTE
Enter the password after Password: . The password is not displayed.
Enter the ftp command behind the prompt ftp>. Table 2-20 describes the ftp commands thatare commonly used.
Table 2-20 Common ftp commands
ftp Command Description
!command Use a local command and return to ftpimmediately.
?|help command View the command help.
ascii Transfer files in ASCII format (default).
binary Transfer files in binary format.
cd folder Modify the remote folder.
close Break the remote connection.
dir r-folder l-file View the remote folder. r-folder refers to theremote folder. l-file refers to the local file. Ifthere is a local file, save the result to the localfile.
get file1 file2 Copy the remote file1 to the local file2.
cd folder Modify the local folder.
ls r-folder l-file Same as dir, but the display format isdifferent.
mget several files Copy several remote files to the localcomputer.
open IP address or domain Reestablish a connection.
put file1 file2 Copy the remote file1 to the local file2.
pwd List the folders of the current remote host.
quit|bye Exit from the ftp.
status View the current ftp status.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-53
l Copy all the files in the path C:\mydoc on the local computer to the /usr/local/tmp folderon the remote host.ftp> binary
ftp> lcd c:\mydoc
ftp> cd /usr/local/tmp
ftp> mput *.*
l Copy the .login file in the /usr/home/rms folder on the remote host to the path C:\mydoc folder on the local computer.ftp> ascii
ftp> lcd c:\temp\from
ftp> cd /usr/home/rms
ftp> get .login
l Copy all files in the /usr/home/rms folder on the remote computer to the path C:\temp\from on the local computer in binary format.ftp> binary
ftp> lcd c:\temp\from
ftp> cd /usr/home/rms
ftp> mget *
l To exit ftp.ftp> quit
CAUTIONThe Telnet and FTP protocols belong to the TCP/IP family. They are the protocols at theapplication layer. They work in client/server mode. The telnet/ftp program running on the localcomputer is a telnet/ftp client program. The telnet/ftp program connects to the server programin the remote host through the TCP/IP protocol. Any system installed with the telnet/ftp server-side software can serve as a remote host. In addition to the default network protocol TCP/IP, theUnix/Linux system supports the Telnet/FTP protocols. Because a Unix/Linux host is installedwith both the telnet/ftp server software and the client software, the Unix/Linux host can serveas either a telnet/ftp server or a telnet/ftp client.Please do not put or get the files on PC's desktop.Special characters in file name, including spaces, may fail the upload or download operations.Please quote the file names with “ ” while transferring files with ftp.
2.8.3 ifconfigThis describes the function, format, option, and example of the ifconfig command. The usageof the command is the same on the Solaris operating system and the Linux operating system.
Function
The ifconfig command is used to view the IP address of the host.
2 Operating System Commands Command Reference
2-54 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Formatifconfig option
Option Description-a: to view all the address information
ExampleTo view the IP address of the host on the Solaris operating system, run the following command:
# ifconfig -a
lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232inet 127.0.0.1 netmask ff000000hme0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST>mtu 1500 inet 129.9.169.143 netmask ffff0000 broadcast 129.9.255.255hme0:1:flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500 inet 129.6.253.136 netmask ffff0000 broadcast 129.6.255.255
To view the IP address of the host on the Linux operating system, run the following command:
# ifconfig -a
bond0 Link encap:Ethernet HWaddr 00:1A:4B:07:C1:18 inet addr:10.121.77.235 Bcast:10.121.77.255 Mask:255.255.254.0 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:3065894 errors:0 dropped:0 overruns:0 frame:0 TX packets:33607 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:261315320 (249.2 Mb) TX bytes:3767548 (3.5 Mb)
eth0 Link encap:Ethernet HWaddr 00:1A:4B:07:C1:18 inet6 addr: fe80::21a:4bff:fe07:c118/64 Scope:Link UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:1533670 errors:0 dropped:0 overruns:0 frame:0 TX packets:16806 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:130737659 (124.6 Mb) TX bytes:1906432 (1.8 Mb) Base address:0x1000 Memory:f0080100000-f0080120000
eth1 Link encap:Ethernet HWaddr 00:1A:4B:07:C1:19 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Base address:0x1040 Memory:f0080120000-f0080140000
eth2 Link encap:Ethernet HWaddr 00:1A:4B:07:C1:18 inet6 addr: fe80::21a:4bff:fe07:c118/64 Scope:Link UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:1532224 errors:0 dropped:0 overruns:0 frame:0 TX packets:16801 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:130577661 (124.5 Mb) TX bytes:1861116 (1.7 Mb) Base address:0x1200 Memory:f0180480000-f01804a0000
eth3 Link encap:Ethernet HWaddr 00:1E:0B:83:71:A1 inet addr:192.168.9.140 Bcast:192.168.9.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-55
Base address:0x1240 Memory:f01804a0000-f01804c0000
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:4337 errors:0 dropped:0 overruns:0 frame:0 TX packets:4337 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:404946 (395.4 Kb) TX bytes:404946 (395.4 Kb)
sit0 Link encap:IPv6-in-IPv4 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
NOTE
In the Unix/Linux system, a network adapter can bind several logical IP addresses, which realizescommunications between different network segments.
2.8.4 netstatThis describes the function, format, options, and example of the netstat command. The usageof the command is the same on the Solaris operating system and the Linux operating system.
FunctionThe netstat command is used to display the current network status. The netstat command ispowerful but complex in format. This describes common applications of the netstat command.
Command Formatnetstat options
Option Descriptionl For viewing all the sockets and routing tables (netstat -anv)
– -a: views all socket information.
– -n: views the information by number. If you do not specify this parameter, theinformation is displayed by logical name.
– -v: views the information about sockets and routing tables of the additional information.
l For viewing the IP address of the network adapter (netstat -i -I interface intervalinterval)– -i: views the information about the network interface.
– -I interface: specifies an interface, for example, hme0:1
– interval: indicates a time interval.
l For viewing the routing table status (netstat -r -anv)– -r: views the information about the routing table.
– -anv: refers to For viewing all the sockets and routing tables.
l For viewing the broadcast information (netstat -M -ns)– -M: views broadcast routing tables.
2 Operating System Commands Command Reference
2-56 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
– -s: summarizes the status of each protocol.
l For viewing the DHCP status (netstat -D -I interface)-D: views the DHCP information.
ExampleUse the command netstat -rn to view the information about the routing tables:
root@ts-007 # netstat -rn
Routing Table:Destination Gateway Flags Ref Use Interface10.105.28.0 10.105.28.202 U 4 2 hme010.0.0.0 10.105.31.254 UG 0 0 224.0.0.0 10.105.28.202 U 4 0 hme0127.0.0.1 127.0.0.1 UH 0 896 lo0
A router can be in any of the following five different flags: U, G, H, D, and M, as described inTable 2-21.
Table 2-21 Description of routing flags
Flag Description
U U indicates that a route is currently available.
G G indicates that a route is destined for a gateway such as a router.If this flag is not set, you can infer that the destination is connected directly.Flag G distinguishes between direct and indirect routes. Flag G is unnecessaryfor direct routes. The difference is that the packet sent through a direct routecarries both the destination IP address and the link-layer address. In the packetsent through an indirect route, however, the IP address points to the destinationand the link layer address points to the gateway (for example, the next router).
H H indicates a route destined for a host. That is, the destination address is acomplete host address.If this flag is not set, you can infer that the route leads to a network and thatthe destination address is a network address: either a network number or anetwork. The part in the address for the host is 0. When you search the routingtable for an IP address, the host address must exactly match the destinationaddress. The network address, however, is required to match only the networknumber and subnet number of the destination address.
D D indicates that a route is created by a redirected packet.
M M indicates that a route is modified by a redirected packet.
The Ref (Reference count) column lists the number of routing progresses. The protocol forconnection, such as TCP, requires a fixed route when a connection is established. If the telnetconnection is established between the host svr4 and the host slip, the Ref is 1. If another telnetconnection is established, its value is changed to 2.
The next column (Use) displays the number of packets sent through a specified route. After yourun the ping command as the unique user of this route, the program sends five groups and the
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-57
number of packets is displayed as 5. The last column (Interface) indicates the name of thelocal interface.
The second row of the output is a loop-back interface. The interface name is permanent set tolo0. Flag G is not set because the route is not destined for a gateway. Flag H indicates that thedestination address, 127.0.0.1, is a host address and not a network address. Because flag G isnot set, the route here is a direct route and the gateway column shows the outgoing IP address.
Each host has one or multiple default routes. That is, if a particular route is not found in the table,the packet is sent to the router. In addition, the current host can access other systems throughthe Sun router (and the slip link) on the internet, based on the settings of the routing table. Theflag UG refers to the gateway.
2.8.5 pingThis describes the function, format, parameter options, and application examples of the pingcommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
Function
The ping command is used to check the physical connection of the network when thecommunication between a user computer and the hosts in the network is interrupted.
Format
ping IP address of a host
Example
Check the physical connection between the current host and the host whose IP address is129.9.0.1 on the Solaris operating system.
# ping 129.9.0.1
129.9.0.1 is alive
Check the physical connection between the current host and the host whose IP address is10.71.15.1 on the Linux operating system.
# ping 10.71.15.1
PING 10.71.15.1 (10.71.15.1) 56(84) bytes of data.64 bytes from 10.71.15.1: icmp_seq=1 ttl=255 time=11.5 ms64 bytes from 10.71.15.1: icmp_seq=2 ttl=255 time=7.11 ms64 bytes from 10.71.15.1: icmp_seq=3 ttl=255 time=7.77 ms
The Internet Control Message Protocol (ICMP) is used through the ping command to check thenetwork connection. An ICMP echo request message is sent to a specific host to request an ICMPecho response message. If the response message is not received within a specified time, theHost unreachable message is displayed on the screen.
The Host unreachable message is displayed in the following cases:
l The specified host is invalid.
l The physical connection of the network is not secure.
2 Operating System Commands Command Reference
2-58 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
l The two communicating hosts do not support the same communication protocol.
To analyze the causes, run the ping command to connect to other hosts in the same networksegment. If the ping command is successful, you can infer that the connection is functional. Inthis case, check the physical connection and the operational status of the specified host. If theping command fails, check whether the physical network connection of the current host is secureor whether the TCP/IP protocol is set correctly only for Windows 95 users.
2.8.6 routeThis describes the function, format, parameter options, and application example of the routecommand. The usage of the command is the same on the Solaris operating system and the Linuxoperating system.
FunctionThe routing table relays IP address between network segments. The route command is used tomodify and maintain the routing table.
Formatroute -fnvq command modifiers args
route -fnvq add | change | delete | get host/net destination gateway args
route -n monitor
route -n flush
NOTE
The meaning of "|" is the same as that of the word "or".
Parameter DescriptionOptions of the route command can be combined. Table 2-22 lists some common options.
Table 2-22 Description of the route commands
Option Description
-f Refresh routing tables for all gateways.
-n View the information in characters instead of symbols.
-v View the additional information.
-q Suspend all outputs.
-commond Have the command add/chang/flush (clear the gateways inthe routing table)/get/monitor.
-destination Indicate the destination network segment. For example,10.0.0.0 stands for section 10, and 10.11.0.0 stands for section10.11.
-gateway Indicate the IP address of the gateway.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-59
Option Description
net Indicate the network segment. For example, 10.11.12.0stands for section 10.11.12.
host Indicate the IP address of the host.
The example of running on the Solaris operating systeml Obtain the routing information about network segment 10.
root@ts-007 # route -n get 10.0.0.0 route to: 10.0.0.0destination: 10.0.0.0 mask: 255.0.0.0 gateway: 10.105.31.254 interface: hme0 flags: <UP,GATEWAY,DONE,STATIC> recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire 0 0 0 0 0 0 1500 0
l Clear the gateways in the routing table.root@ts-007 # route -n flush10 10.105.31.254 doneroot@ts-007 # netstat -rnRouting Table: Destination Gateway Flags Ref Use Interface-------------------- -------------------- ----- ----- ------ ---------10.105.28.0 10.105.28.202 U 4 6 hme0224.0.0.0 10.105.28.202 U 4 0 hme0127.0.0.1 127.0.0.1 UH 0 1500 lo0root@ts-007 # telnet 10.129.3.4Trying 10.129.3.4...telnet: Unable to connect to remote host: Network is unreachableAfter the gateways in the routing table are cleared, the network segments beyond10.105.28.202/34 are no longer accessible.
l Add a routing record.root@ts-007 # route add 129.9.0.0 10.105.28.202add net 129.9.0.0: gateway 10.105.28.202 root@ts-007 # netstat -rnRouting Table: Destination Gateway Flags Ref Use Interface-------------------- -------------------- ----- ----- ------ ---------10.105.28.0 10.105.28.202 U 4 2 hme0129.9.0.0 10.105.28.202 UG 0 0 10.0.0.0 10.105.31.254 UG 0 0 224.0.0.0 10.105.28.202 U 4 0 hme0127.0.0.1 127.0.0.1 UH 0 313 lo0
NOTE
129.9.0.0 10.105.28.202 UG 0 0 is the newly-added routing record.
l Modify the routing table.root@ts-007 # route change 129.9.0.0 1.2.3.4change net 129.9.0.0: gateway 1.2.3.4
2 Operating System Commands Command Reference
2-60 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
root@ts-007 # netstat -rnRouting Table: Destination Gateway Flags Ref Use Interface-------------------- -------------------- ----- ----- ------ ---------10.105.28.0 10.105.28.202 U 4 2 hme0129.9.0.0 1.2.3.4 UG 0 0 10.0.0.0 10.105.31.254 UG 0 0 224.0.0.0 10.105.28.202 U 4 0 hme0127.0.0.1 127.0.0.1 UH 0 445 lo0
NOTE
129.9.0.0 1.2.3.4 UG 0 0 is the routing record of the modified gateway.
The example of running on the Linux operating systemUse the command netstat -rn to view the information about the routing tables:
root@ts-007 # netstat -rnRouting Table:Destination Gateway Flags Ref Use Interface10.105.28.0 10.105.28.202 U 4 2 hme010.0.0.0 10.105.31.254 UG 0 0 224.0.0.0 10.105.28.202 U 4 0 hme0127.0.0.1 127.0.0.1 UH 0 896 lo0
A router can be in any of the following five different flags: U, G, H, D, and M, as described inTable 2-23.
Table 2-23 Description of routing flags
Flag Description
U U indicates that a route is currently available.
G G indicates that a route is destined for a gateway such as a router.If this flag is not set, you can infer that the destination is connected directly.Flag G distinguishes between direct and indirect routes. Flag G is unnecessaryfor direct routes. The difference is that the packet sent through a direct routecarries both the destination IP address and the link-layer address. In the packetsent through an indirect route, however, the IP address points to the destinationand the link layer address points to the gateway (for example, the next router).
H H indicates a route destined for a host. That is, the destination address is acomplete host address.If this flag is not set, you can infer that the route leads to a network and thatthe destination address is a network address: either a network number or anetwork. The part in the address for the host is 0. When you search the routingtable for an IP address, the host address must exactly match the destinationaddress. The network address, however, is required to match only the networknumber and subnet number of the destination address.
D D indicates that a route is created by a redirected packet.
M M indicates that a route is modified by a redirected packet.
The Ref (Reference count) column lists the number of routing progresses. The protocol forconnection, such as TCP, requires a fixed route when a connection is established. If the telnet
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-61
connection is established between the host svr4 and the host slip, the Ref is 1. If another telnetconnection is established, its value is changed to 2.
The next column (Use) displays the number of packets sent through a specified route. After yourun the ping command as the unique user of this route, the program sends five groups and thenumber of packets is displayed as 5. The last column (Interface) indicates the name of thelocal interface.
The second row of the output is a loop-back interface. The interface name is permanent set tolo0. Flag G is not set because the route is not destined for a gateway. Flag H indicates that thedestination address, 127.0.0.1, is a host address and not a network address. Because flag G isnot set, the route here is a direct route and the gateway column shows the outgoing IP address.
Each host has one or multiple default routes. That is, if a particular route is not found in the table,the packet is sent to the router. In addition, the current host can access other systems throughthe Sun router (and the slip link) on the internet, based on the settings of the routing table. Theflag UG refers to the gateway.
2.8.7 telnetThis describes the functions, format, parameters, and example of the telnet command. Thetelnet command is used to log in to remote hosts through network connection. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
FunctionNOTE
Before running the telnet command, ensure that a local computer is connected to the remote host accordingto the TCP/IP protocol.
Telnet is the software used to log in to remote hosts through network connection. Telnet takesthe local computer as a simulated terminal of the remote host and enables you to log in to theremote server from the local computer. After you log in to the remote host successfully throughtelnet, you become a remote simulated terminal user and you can use the local computer as areal terminal. In this case, the resources and functions available and the operating mode dependon the settings of the remote host and the access privileges of the login account.
Command Formattelnet IP address or domain name
Parameter Descriptionl IP address: the IP address of a remote host
l Domain: the domain name of a remote host
ExampleRun the telnet command on a local computer and log in to a remote host. Assume that the IPaddress of the remote host is 129.9.169.143.
On the local computer, choose Start > Run. Enter telnet 129.9.169.143 and click OK. TheTelnet dialog box appears and prompts you to enter the user name and password of the remotehost.
2 Operating System Commands Command Reference
2-62 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
login: root
Password:root password
NOTE
Enter the password on the right of Password:. The entered password is not displayed.
The previous steps are the same as those when you operate on the host.
2.9 Other Common CommandsThis describes the functions of other common commands and provides some applicationexamples.
2.9.1 bcThis describes the function and example of the bc command. The command is only used on theSolaris operating system.
2.9.2 scriptThis describes the function, format, parameter options, and application examples of the scriptcommand. You use this command to record all the screen input and output in a script file. Youmust start recording the screen input and output after running the script command and endrecording them after running the exit command. The command is only used on the Solarisoperating system.
2.9.3 pkgaddThis describes the function, format, option, and example of the pkgadd command. The usage ofthe command is the same on the Solaris operating system and the Linux operating system.
2.9.4 pkgrmThis describes the function, format, and example of the pkgrm command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
2.9.1 bcThis describes the function and example of the bc command. The command is only used on theSolaris operating system.
FunctionThe bc command is used to perform a simple calculation.
ExampleTo multiply 4 by 5, run the following command:
# bc
4*5
20
NOTE
To get the result, run the bc command, and then press Enter. Type the formula 4*5, and then pressEnter. The result is displayed on the screen. Press Ctrl+D to exit from the bc program.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-63
2.9.2 scriptThis describes the function, format, parameter options, and application examples of the scriptcommand. You use this command to record all the screen input and output in a script file. Youmust start recording the screen input and output after running the script command and endrecording them after running the exit command. The command is only used on the Solarisoperating system.
Function
CAUTIONClose the script file before running the exit command to terminate the recording of the screenI/O. If you do not close the script file, the script file builds up and hinders the normal operationof the system.
Record in a script file all the screen input and output that occur from the time when the scriptcommand is run to the time when the exit command is entered. The script command is helpfulfor programming and debugging.
Formatscript option file
Option Description-a: appends the screen I/O content to a file. If you do not set this parameter, the screen I/Ooverwrites the content of the file.
Parameter Descriptionfile: the file used to save the screen I/O content. If you do not specify the file name, the screenI/O content is saved to the typescript file.
ExampleTo save the screen I/O content in the default destination file typescript, run the followingcommands:
# script
Script started, file is typescript
# ps
PID TTY TIME CMD 775 pts/8 0:00 ksh
# pwd
/export/home
# date
Mon Feb 4 19:12:14 GMT 2002
2 Operating System Commands Command Reference
2-64 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
# exit
Script done, file is typescript
To view the content of the typescript file, run the following command:
# cat typescript
Script started on Mon Feb 04 19:11:49 2002$ ps PID TTY TIME CMD 775 pts/8 0:00 ksh$ pwd/export/home$ dateMon Feb 4 19:12:14 GMT 2002$ exitscript done on Mon Feb 04 19:12:24 2002
2.9.3 pkgaddThis describes the function, format, option, and example of the pkgadd command. The usage ofthe command is the same on the Solaris operating system and the Linux operating system.
Function
The pkgadd command is used to send a file package to the system for execution. To remove apackage from the system, run the pkgrm command.
Command Format
pkgadd option file package name
Option Description
-d device: to install or copy a package from the device. The device can be an absolute path, theidentifier of a tape, or a disk such as /var/tmp or /floppy/floppy_name, or a device name suchas /floppy/floppy0.
Example
To send a file package in the current folder to the file1 file, run the following command:
# pkgadd -d . file1
The dot in the command indicates that the folder is the current folder.
2.9.4 pkgrmThis describes the function, format, and example of the pkgrm command. The usage of thecommand is the same on the Solaris operating system and the Linux operating system.
Function
The pkgrm command is used to remove a package from the system. To pack and send a packageto the system, use the pkgadd command.
Command Reference 2 Operating System Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
2-65
Command Formatpkgrm option file package name
ExampleTo remove the file1 file, run the following command:
# pkgrm file1
2 Operating System Commands Command Reference
2-66 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
3 Summary of Commonly Used ClusterCommands
This describes the common maintenance commands of the Cluster 3.0.
Table 3-1 Common maintenance commands of the Cluster3.0
Command Description
scstat Check the Cluster status.
scstat -g Check the status of a resource group.
scrgadm -a -g oss_rg Create the resource group oss_rg.
scrgadm -r -g oss_rg Delete the resource group oss_rg.
scrgadm -a -g oss_rg -h osssvr-1,osssvr-2 Register osssvr-1 and osssvr-2 to theresource group oss_rg.
scrgadm -a -L -g oss_rg -l osssvr Register the logical host osssvr to theresource group oss_rg.
scrgadm -a -j ossdg_rs -g oss_rg -tSUNW.HAStoragePlus -xFilesystemMountPoints=data,/export/home
Register the volume group ossdg_rg-t andmounting point data,/export/home to theresource group oss_rg.
scrgadm -a -t HW.M2000 Register the resource type HW.M2000 inthe Sun Cluster 3.0. The link file namedHW.M2000 must be created in the /usr/cluster/lib/rgm/rtreg folder.
scrgadm -r -t HW.M2000 Delete the resource type HW.M2000 .
scrgadm -a -j ossapp_rs -t HW.M2000 -goss_rg
Add the resource ossapp_rs of theHW.M2000 type to the resource grouposs_rg.
scrgadm -r -j sybase_rs Delete the resource sybase_rs.
Command Reference 3 Summary of Commonly Used Cluster Commands
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
3-1
Command Description
scswitch -Z -g oss_rg Start all resources in the resource grouposs_rg, including the resourcesdeactivated by scswitch -n -j.
scswitch -F -g oss_rg Close the resource group oss_rg.
scswitch -z -g oss_rg -h osssvr-1 Start the resource group oss_rg on thehost osssvr-1.
scswitch -S -h osssvr-1 Set the disk device group and resourcegroup to offline state at the osssvr-1 node.If the disk device group at the osssvr-1node is online, the disk device group isswitched to the osssvr-2 node after yourun the command. If both the disk devicegroup and resource group at the osssvr-1node are online, they are switched to theosssvr-2 node after you run the command.
scswitch -e -j sybase_rs Activate the resource sybase_rs andenable the Cluster monitoring over theSybase.
scswitch -n -j sybase_rs Deactivate the resource sybase_rs andstop the Cluster monitoring over theSybase.
NOTE
l After you run the command scswitch -S -h nodename, all online resource groups are switched to thetarget PC. The offline resource groups on the original host remain offline on the target PC.
l After you run the command scswitch -z -g rgname -h nodename, the resource group rgname isswitched to the target PC.
3 Summary of Commonly Used Cluster Commands Command Reference
3-2 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
4 Common Commands and Parameters of theVeritas Cluster
This describes the common commands and parameters of the Veritas Cluster.
Table 4-1 Common maintenance commands of the VCS
Command Meaning Example
hastart Starts the VCS.NOTE
After you run the command on acertain node, the VCS service isstarted on this node. The nic_rsresource is automatically started atthe same time. If this node servesas the active node, the otherresources of the oss_sg resourcegroup are also automaticallystarted.
hastart
hastop -all Stops the VCS.NOTE
After you run the command, allresources in the HA system and theVCS service are stopped.Therefore, run the command withcaution.
hastop -all
hastop -all -force Forcibly stops the VCS. If youfail to stop the VCS by runningthe hastop -all command, youneed to use this command toforcibly stop the VCS.
hastop -all -force
/opt/VRTSvcs/bin/hahb -add hb
Adds a heartbeat link. /opt/VRTSvcs/bin/hahb -addIcmpS
/opt/VRTSvcs/bin/hahb -deletehb
Deletes a heartbeat link. /opt/VRTSvcs/bin/hahb -deleteIcmpS
Command Reference 4 Common Commands and Parameters of the Veritas Cluster
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
4-1
Command Meaning Example
/opt/VRTSvcs/bin/hahb -display
Displays the detailedinformation about a heartbeatlink.
/opt/VRTSvcs/bin/hahb -display
/opt/VRTSvcs/bin/hahb -state hb
Displays the status of aheartbeat link.
/opt/VRTSvcs/bin/hahb -stateIcmpS
/opt/VRTSvcs/bin/hahb -list
Lists the information about aheartbeat link.
/opt/VRTSvcs/bin/hahb -list
/opt/VRTSvcs/bin/hahb -modifyhb attr value
Modifies the parameters of aheartbeat link.
/opt/VRTSvcs/bin/hahb -modifyIcmpS Arguments 10.10.10.31 -clus osscluster-2
hagrp -add group Adds a resource group. hagrp -add OssService
hagrp -deletegroup
Deletes a resource group. hagrp -delete OssService
hagrp -link parentgroup child groupdependency
Sets the dependency betweenresource groups.
hagrp -link OssServiceRvgService dependency
hagrp -unlinkparent group childgroup
Deletes the dependencybetween resource groups.
hagrp -unlink OssServiceRvgService
hagrp -clear group Clears the fault state and no-persistent state of each resourcein a resource group.
hagrp -clear OssService
hagrp -clearadminwaitgroup -sys system
Clears the ADMIN_WAITstate of each resource in aresource group.
hagrp -clearadminwaitOssService -sys osssvr-2
hagrp -flushgroup -sys system
When a resource in a resourcegroup is blocked due to anexception during the online oroffline process, you can run thiscommand to stop the online oroffline process and set theresource to the to-be-startedstate or the stopped state.
hagrp -flush OssService -sysosssvr-1
hagrp -onlinegroup -sys system
Starts a resource group. hagrp -online OssService -sysosssvr-1
hagrp -offlinegroup -sys system
Stops a resource group. hagrp -offline OssService -sysosssvr-1
hagrp -switchgroup -to system
Switches a resource group. hagrp -switch OssService -toosssvr-1
hagrp -freezegroup -persistent
Freezes a resource grouppermanently.
hagrp -freeze OssService -persistent
4 Common Commands and Parameters of the Veritas Cluster Command Reference
4-2 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Meaning Example
hagrp -unfreezegroup -persistent
Unfreezes a permanently frozenresource group.
hagrp -unfreeze OssService -persistent
hagrp -freezegroup
Freezes a resource grouptemporarily.NOTE
A temporarily frozen resourcegroup is unfrozen after the VCS isrestarted.
hagrp -freeze OssService
hagrp -unfreezegroup
Unfreezes a temporarily frozenresource group.
hagrp -unfreeze OssService
hagrp -enablegroup
Activates a resource group. Aresource group can be startedonly after it is activated.
hagrp -enable OssService
hagrp -disablegroup
Disables a resource group. Aresource group cannot bestarted after it is disabled.
hagrp -disable OssService
hagrp -enableresourcesgroup
Activates all the resources in aresource group.
hagrp -enableresourcesOssService
hagrp -disableresourcesgroup
Disables all the resources in aresource group.
hagrp -disableresourcesOssService
hagrp -display Displays the detailedinformation about a resourcegroup.
hagrp -display
hagrp -state Displays the status of a resourcegroup.
hagrp -state
hagrp -list Lists the names of resourcegroups.
hagrp -list
hagrp -valuegroup attr
Displays the values of theparameters of a resource group.
hagrp -value RvgService Probed
hagrp -dep Displays the dependencybetween resource groups.
hagrp -dep
hagrp -resourcesgroup
Displays the resources of aresource group.
hagrp -resources OssService
hares -add restype group
Adds a resource. hares -add oss_app ApplicationOssService
hares -delete res Deletes a resource. hares -delete oss_app
hares -link parentres child res
Sets the dependency betweenresources.
hares -link oss_apposs_sybase_back
Command Reference 4 Common Commands and Parameters of the Veritas Cluster
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
4-3
Command Meaning Example
hares -unlinkparent res child res
Deletes the dependencybetween resources.
hares -unlink oss_apposs_sybase_back
hares -clear res Clears the alarms of a resource. hares -clear oss_app
hares -online res -sys system
Starts a resource. hares -online oss_app -sys osssvr-1
hares -online -force res -syssystem
Starts a resource forcibly. hares -online -force oss_app -sysosssvr-1
hares -offline res -sys system
Stops a resource. hares -offline oss_app -sys osssvr-1
hares -probe res -sys system
Monitors the status of aresource.
hares -probe oss_app -sys osssvr-1
hares -dep Displays the dependencybetween resources.
hares -dep
hares -display res Displays the detailedinformation about a resource.
hares -display oss_app
hares -state res Displays the status of aresource.
hares -state oss_app
hares -list Lists the names of resources. hares -list
hares -value resattr
Displays the values of theparameters of a resource.
hares -value oss_app Type
4 Common Commands and Parameters of the Veritas Cluster Command Reference
4-4 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
5 Common VVR Commands and Parameters
The following table describes the common VVR commands and parameters.
Table 5-1 Common VVR commands and parameters
Command Meaning Example
vradmin -g diskgroupcreatepri rvg_namedv01_name,dv02_name... srl_name
Creates the active node inan RVG.
vradmin -g ossdg createpriossrvgexportsync,fmdb_data_lv001,fmdb_data_lv002 srl
vradmin -g diskgroupaddsec local_rvgnamepri_hostnamesec_hostname
Adds the standby node inthe created RVG.
vradmin -g ossdg addsec ossrvg192.168.8.20 192.168.8.22
vradmin -g diskgroupchangeip local_rvgnameattrs....
Changes the IP address ofan active or a standbyreplication link.
vradmin -g ossdg changeip ossrvgnewpri=10.10.10.30newsec=10.10.10.31
vradmin -g diskgroup -lrepstatuslocal_rvgname
Displays the replicationrelation of an RVG.
vradmin -g ossdg -l repstatusossrvg
vradmin -l printrvg Displays the informationabout the active andstandby nodes in an RVG.
vradmin -l printrvg
vradmin -g diskgroup -lprintrvg local_rvgname
Displays the informationabout the active andstandby nodes in aspecified RVG.
vradmin -g ossdg -l printrvgossrvg
vradmin printvol Displays the volumeinformation in an RVG.
vradmin printvol
vradmin -g diskgroupprintvol local_rvgname
Displays the volumeinformation in a specifiedRVG.
vradmin -g ossdg printvol ossrvg
Command Reference 5 Common VVR Commands and Parameters
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
5-1
Command Meaning Example
vradmin -g diskgrouppausereplocal_rvgnamesec_hostname
Pauses thesynchronization of data tothe standby node.
vradmin -g ossdg pauserep ossrvg192.168.8.22
vradmin -g diskgroupresumereplocal_rvgnamesec_hostname
Resumes thesynchronization of data tothe standby node.
vradmin -g ossdg resumerepossrvg 192.168.8.22
vradmin -g diskgroup -astartrep local_rvgnamesec_hostname
Uses automaticsynchronization tosynchronize data to thestandby node and establishthe replication link.
vradmin -g ossdg -a startrepossrvg 192.168.8.22
vradmin -g diskgroupstoprep local_rvgnamesec_hostname
Stops copying data to thestandby node.
vradmin -g ossdg stoprep ossrvg192.168.8.22
vradmin -g diskgroupsyncrvg local_rvgnamesec_hostname....
Compares the data basedon the volumes, and thensynchronizes the differentdata to the standby nodebased on the RVGs.
vradmin -g ossdg syncrvg ossrvg192.168.8.22
vradmin -g diskgroupsyncvol local_vols_listremote_hostname....
Compares the data basedon the volumes, and thensynchronizes the differentdata in a specified volumeto the standby node.
vradmin -g ossdg syncvolexportsync,fmdb_data_lv001,fmdb_data_lv002 192.168.8.22
vradmin -g diskgroup -verify syncrvglocal_rvgnamesec_hostname…
Checks the datadifferences between thesynchronization volumesof the active and standbynodes, and then generatesa report.
vradmin -g ossdg -verify syncrvgossrvg 192.168.8.22
vradmin -g diskgroupaddvol local_rvgnamevolume_name
Adds a specified volumeto an RVG.
vradmin -g ossdg addvol ossrvgoss_v1
vradmin -g diskgroupdelvol local_rvgnamevolume_name
Deletes a specifiedvolume from an RVG.
vradmin -g ossdg delvol ossrvgoss_v1
5 Common VVR Commands and Parameters Command Reference
5-2 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Meaning Example
vradmin -g diskgroupmigrate local_rvgnamenewprimary_name
Switches the replicationrelation between the activeand standby nodes. Afterthe switchover, theoriginal active nodebecomes the new standbynode and the originalstandby node becomes thenew active node. Inaddition, the datasynchronization directionchanges.
vradmin -g ossdg migrate ossrvg192.168.8.22
vradmin -g diskgrouptakeover local_rvgname
Takes over the Primaryrole of the original activenode and enables the fastfailback function.
vradmin -g ossdg takeover ossrvg
vradmin -g diskgroup -autofb takeoverlocal_rvgname
Takes over the primaryrole of the original activenode, enables the fastfailback function, andautomaticallysynchronizes data to theoriginal active node afterthe original active node isavailable.
vradmin -g ossdg -autofbtakeover ossrvg
vradmin -g diskgroup -Ntakeover local_rvgname
Switches the standby nodeto the active node for datareplication, while the fastfailback function is notenabled.
vradmin -g ossdg -N takeoverossrvg
vradmin -g diskgroupfbsync local_rvgname
Switches the originalactive node to the standbynode and uses the fastfailback function tosynchronize data from thenew active node.
vradmin -g ossdg fbsync ossrvg
vradmin -g diskgroup -wait fbsynclocal_rvgname
Switches the originalactive node to the standbynode and uses the fastfailback function tosynchronize data from thenew active node. Thesystem returns to thecommand line interfacefor the next commandafter the synchronizationis complete.
vradmin -g ossdg -wait fbsyncossrvg
Command Reference 5 Common VVR Commands and Parameters
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
5-3
Command Meaning Example
vradmin -g diskgroupmakesec local_rvgnamenewprimary_name
Switches the originalactive node to the standbynode when the fastfailback function is notenabled.
vradmin -g ossdg makesec ossrvg192.168.8.22
vradmin -g diskgroupdelsec local_rvgnamesec_hostname
Deletes the standby nodefrom an RVG.
vradmin -g ossdg delsec ossrvg192.168.8.22
vradmin -g diskgroupdelpri rvg_name
Deletes the active nodefrom an RVG before theapplication runs.
vradmin -g ossdg delpri ossrvg
vradmin -g diskgroup -fdelpri rvg_name
Deletes the active nodeforcibly from an RVGafter the application runs.
vradmin -g ossdg -f delpri ossrvg
vxrvg -g diskgroup -lgetdatavols rvg_name
Displays the informationabout all the volumesassigned to a specifiedRVG.
vxrvg -g ossdg -l getdatavolsossrvg
vxrvg -g diskgroupgetrlinks rvg_name
Displays the informationabout all the links assignedto a specified RVG.
vxrvg -g ossdg getrlinks ossrvg
vxrvg -g diskgroupstart rvg_name
Starts the I/O access to thevolumes in a specifiedRVG.
vxrvg -g ossdg start ossrvg
vxrvg -g diskgroup stoprvg_name
Stops the I/O access to thevolumes in a specifiedRVG.
vxrvg -g ossdg stop ossrvg
vxrvg -g diskgrouprecover rvg_name
Resumes the operation ofan RVG after the nodes arerestarted.
vxrvg -g ossdg recover ossrvg
vxrvg -g diskgroupcheckend rvg_name
Sets the current position ofthe SRL to the check endpoint on the active node.
vxrvg -g ossdg checkend ossrvg
vxrvg -g diskgroupcplist rvg_name
Displays all the checkpoints existing in aspecified RVG.
vxrvg -g ossdg cplist ossrvg
vxrvg -g diskgroup statsrvg_name
Displays the statistics ofthe application of aspecified RVG. Thiscommand can be executedonly on the active node.
vxrvg -g ossdg stats ossrvg
5 Common VVR Commands and Parameters Command Reference
5-4 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)
Command Meaning Example
vxrlink -g diskgroupassoc rvg_namerlink_name
Assigns a replication linkto an RVG.
vxrlink -g ossdg assoc ossrvgto_secondary
vxrlink -g diskgroup disrlink_name
Deletes a replication linkfrom an RVG.
vxrlink -g ossdg dis to_secondary
vxrlink -g diskgroup -aatt rlink_name
Uses the auto attach modeto set a replication link tothe connected state.
vxrlink -g ossdg -a attto_secondary
vxrlink -g diskgroup -fatt rlink_name
Uses the force attachmethod to set a replicationlink to the connected state.
vxrlink -g ossdg -f attto_secondary
vxrlink -g diskgroupdet rlink_name
Sets a replication link tothe disconnected state.
vxrlink -g ossdg det to_secondary
vxrlink -g diskgrouppause rlink_name
Pauses thesynchronization of data tothe standby node througha specified replicationlink.
vxrlink -g ossdg pauseto_secondary
vxrlink -g diskgroupresume rlink_name
Resumes thesynchronization of data tothe standby node througha specified replicationlink.
vxrlink -g ossdg resumeto_secondary
vxrlink -g diskgrouprecover rlink_name
Recovers a replication linkafter the nodes arerestarted.
vxrlink -g ossdg recoverto_secondary
vxrlink -g diskgroupverify rlink_name
Displays the configurationstatus of a specified link.
vxrlink -g ossdg verifyto_secondary
vxrlink -g diskgroup -estats rlink_name
Displays the usage statusof a specified link.
vxrlink -g ossdg -e statsto_secondary
vxrlink -g diskgroupstatus rlink_name
Displays the SRL spaceoccupied by a specifiedlink, and the remainingdata of the standby nodethat needs to besynchronized.
vxrlink -g ossdg statusto_secondary
vxprint -V Displays all the RVGs. vxprint -V
vxprint -P Displays all theRLINKGS.
vxprint -P
Command Reference 5 Common VVR Commands and Parameters
Issue 02 (2009-10-31) Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
5-5
Command Meaning Example
vxmake -g diskgrouprlink rlink_nameprotocol=protocol_nameremote_host=sec_hostnameremote_rlink=rlink_name
Uses a specified networktransport protocol tocreate a replication link.The value of theprotocol_name parametercan be set to TCP or UDP.
vxmake -g ossdg rlinkto_secondary protocol=UDPremote_host=192.168.8.22remote_rlink=to_secondary
vxmemstat Displays the usagestatistics of the memory ofthe Veritas VolumeManager.
vxmemstat
vrport Manages the ports of theVVR.
vrport
vrnotify -g diskgroup Displays the eventnotifications of the VVR.
vrnotify -g diskgroup
vxedit -g diskgroup setprotocol=protocol_namerlink_name
Selects a networktransport protocol. Youcan select the TCP or UDPprotocol.
vxedit -g ossdg set protocol=UDPto_secondary
5 Common VVR Commands and Parameters Command Reference
5-6 Huawei Proprietary and ConfidentialCopyright © Huawei Technologies Co., Ltd.
Issue 02 (2009-10-31)