sethostname(2)sethostname(2)NAMEsethostname() - set name of current host system
The system call sets the name of the current system to name, which has
a length of namelen characters. At system boot time is normally exe‐
cuted by the command (see hostname(1)) in the script. Host names are
limited to characters, as defined in
Prior to ContainmentExt B.11.31.03, the actions associated with this
system call require the privilege If ContainmentExt B.11.31.03 or a
later version of HP-UX Containment product is installed on the system,
either the privilege or the privilege is required. Processes owned by
the superuser have this privilege. Processes owned by other users may
have this privilege, depending on system configuration.
See privileges(5) for more information about privileged access on sys‐
tems that support fine-grained privileges.
returns the following values:
is set to indicate the error.
If fails, is set to one of the following values.
name points to an illegal address. The reliable
detection of this error is implementation depen‐
The user does not have appropriate privileges.
Setting a hostname of more than 64 bytes with is possible only with the
appropriate configuration options enabled (see nodehostnamesize(5)).
It is strongly recommended that all related documentation be completely
understood before setting a larger hostname. A hostname larger than 64
bytes can cause anomalous behavior or failure in applications which use
the command or the system function to obtain the name.
was developed by the University of California, Berkeley.
SEE ALSOhostname(1), uname(1), gethostname(2), uname(2), nodehostnamesize(5),