In Ubuntu 10.04 (Lucid Lynx), the /etc/hostname
file should typically contain only the short hostname of the system, not the fully-qualified domain name (FQDN). This follows the traditional Unix convention where the hostname file stores just the machine's name.
The distinction between these is important:
# Correct (short hostname): webserver # Incorrect (FQDN): webserver.example.com
The FQDN should be properly configured in these files:
/etc/hosts
- Should contain entries mapping IPs to both short and FQDN- DNS configuration - Should have proper forward and reverse records
Example /etc/hosts
entry:
127.0.0.1 localhost 192.168.1.10 webserver.example.com webserver
To check and modify the hostname:
# View current hostname hostname hostname -f # shows FQDN # Temporarily change hostname sudo hostname newname # Permanently change hostname (edit /etc/hostname) sudo nano /etc/hostname # For immediate effect after editing sudo /etc/init.d/hostname restart
Using FQDN in /etc/hostname
might cause problems with:
- Certain services that expect only the short name
- Some configuration tools and scripts
- Logging systems
In some enterprise environments, you might need to configure /etc/hosts
differently:
# For multi-homed systems 192.168.1.10 webserver.example.com webserver 10.0.0.10 webserver.internal.example.com webserver-int
Stick to the standard practice of using only the short hostname in /etc/hostname
for Ubuntu 10.04. The FQDN belongs in other configuration files and DNS records.
In Ubuntu 10.04 (Lucid Lynx), the /etc/hostname
file serves as the system's hostname configuration. This plain text file contains a single line specifying the machine's name. The traditional approach recommends using just the short hostname (e.g., "webserver") rather than the Fully Qualified Domain Name (FQDN, e.g., "webserver.example.com").
Ubuntu's official documentation for 10.04 clearly states:
# Recommended format for /etc/hostname hostname
Not:
# Not recommended format hostname.domain.tld
While the system might work with an FQDN in /etc/hostname
, several components could malfunction:
- Some services may improperly parse the hostname
- System initialization scripts might behave unexpectedly
- Certain network utilities could generate incorrect output
For a server named "mail" in domain "example.com", the correct setup would be:
# /etc/hostname contents: mail # /etc/hosts contents: 127.0.0.1 localhost 192.168.1.10 mail.example.com mail
To check your current hostname settings:
# View system hostname hostname # View FQDN (requires proper DNS or hosts file) hostname -f # Check all name resolutions getent hosts $(hostname)
To change the hostname properly:
# Edit the hostname file sudo nano /etc/hostname # Update hosts file sudo nano /etc/hosts # Apply changes without reboot sudo hostname $(cat /etc/hostname) sudo service hostname start
If you encounter problems after changing hostname:
- Verify both
/etc/hostname
and/etc/hosts
are consistent - Restart affected services:
sudo service networking restart
- Check syslog for errors:
grep hostname /var/log/syslog