Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to change my "Device name" as shown in the settings panel. How do I do this?

enter image description here

share|improve this question
1st answer worked fine for me on 14.04, many thanks – user277255 May 2 '14 at 21:06
up vote 28 down vote accepted

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.

share|improve this answer
Thanks, good tip on checking present hostname – Victor S Jul 4 '12 at 15:53
Only 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 Shah Jul 6 '12 at 3:26
Thats right. I rewrote the description. – vine_user Jul 6 '12 at 5:57
  • Open a terminal and issue the command

    gksu gedit /etc/hosts
  • Then change the line   victor-System-Product-Name

    with    your-desired-name
  • Then also open the file /etc/hostname with command gksu gedit /etc/hostname and change the hostname there to reflect the new name.

  • Then reboot the computer, to see the changes

share|improve this answer
Or sudo hostname preferredname ? – Samik Jul 4 '12 at 15:00
@Samik, unfortunately sudo hostname preferredname won't work. I checked that. thanks – Anwar Shah Jul 4 '12 at 15:07
Sorry, 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. – Victor S Jul 4 '12 at 15:52
@VictorS, yes, only changing the hostname causes errors to be shown in terminal – Anwar Shah Jul 6 '12 at 3:32

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.

share|improve this answer

Run this command , it will open up Text editor

sudo gedit /etc/hostname 

Replace the present name to your Desired name. Save and close. Reboot for it to take effect.

share|improve this answer
Only changing the hostname, causes error to be shown on each sudo command to the terminal – Anwar Shah Jul 6 '12 at 3:30
Thanks 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. – atenz Jul 6 '12 at 5:19
I edited /etc/hostname to a new name anwar from previous one anwar-precise. The error after rebooting the system and executing a sudo command is sudo: unable to resolve host anwar. It may be only warning. I executed sudo gedit command – Anwar Shah Jul 6 '12 at 5:32
I searched for these and concluded you need to change both hosts and hostname 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 such error ,must be different interface. – atenz Jul 6 '12 at 6:00

protected by Community May 2 '14 at 21:39

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.