/go/hostname: hostname from the Command Line

/go/hostname changes the server's hostname, such as server.example.com, and updates everything in GoAdmio that depends on it. It: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Change the hostname (run as root)
/go/hostname server.example.com

Create the DNS record first. The name must already point to this server’s IPv4 address.

Arguments

Argument Effect
<hostname> Changes the hostname to this name.
restore Changes the hostname to the name stored in /etc/hostname.bak.
(none) Asks for the hostname, with the current one filled in for you to edit.

The hostname must contain at least two dots, for example server.example.com. A name such as example.com is rejected.

The command does not create /etc/hostname.bak. restore works only when that file already exists.

Examples

# Change the hostname
/go/hostname server.example.com

# Use a name that starts with smtp. so that an imap. name is set up too
/go/hostname smtp.example.com

# Check that the name points to this server before you run the command
dig +short server.example.com

# Review the log of past runs
tail -n 20 /var/log/go/hostname.log

Output

Message Meaning
Invalid Server Hostname, A hostname should consist of a name and a domain name. All valid hostnames should have 2 dots in them. The name has fewer than two dots. Exit status 1.
Failed to change server hostname. Hostname <name> Not Resolving To <ip> The name’s DNS does not point to this server’s IPv4 address. Nothing is changed. Exit status 1.
Hostname changed to <name> The hostname, /etc/hosts, and the configuration were updated. The remaining steps follow.

See the full reference at /go/hostname and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *