---
name: "sge_hostnameutils"
section: "1"
platform: "linux"
package: "gridengine-common"
version: "8.1.9+dfsg-13.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sge_hostnameutils"
---

# sge\_hostnameutils(1)

get local host information

## NAME

gethostname, gethostbyname, gethostbyaddr, getservbyname - get local host information

## SYNTAX

**$SGE\_ROOT/utilbin/$ARCH/gethostname** \[**-help**\|**-name**\|**-aname**\|**-all**\]

**$SGE\_ROOT/utilbin/$ARCH/gethostbyname** \[**-help**\|**-name**\|**-aname**\|**-all**\] *name*

**$SGE\_ROOT/utilbin/$ARCH/gethostbyaddr** \[**-help**\|**-name**\|**-aname**\|**-all**\] *ip*

**$SGE\_ROOT/utilbin/$ARCH/getservbyname** \[**-help**\|**-number**\] *service*

## DESCRIPTION

*gethostname* and *gethostbyname* are used to get the local resolved host name. *gethostbyaddr* is used to get the hostname of a specified IP address (dotted decimal notation). *getservbyname* can be used to get the configured port number of a service (e.g. from /etc/services).

The hostname utils are primarily used by the Grid Engine installation scripts. *gethostname* , *gethostbyname* and *gethostbyaddr* called without any option will print out the hostname, all specified aliases, and the IP address of the locally resolved hostname. Calling *getservbyname* without any option will print out the full service entry.

## OPTIONS

### -help

Prints a list of all options.

### -name

This option only reports the primary name of the host.

### -aname

If this option is set, the Grid Engine host alias file is used for host name resolving. It is necessary to set the environment variable SGE\_ROOT and, if more than one cell is defined, also SGE\_CELL.

This option will print out the Grid Engine host name.

### -all

By using the **-all** option all available host information will be printed. This information includes the host name, the Grid Engine host name, all host aliases,  and the IP address of the host.

### -number

This option will print out the port number of the specified service name.

### \<name\>

The host name for which the information is requested.

### \<ip\>

The IP address (dotted decimal notation) for which the information is requested.

### \<service\>

The service name for which the information is requested (e.g. ftp, sge\_qmaster or sge\_execd).

## EXAMPLES

The following example shows how to get the port number of the FTP service:

```
>/opt/sge/default/lx-amd64/getservbyname -number ftp
21
```

The next example shows the output of  **gethostname -all** when the host alias file contains this line:

gridmaster extern\_name extern\_name.mydomain

The local host resolving must also provide the alias name "gridmaster". Each Grid Engine host that wants to use the cluster must be able to resolve the host name "gridmaster".

To setup an alias name, edit your /etc/hosts file or modify your NIS setup to provide the alias for the NIS clients.

The host alias file must be readable from each host (use e.g. NFS shared file location).

```
>/opt/sge/default/lx-amd64/gethostname -all
Hostname: extern_name.mydomain
SGE name: gridmaster
Aliases:  loghost gridmaster
Host Address(es): 192.168.143.99
```

## ENVIRONMENT VARIABLES

- **SGE\_ROOT**

  Specifies the location of the Grid Engine standard configuration files.

- **SGE\_CELL**

  If set, specifies the default Grid Engine cell.

## SEE ALSO

[*sge\_intro*(1)](/sge_intro/1.md), *host\_aliases*(5),

## COPYRIGHT

See [*sge\_intro*(1)](/sge_intro/1.md) for a full statement of rights and permissions.
