Tips & Tricks: Change Linux Computer Name

I recently ran into a situation where I wanted to change the computer name on my Linux box to meet a certain naming scheme but couldn't remember for the life of me where and how to do it. This guide will hopefully save you the few minutes it took me poking around my machine trying to find it.

In a terminal window open up the 'hostname' and 'hosts' file in your favourite text editor (vim). In my case because I'm running Mint Linux I also use sudo:

f......@hermes:/$ sudo vim /etc/hostname

When prompted, enter the administrator password and click the OK button.

Within the hostname file lies the computer name that you want to change. Replace the current computer name with your desired new name, save using :wq and do the same for the hosts file.

f......@hermes:/$ sudo vim /etc/hosts

Once you have restarted your system you should be able to open up your terminal and find that your username is now followed by your new computer name.

No comments:

Post a Comment