Introduction : You can use the hostnamectl command to see or set the system’s host name. The host name or computer name is usually at system startup in /etc/hostname file. Open the terminal application and type the following commands to set or change hostname or computer name on Ubuntu Linux.
Ubuntu set hostname permanently (computer name) command
The procedure to change hostname is as follows on Ubuntu:
- Open the terminal application
- Login to remote Ubuntu server using the ssh user@server-ip-here
- To change hostname (Computer Name) in Ubuntu type: hostnamectl set-hostname wsl-us-west2-www1
- Verify new change by typing hostnamectl
Let us see all commands in details.
How to find current hostname on Ubuntu
Type the following hostnamectl command
$ hostnamectl
Ubuntu change hostname permanently
Simply type the following command:
$ sudo hostnamectl set-hostname wsl-us-west2-www1
Verify new changes with the following command:
$ hostnamectl
One can use the cat command too:
$ cat /etc/hostname
Do I need to reboot my Ubuntu VM to change take effect?
No. You do not need to reboot the Linux box. Just log in again using the ssh command and your PS1 (bash shell prompt) will be updated too:
$ ssh vivek@aws-server-ip-here
Conclusion
You learned how to use the hostnamectl command to query and change the Ubuntu system hostname and related settings.
- Ubuntu Linux Change Hostname (computer name)
- Debian Linux: Change Hostname / Computer Name Permanently
- Linux change my hostname / computer system name
- Linux Change Hostname
- RHEL / Centos Linux 7: Change and Set Hostname Command
- OpenBSD Change Hostname
- CentOS Linux 5/6 Change Hostname Command
- Linux setting hostname and domain name of my server
- FreeBSD Change Hostname without reboot
- SuSe Linux Change Hostname without reboot
- How to set the hostname on Fedora Linux
- Ubuntu 18.04 LTS change hostname permanently
- Ubuntu set hostname permanently (computer name) command
- OpenSUSE Linux set hostname permanently (computer name) command
- RHEL 8 Linux set hostname permanently (computer name) command
How to change hostname in Ubuntu 18.04 LTS server?
hostnamectl set-hostname "your-name-here"