Site icon TechGit

How to Change Computer Name (hostname) in Ubuntu 22.10 without Restart

This simple tutorial shows how to change the computer name (aka hostname) in your Ubuntu 22.10 Kinetic Kudu without a system restart.

The methods here are universal ways that works in not only default Ubuntu release but also its flavors (e.g., KUbuntu, XUbuntu), and even other Linux.

NOTE: A hostname can be a single word or phrase, including letters, number, periods, or hyphen with 253 characters length limit, with NO space.

Change Computer Name for Temporary Use

If possible to change the name for temporary use. So, the new name will work until you restart the system.

Replace ‘NEW_NAME_HERE’ and type user password (no asterisk feedback) to authenticate. And, you may need to restart terminal or console to see effect.

Change Computer Name by Editing Config file

The classic way to permanently change your system hostname is just edit the configuration file!

Ubuntu 22.10 switched to Gnome Text Editor instead of Gedit. The new editor however does NOT open files via sudo command from terminal, due to either bug or design issue.

So, here I’m going to use the universal nano command line text editor to open the configuration file.

When file opens in terminal, delete the old name and type a new one. Finally, press Ctrl+X, type y and hit Enter to save change.

This method however need a system restart if you’re running with default Wayland session. If you switched back Xorg session, run the command below to make it work without restart.

sudo systemctl restart systemd-logind.service

Use ‘hostnamectl’ to change computer name

The hostnamectl command is a good choice today to permanently change your computer name without system start.

The change takes effect immediately, though you may need to restart terminal window.

Use new name in ‘/etc/hosts’

To avoid network issues, it’s HIGHLY recommend to also edit ‘/etc/hosts’ and replace all old names with new ones.

When file opens in terminal, delete all the old hostname and insert the new name you set. Also, press Ctrl+X, type y and hit Enter to save change.

Original Article

FacebookTwitterTumblrRedditLinkedInHacker NewsDiggBufferGoogle ClassroomThreadsXINGShare
Exit mobile version