Change the "device name" in the details window of System settings
Solution 1
Execute the following command using a terminal:
sudo sed -i 's/present-host-name/new-host-name/' /etc/hosts
sudo sed -i 's/present-host-name/new-host-name/' /etc/hostname
You can check your present-host-name by cat /etc/hostname
or hostname
.
Then reboot the computer, to see the changes.
Solution 2
Open a terminal and issue the command
gksu gedit /etc/hosts
Then change the line
127.0.1.1 victor-System-Product-Name
with
127.0.1.1 your-desired-name
Then also open the file
/etc/hostname
with commandgksu gedit /etc/hostname
and change the hostname there to reflect the new name.Then reboot the computer, to see the changes
Solution 3
You can use the built in service hostnamectl
sudo hostnamectl set-hostname [NEW-HOSTNAME]
replacing [NEW-HOSTNAME]
with the hostname you would like
this should work immediately on most things but I would reboot for good measure.
Solution 4
Since there are plenty of ways to get something done here is one more:
While in your root directory:
cd /etc
sudo vi hostname
Type in your admin password, press Enter.
Press i
to 'insert' and change existing device name to the desired device name.
Press Esc and type :wq!
, press Enter.
Restart the system for the change to take affect.
Related videos on Youtube
Victor S
Contract software developer working for start-ups and small business. Ruby, PHP, JavaScript/NodeJS. Operating from Toronto, love to work on remote teams. Give me a shout if you need technical advice or some extra hands on deck!
Updated on September 18, 2022Comments
-
Victor S over 1 year
I would like to change my "Device name" as shown in the settings panel. How do I do this?
-
Admin almost 10 years1st answer worked fine for me on 14.04, many thanks
-
-
Samik almost 12 yearsOr
sudo hostname preferredname
? -
Anwar almost 12 years@Samik, unfortunately
sudo hostname preferredname
won't work. I checked that. thanks -
Victor S almost 12 yearsSorry, these steps don't work, but I guess it's good to change the etc/hosts file to reflect what is in etc/hostname anyway. Thanks.
-
Anwar almost 12 yearsOnly renaming the hostname change the device name in details. but There will be an error relating to hostname in each sudo command to terminal
-
Anwar almost 12 yearsOnly changing the hostname, causes error to be shown on each sudo command to the terminal
-
Anwar almost 12 years@VictorS, yes, only changing the hostname causes errors to be shown in terminal
-
atenz almost 12 yearsThanks for noticing me about that , can you post the exact errors you see . According to Hostname man page
Edit /etc/hostname for permanent change
, even i tried this method and haven't encountered any such errors. -
Anwar almost 12 yearsI edited
/etc/hostname
to a new nameanwar
from previous oneanwar-precise
. The error after rebooting the system and executing a sudo command issudo: unable to resolve host anwar
. It may be only warning. I executedsudo gedit
command -
vine_user almost 12 yearsThats right. I rewrote the description.
-
atenz almost 12 yearsI searched for these and concluded you need to change both
hosts
andhostname
to reflect complete changes , depending on maybe loopback , DNS , domain-name, resolv.conf. But its better to do changes in both of them. Yet i haven't encountered any sucherror
,must be different interface. -
UnKNOWn over 3 yearsvery nice.. Changes are immediate..