La commande 'chservices' permet de gérer les entrées contenues dans le fichier '/etc/services'.

Les syntaxes sont les suivantes :

POur ajouter ou activer une entrée :

chservices [  -a -v ServiceName -p protocol -n port [  -u "Alias ...]

Pour modifier une entrée:

chservices -c -v ServiceName -p protocol -n port [  -V NewServiceName ] [  -P NewProtocol ] [  -N NewPort ] [  -u "Alias ...]

POur désactiver une entrée:

chservices -d -v ServiceName -p protocol -n port [  -V NewServiceName ] [  -u Alias ...]

 

Quelques exemples simples :

  1. Pour ajouter le service 'gregsapp' comme service UDP sur port 1423, entrer :
    chservices -a -v gregsapp -p udp -n 1423 
  2. Pour ajouter le service 'gregsapp' comme service UDP sur port 1423, avec un alias 'fredsapp', entrer:
    chservices -a -v gregsapp -p udp -n 1423 -u "fredsapp"
  3. Pour modifier le port du service 'grepsapp' avec protocole UDP vers le port 1456, entrer :
    chservices -c -v gregsapp -p udp -N 1456
  4. Pour désactiver le service grepsapp sur port UDP 1456 en le mettant en commentaire,taper :
    chservices -d -v gregsapp -p udp -n 1456


    La syntaxte officielle en Version 6.1 d'AIX d'IBM est donnée ci-dessous:

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

ItemDescription
-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

  1. To add the service, gregsapp, as a udp service on port 1423, enter:
    chservices -a -v gregsapp -p udp -n 1423 
  2. 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"
  3. 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
  4. To deactivate the gregsapp service on udp port 1456 by commenting it out, enter:
    chservices -d -v gregsapp -p udp -n 1456

Files

ItemDescription
/usr/sbin/chservices Contains the chservices command.
/etc/services Contains services information for the inetddaemon.
icon phone
Téléphone/Whatsapp : +33 (0)6 83 84 85 74
icon phone