chservices Command
Purpose
Changes the contents of the /etc/services file.
Syntax
To Add or Activate an Entry:
chservices [ -a ] -v ServiceName -p protocol -n port [ -u "Alias ..." ]
To Change an Entry:
chservices -c -v ServiceName -p protocol -n port [ -V NewServiceName ] [ -P NewProtocol ] [ -N NewPort ] [ -u "Alias ..." ]
To Deactivate an Entry:
chservices -d -v ServiceName -p protocol -n port [ -V NewServiceName ] [ -u Alias ..." ]
Description
The chservices command adds, deletes, or changes entries in the /etc/services file. These entries are related to known services used in the DARPA Internet and also related to information used by the inetd server. The entries for the inetd server determine how the system handles Internet service requests.
The chservices command manipulates the following entries for known services:
- The official Internet service name specified by the ServiceName variable.
- The port number, specified by the port variable, used for the service.
- The transport protocol, specified by the protocol variable, used for the service.
- A list of unofficial names, specified by the Alias variable, used by the service.
Flags
Item | Description |
---|---|
-a | Adds or activates an entry in the /etc/services file. If the requested service exists in the file, the -a flag uncomments the line. If the line does not exist, the -a flag adds the line to the file. This is the default action. |
-c | Changes an entry in the /etc/services file. |
-d | Deactivates an entry in the /etc/services file by commenting the line in the file. |
-N NewPort | Specifies a socket port number. |
-n port | Specifies a socket port number. |
-P NewProtocol | Specifies a new protocol name for a current protocol name. |
-p protocol | Specifies the protocol. |
-V NewName | Specifies a new service name. |
-v ServiceName | Specifies the service name. |
-u "Alias..." | Specifies a list of aliases. |
Note: Adding or keeping comments on lines modified with the chservices command is not supported.
Security
Access Control: Only the root user and members of the system group have access to this command.
Examples
- To add the service, gregsapp,
as a udp service on port 1423, enter:
chservices -a -v gregsapp -p udp -n 1423
- To add the service, gregsapp,
as a udp service on port 1423 with an alias of fredsapp,
enter:
chservices -a -v gregsapp -p udp -n 1423 -u "fredsapp"
- To change the port
of the service specified as gregsapp with a udp protocol
to 1456, enter:
chservices -c -v gregsapp -p udp -N 1456
- To deactivate the gregsapp service
on udp port 1456 by commenting it out, enter:
chservices -d -v gregsapp -p udp -n 1456
Files
Item | Description |
---|---|
/usr/sbin/chservices | Contains the chservices command. |
/etc/services | Contains services information for the inetd daemon. |