How do I change the computer name?
up vote
313
down vote
favorite
When I connect to my server (ubuntu server 10.10), I get this:
name@server-name.belkin ~>
How can I remove ".belkin"?
hostname
|
show 1 more comment
up vote
313
down vote
favorite
When I connect to my server (ubuntu server 10.10), I get this:
name@server-name.belkin ~>
How can I remove ".belkin"?
hostname
1
Try editing /etc/ hosts. gksudo gedit /etc/hosts and replace server-name.belkin by whatever name you desire.
– LFC_fan
Oct 26 '10 at 8:39
2
Do you want to change the actual server name, or just the way it's displayed in the prompt?
– Dave Jennings
Oct 26 '10 at 18:07
2
Voting to reopen, because this is a superset (allows restart).
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Feb 5 '17 at 17:27
how does this question get closed in favor of one asked over a year later?
– warren
Aug 24 '17 at 16:42
@warren the current consensus is to close by "quality": meta.stackexchange.com/questions/147643/… Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Apr 19 at 11:59
|
show 1 more comment
up vote
313
down vote
favorite
up vote
313
down vote
favorite
When I connect to my server (ubuntu server 10.10), I get this:
name@server-name.belkin ~>
How can I remove ".belkin"?
hostname
When I connect to my server (ubuntu server 10.10), I get this:
name@server-name.belkin ~>
How can I remove ".belkin"?
hostname
hostname
edited Sep 12 '12 at 3:45
Jorge Castro
35.3k105422616
35.3k105422616
asked Oct 26 '10 at 8:00
Wolfy
3,372112839
3,372112839
1
Try editing /etc/ hosts. gksudo gedit /etc/hosts and replace server-name.belkin by whatever name you desire.
– LFC_fan
Oct 26 '10 at 8:39
2
Do you want to change the actual server name, or just the way it's displayed in the prompt?
– Dave Jennings
Oct 26 '10 at 18:07
2
Voting to reopen, because this is a superset (allows restart).
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Feb 5 '17 at 17:27
how does this question get closed in favor of one asked over a year later?
– warren
Aug 24 '17 at 16:42
@warren the current consensus is to close by "quality": meta.stackexchange.com/questions/147643/… Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Apr 19 at 11:59
|
show 1 more comment
1
Try editing /etc/ hosts. gksudo gedit /etc/hosts and replace server-name.belkin by whatever name you desire.
– LFC_fan
Oct 26 '10 at 8:39
2
Do you want to change the actual server name, or just the way it's displayed in the prompt?
– Dave Jennings
Oct 26 '10 at 18:07
2
Voting to reopen, because this is a superset (allows restart).
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Feb 5 '17 at 17:27
how does this question get closed in favor of one asked over a year later?
– warren
Aug 24 '17 at 16:42
@warren the current consensus is to close by "quality": meta.stackexchange.com/questions/147643/… Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Apr 19 at 11:59
1
1
Try editing /etc/ hosts. gksudo gedit /etc/hosts and replace server-name.belkin by whatever name you desire.
– LFC_fan
Oct 26 '10 at 8:39
Try editing /etc/ hosts. gksudo gedit /etc/hosts and replace server-name.belkin by whatever name you desire.
– LFC_fan
Oct 26 '10 at 8:39
2
2
Do you want to change the actual server name, or just the way it's displayed in the prompt?
– Dave Jennings
Oct 26 '10 at 18:07
Do you want to change the actual server name, or just the way it's displayed in the prompt?
– Dave Jennings
Oct 26 '10 at 18:07
2
2
Voting to reopen, because this is a superset (allows restart).
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Feb 5 '17 at 17:27
Voting to reopen, because this is a superset (allows restart).
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Feb 5 '17 at 17:27
how does this question get closed in favor of one asked over a year later?
– warren
Aug 24 '17 at 16:42
how does this question get closed in favor of one asked over a year later?
– warren
Aug 24 '17 at 16:42
@warren the current consensus is to close by "quality": meta.stackexchange.com/questions/147643/… Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Apr 19 at 11:59
@warren the current consensus is to close by "quality": meta.stackexchange.com/questions/147643/… Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Apr 19 at 11:59
|
show 1 more comment
13 Answers
13
active
oldest
votes
up vote
401
down vote
accepted
You need to edit the computer name in two files:
/etc/hostname
and
/etc/hosts
These will both need administrative access, so run
gksu gedit /path/to/file
Replace any instances of the existing computer name with your new one. When complete run
sudo service hostname start
The name will also be changed if you restart your computer.
See also:
- How do I change the hostname without a restart?
41
After that, justsudo service hostname restart
and the hostname has been changed without rebooting.
– Anthony O.
Nov 20 '13 at 0:37
6
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
7
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart
– gerrytan
Oct 30 '14 at 21:47
9
On 14.04, I simply ransudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.
– TSJNachos117
Nov 22 '14 at 8:33
8
sudo hostname new-host-name
worked for me on ubuntu 13.10
– Lekhnath
Jan 14 '15 at 12:04
|
show 16 more comments
up vote
137
down vote
hostnamectl set-hostname
on 13.10+ desktop
This is the best way if you have systemd (13.10 onwards) and if cloud-init is not active (see below):
hostnamectl set-hostname 'new-hostname'
It:
- does not require rebooting
- persists after reboots
More info at: https://askubuntu.com/a/516898/52975
18.04 onwards: cloud-init
18.04 Introduced cloud-init which can control setting of the hostname so hostnamectl
changes it won't stick after a reboot if cloud-init is installed. TODO: how to check if it is installed, is it installed by default on the desktop image or just server?
If you want hostnamectl
changes to stay after a reboot, then you'll need to edit the cloud-init config files, disable cloud-init's hostname set/update module:
sudo sed 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfg
or disable cloud-init entirely:
sudo touch /etc/cloud/cloud-init.disabled
See also: How do I change the hostname without a restart?
3
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
4
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
7
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
2
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
2
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
|
show 6 more comments
up vote
68
down vote
It's quite easy:
Edit
/etc/hostname
, make the name change, save the file.You should also make the same changes in
/etc/hosts
fileRun
sudo service hostname start
As long as you have no application settings depending on the 'old' hostname, you should be ok ;-)
29
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
I don't have any reference to my hostname (new or old) in/etc/hosts
, only localhost and some IPv6 rules.
– Oli♦
Dec 9 '10 at 9:30
1
It's ok, you can do that ashostname
is now a service managed fromupstart
. It'll do exactly the same thing,restart the service.
– Pavlos G.
Jan 7 '11 at 13:11
2
Note: this will not work for ubuntu 14.x, ashostname
is no longer ininit.d
– Rápli András
Oct 9 '14 at 11:42
|
show 7 more comments
up vote
24
down vote
It is safe to do, you just need to be sure you edit both the system hostname configuration file (/etc/hostname) and the hostname name resolution file (/etc/hosts).
From a terminal execute the following:
sudo -s
editor /etc/hostname
editor /etc/hosts
shutdown -ry now
2
You can avoid shutdown withsudo service hostname restart
.
– Wtower
Nov 19 '14 at 12:27
3
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
add a comment |
up vote
18
down vote
In addition to editing /etc/hosts and /etc/hostname, various services might have issues with the change as well. Mysql and postfix are installed by default in ubuntu. A broken postfix won't affect most ubuntu users, since it's a background email server that isn't used by much.
Postfix:
sudo editor /etc/postfix/main.cf
sudo service postfix restart
The default config for mysql doesn't use hostname, so it will work fine as-is. If you have customized it, edit the files in /etc/mysql/ and restart the service.
You may also want to edit /etc/motd (message of the day), which is shown on virtual terminals and remote logins. That one won't harm anything though.
Other services that you may have installed that would need fixing are apache, bind9, etc. In each case, find and edit the hostname in their config and restart the service.
add a comment |
up vote
14
down vote
The host name uniquely identifies your computer on the local network (and possibly on the Internet as well) so it's not a good idea to change it unless you know what you are doing.
But you can change the shell prompt not to display the .belkin
(domain name part):
export PS1='u@h w> '
See the bash man page and specifically the section on prompting for more information.
add a comment |
up vote
14
down vote
Another better and safe way to rename hostname
Install ailurus
Add the PPA and update your repository
sudo add-apt-repository ppa:ailurus && sudo apt-get update
Install ailurus
sudo apt-get install ailurus
- After installation it will be found under Applications>>System Tools>>Ailurus
5
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
38
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
9
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
add a comment |
up vote
9
down vote
If you don't want to play with a text editor, Ubuntu Tweak (grab the deb from their website) has that as one of the little things you can play with (along with lots of other little tweaks that you might want to make but don't really want to play around with the terminal and the files themselves).
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
You can also add Ubuntu Tweak as a PPA withsudo add-apt-repository ppa:tualatrix/ppa
thensudo apt-get update
thensudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
1
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
add a comment |
up vote
9
down vote
Use the hostname
command to change your hostname
sudo hostname newname
However, this does not edit your hosts file, which you must do so as to make sure that your computer recognizes itself
gksudo /etc/hosts
And add a new entry for your hostname pointing to 127.0.0.1
127.0.0.1 oldname newname
You could remove the old entry as well, but I prefer to keep it there.
add a comment |
up vote
7
down vote
The following command change the hostname on the fly but to make it permanent, you have to edit /etc/hostname
:
echo 'new_hostname' > /proc/sys/kernel/hostname
Open a new terminal session and you'll see it right away.
With systemd
in place, the proper way to do it is
hostnamectl set-hostname "new_name"
add a comment |
up vote
4
down vote
If you want a GUI assisted process install Ubuntu-Tweak. Among other uses of this app is the ability to change computer name through tab "Computer-Details" -> "Hostname"
add a comment |
up vote
3
down vote
SystemSettings -> Details -> Overwiev (default opened in U16.04) - Device Name.
but additionally you must change name in /etc/hosts. Ubuntu BUG()?
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
add a comment |
up vote
2
down vote
Open a terminal and
sudo sed -i '1s/.*/desired-name/g' /etc/hostname
# you need restart to effect with...
sudo shutdown -r 0
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
add a comment |
protected by Community♦ Jan 17 '17 at 22:56
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?
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
401
down vote
accepted
You need to edit the computer name in two files:
/etc/hostname
and
/etc/hosts
These will both need administrative access, so run
gksu gedit /path/to/file
Replace any instances of the existing computer name with your new one. When complete run
sudo service hostname start
The name will also be changed if you restart your computer.
See also:
- How do I change the hostname without a restart?
41
After that, justsudo service hostname restart
and the hostname has been changed without rebooting.
– Anthony O.
Nov 20 '13 at 0:37
6
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
7
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart
– gerrytan
Oct 30 '14 at 21:47
9
On 14.04, I simply ransudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.
– TSJNachos117
Nov 22 '14 at 8:33
8
sudo hostname new-host-name
worked for me on ubuntu 13.10
– Lekhnath
Jan 14 '15 at 12:04
|
show 16 more comments
up vote
401
down vote
accepted
You need to edit the computer name in two files:
/etc/hostname
and
/etc/hosts
These will both need administrative access, so run
gksu gedit /path/to/file
Replace any instances of the existing computer name with your new one. When complete run
sudo service hostname start
The name will also be changed if you restart your computer.
See also:
- How do I change the hostname without a restart?
41
After that, justsudo service hostname restart
and the hostname has been changed without rebooting.
– Anthony O.
Nov 20 '13 at 0:37
6
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
7
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart
– gerrytan
Oct 30 '14 at 21:47
9
On 14.04, I simply ransudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.
– TSJNachos117
Nov 22 '14 at 8:33
8
sudo hostname new-host-name
worked for me on ubuntu 13.10
– Lekhnath
Jan 14 '15 at 12:04
|
show 16 more comments
up vote
401
down vote
accepted
up vote
401
down vote
accepted
You need to edit the computer name in two files:
/etc/hostname
and
/etc/hosts
These will both need administrative access, so run
gksu gedit /path/to/file
Replace any instances of the existing computer name with your new one. When complete run
sudo service hostname start
The name will also be changed if you restart your computer.
See also:
- How do I change the hostname without a restart?
You need to edit the computer name in two files:
/etc/hostname
and
/etc/hosts
These will both need administrative access, so run
gksu gedit /path/to/file
Replace any instances of the existing computer name with your new one. When complete run
sudo service hostname start
The name will also be changed if you restart your computer.
See also:
- How do I change the hostname without a restart?
edited May 12 '17 at 10:29
Josip Rodin
298111
298111
answered Oct 26 '10 at 14:39
richzilla
7,859174361
7,859174361
41
After that, justsudo service hostname restart
and the hostname has been changed without rebooting.
– Anthony O.
Nov 20 '13 at 0:37
6
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
7
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart
– gerrytan
Oct 30 '14 at 21:47
9
On 14.04, I simply ransudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.
– TSJNachos117
Nov 22 '14 at 8:33
8
sudo hostname new-host-name
worked for me on ubuntu 13.10
– Lekhnath
Jan 14 '15 at 12:04
|
show 16 more comments
41
After that, justsudo service hostname restart
and the hostname has been changed without rebooting.
– Anthony O.
Nov 20 '13 at 0:37
6
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
7
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart
– gerrytan
Oct 30 '14 at 21:47
9
On 14.04, I simply ransudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.
– TSJNachos117
Nov 22 '14 at 8:33
8
sudo hostname new-host-name
worked for me on ubuntu 13.10
– Lekhnath
Jan 14 '15 at 12:04
41
41
After that, just
sudo service hostname restart
and the hostname has been changed without rebooting.– Anthony O.
Nov 20 '13 at 0:37
After that, just
sudo service hostname restart
and the hostname has been changed without rebooting.– Anthony O.
Nov 20 '13 at 0:37
6
6
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
In Ubuntu 14.04 there is no service 'hostname'. What can I do there to avoid reboot.
– Arpad Horvath
Jul 28 '14 at 6:39
7
7
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart– gerrytan
Oct 30 '14 at 21:47
sudo service hostname restart
doesn't work on default install of ubuntu server 14.04 on AWS. I had to do full server restart– gerrytan
Oct 30 '14 at 21:47
9
9
On 14.04, I simply ran
sudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.– TSJNachos117
Nov 22 '14 at 8:33
On 14.04, I simply ran
sudo hostname
, and that did the trick. I didn't notice any immediate change, but when I opened a new terminal, I saw my hostname had indeed changed.– TSJNachos117
Nov 22 '14 at 8:33
8
8
sudo hostname new-host-name
worked for me on ubuntu 13.10– Lekhnath
Jan 14 '15 at 12:04
sudo hostname new-host-name
worked for me on ubuntu 13.10– Lekhnath
Jan 14 '15 at 12:04
|
show 16 more comments
up vote
137
down vote
hostnamectl set-hostname
on 13.10+ desktop
This is the best way if you have systemd (13.10 onwards) and if cloud-init is not active (see below):
hostnamectl set-hostname 'new-hostname'
It:
- does not require rebooting
- persists after reboots
More info at: https://askubuntu.com/a/516898/52975
18.04 onwards: cloud-init
18.04 Introduced cloud-init which can control setting of the hostname so hostnamectl
changes it won't stick after a reboot if cloud-init is installed. TODO: how to check if it is installed, is it installed by default on the desktop image or just server?
If you want hostnamectl
changes to stay after a reboot, then you'll need to edit the cloud-init config files, disable cloud-init's hostname set/update module:
sudo sed 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfg
or disable cloud-init entirely:
sudo touch /etc/cloud/cloud-init.disabled
See also: How do I change the hostname without a restart?
3
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
4
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
7
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
2
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
2
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
|
show 6 more comments
up vote
137
down vote
hostnamectl set-hostname
on 13.10+ desktop
This is the best way if you have systemd (13.10 onwards) and if cloud-init is not active (see below):
hostnamectl set-hostname 'new-hostname'
It:
- does not require rebooting
- persists after reboots
More info at: https://askubuntu.com/a/516898/52975
18.04 onwards: cloud-init
18.04 Introduced cloud-init which can control setting of the hostname so hostnamectl
changes it won't stick after a reboot if cloud-init is installed. TODO: how to check if it is installed, is it installed by default on the desktop image or just server?
If you want hostnamectl
changes to stay after a reboot, then you'll need to edit the cloud-init config files, disable cloud-init's hostname set/update module:
sudo sed 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfg
or disable cloud-init entirely:
sudo touch /etc/cloud/cloud-init.disabled
See also: How do I change the hostname without a restart?
3
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
4
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
7
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
2
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
2
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
|
show 6 more comments
up vote
137
down vote
up vote
137
down vote
hostnamectl set-hostname
on 13.10+ desktop
This is the best way if you have systemd (13.10 onwards) and if cloud-init is not active (see below):
hostnamectl set-hostname 'new-hostname'
It:
- does not require rebooting
- persists after reboots
More info at: https://askubuntu.com/a/516898/52975
18.04 onwards: cloud-init
18.04 Introduced cloud-init which can control setting of the hostname so hostnamectl
changes it won't stick after a reboot if cloud-init is installed. TODO: how to check if it is installed, is it installed by default on the desktop image or just server?
If you want hostnamectl
changes to stay after a reboot, then you'll need to edit the cloud-init config files, disable cloud-init's hostname set/update module:
sudo sed 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfg
or disable cloud-init entirely:
sudo touch /etc/cloud/cloud-init.disabled
See also: How do I change the hostname without a restart?
hostnamectl set-hostname
on 13.10+ desktop
This is the best way if you have systemd (13.10 onwards) and if cloud-init is not active (see below):
hostnamectl set-hostname 'new-hostname'
It:
- does not require rebooting
- persists after reboots
More info at: https://askubuntu.com/a/516898/52975
18.04 onwards: cloud-init
18.04 Introduced cloud-init which can control setting of the hostname so hostnamectl
changes it won't stick after a reboot if cloud-init is installed. TODO: how to check if it is installed, is it installed by default on the desktop image or just server?
If you want hostnamectl
changes to stay after a reboot, then you'll need to edit the cloud-init config files, disable cloud-init's hostname set/update module:
sudo sed 's/preserve_hostname: false/preserve_hostname: true/' /etc/cloud/cloud.cfg
or disable cloud-init entirely:
sudo touch /etc/cloud/cloud-init.disabled
See also: How do I change the hostname without a restart?
edited Oct 30 at 9:28
answered Nov 30 '15 at 11:24
Ciro Santilli 新疆改造中心 六四事件 法轮功
8,83444145
8,83444145
3
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
4
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
7
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
2
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
2
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
|
show 6 more comments
3
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
4
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
7
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
2
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
2
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
3
3
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
works perfect in Ubuntu 15.10
– A.B.
Feb 26 '16 at 13:28
4
4
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
Doesn't change /etc/hosts in 14.04
– Autodidact
Jul 1 '16 at 15:37
7
7
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
works perfectly in ubuntu 16.04... thanks a lot
– Hirak
Nov 20 '16 at 11:16
2
2
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
Confirmed to work correctly in 16.10 also
– fuzzygroup
Nov 20 '16 at 11:23
2
2
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
I had to add my new-hostname into /etc/hosts else using sudo would cause some error "sudo: unable to resolve host xxxxx"
– WoodyDRN
May 27 '17 at 0:27
|
show 6 more comments
up vote
68
down vote
It's quite easy:
Edit
/etc/hostname
, make the name change, save the file.You should also make the same changes in
/etc/hosts
fileRun
sudo service hostname start
As long as you have no application settings depending on the 'old' hostname, you should be ok ;-)
29
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
I don't have any reference to my hostname (new or old) in/etc/hosts
, only localhost and some IPv6 rules.
– Oli♦
Dec 9 '10 at 9:30
1
It's ok, you can do that ashostname
is now a service managed fromupstart
. It'll do exactly the same thing,restart the service.
– Pavlos G.
Jan 7 '11 at 13:11
2
Note: this will not work for ubuntu 14.x, ashostname
is no longer ininit.d
– Rápli András
Oct 9 '14 at 11:42
|
show 7 more comments
up vote
68
down vote
It's quite easy:
Edit
/etc/hostname
, make the name change, save the file.You should also make the same changes in
/etc/hosts
fileRun
sudo service hostname start
As long as you have no application settings depending on the 'old' hostname, you should be ok ;-)
29
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
I don't have any reference to my hostname (new or old) in/etc/hosts
, only localhost and some IPv6 rules.
– Oli♦
Dec 9 '10 at 9:30
1
It's ok, you can do that ashostname
is now a service managed fromupstart
. It'll do exactly the same thing,restart the service.
– Pavlos G.
Jan 7 '11 at 13:11
2
Note: this will not work for ubuntu 14.x, ashostname
is no longer ininit.d
– Rápli András
Oct 9 '14 at 11:42
|
show 7 more comments
up vote
68
down vote
up vote
68
down vote
It's quite easy:
Edit
/etc/hostname
, make the name change, save the file.You should also make the same changes in
/etc/hosts
fileRun
sudo service hostname start
As long as you have no application settings depending on the 'old' hostname, you should be ok ;-)
It's quite easy:
Edit
/etc/hostname
, make the name change, save the file.You should also make the same changes in
/etc/hosts
fileRun
sudo service hostname start
As long as you have no application settings depending on the 'old' hostname, you should be ok ;-)
edited May 12 '17 at 10:28
Josip Rodin
298111
298111
answered Dec 6 '10 at 15:52
Pavlos G.
7,22612633
7,22612633
29
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
I don't have any reference to my hostname (new or old) in/etc/hosts
, only localhost and some IPv6 rules.
– Oli♦
Dec 9 '10 at 9:30
1
It's ok, you can do that ashostname
is now a service managed fromupstart
. It'll do exactly the same thing,restart the service.
– Pavlos G.
Jan 7 '11 at 13:11
2
Note: this will not work for ubuntu 14.x, ashostname
is no longer ininit.d
– Rápli András
Oct 9 '14 at 11:42
|
show 7 more comments
29
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
I don't have any reference to my hostname (new or old) in/etc/hosts
, only localhost and some IPv6 rules.
– Oli♦
Dec 9 '10 at 9:30
1
It's ok, you can do that ashostname
is now a service managed fromupstart
. It'll do exactly the same thing,restart the service.
– Pavlos G.
Jan 7 '11 at 13:11
2
Note: this will not work for ubuntu 14.x, ashostname
is no longer ininit.d
– Rápli András
Oct 9 '14 at 11:42
29
29
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
WARNING: If you do this without changing /etc/hosts accordingly you will be unable to use sudo because your hostname will fail to lookup
– João Pinto
Dec 6 '10 at 16:10
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
You're right regarding editing the /etc/hosts, i forgot about it (just added it to my answer), though sudo seems to be working fine for me without changing it (i've restarted the machine and it still works)
– Pavlos G.
Dec 6 '10 at 16:14
I don't have any reference to my hostname (new or old) in
/etc/hosts
, only localhost and some IPv6 rules.– Oli♦
Dec 9 '10 at 9:30
I don't have any reference to my hostname (new or old) in
/etc/hosts
, only localhost and some IPv6 rules.– Oli♦
Dec 9 '10 at 9:30
1
1
It's ok, you can do that as
hostname
is now a service managed from upstart
. It'll do exactly the same thing,restart the service.– Pavlos G.
Jan 7 '11 at 13:11
It's ok, you can do that as
hostname
is now a service managed from upstart
. It'll do exactly the same thing,restart the service.– Pavlos G.
Jan 7 '11 at 13:11
2
2
Note: this will not work for ubuntu 14.x, as
hostname
is no longer in init.d
– Rápli András
Oct 9 '14 at 11:42
Note: this will not work for ubuntu 14.x, as
hostname
is no longer in init.d
– Rápli András
Oct 9 '14 at 11:42
|
show 7 more comments
up vote
24
down vote
It is safe to do, you just need to be sure you edit both the system hostname configuration file (/etc/hostname) and the hostname name resolution file (/etc/hosts).
From a terminal execute the following:
sudo -s
editor /etc/hostname
editor /etc/hosts
shutdown -ry now
2
You can avoid shutdown withsudo service hostname restart
.
– Wtower
Nov 19 '14 at 12:27
3
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
add a comment |
up vote
24
down vote
It is safe to do, you just need to be sure you edit both the system hostname configuration file (/etc/hostname) and the hostname name resolution file (/etc/hosts).
From a terminal execute the following:
sudo -s
editor /etc/hostname
editor /etc/hosts
shutdown -ry now
2
You can avoid shutdown withsudo service hostname restart
.
– Wtower
Nov 19 '14 at 12:27
3
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
add a comment |
up vote
24
down vote
up vote
24
down vote
It is safe to do, you just need to be sure you edit both the system hostname configuration file (/etc/hostname) and the hostname name resolution file (/etc/hosts).
From a terminal execute the following:
sudo -s
editor /etc/hostname
editor /etc/hosts
shutdown -ry now
It is safe to do, you just need to be sure you edit both the system hostname configuration file (/etc/hostname) and the hostname name resolution file (/etc/hosts).
From a terminal execute the following:
sudo -s
editor /etc/hostname
editor /etc/hosts
shutdown -ry now
answered Dec 6 '10 at 16:12
João Pinto
14.6k34660
14.6k34660
2
You can avoid shutdown withsudo service hostname restart
.
– Wtower
Nov 19 '14 at 12:27
3
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
add a comment |
2
You can avoid shutdown withsudo service hostname restart
.
– Wtower
Nov 19 '14 at 12:27
3
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
2
2
You can avoid shutdown with
sudo service hostname restart
.– Wtower
Nov 19 '14 at 12:27
You can avoid shutdown with
sudo service hostname restart
.– Wtower
Nov 19 '14 at 12:27
3
3
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
@Wtower Doesn't work with 14.04. :(
– dotslash
Jan 2 '16 at 6:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:13
add a comment |
up vote
18
down vote
In addition to editing /etc/hosts and /etc/hostname, various services might have issues with the change as well. Mysql and postfix are installed by default in ubuntu. A broken postfix won't affect most ubuntu users, since it's a background email server that isn't used by much.
Postfix:
sudo editor /etc/postfix/main.cf
sudo service postfix restart
The default config for mysql doesn't use hostname, so it will work fine as-is. If you have customized it, edit the files in /etc/mysql/ and restart the service.
You may also want to edit /etc/motd (message of the day), which is shown on virtual terminals and remote logins. That one won't harm anything though.
Other services that you may have installed that would need fixing are apache, bind9, etc. In each case, find and edit the hostname in their config and restart the service.
add a comment |
up vote
18
down vote
In addition to editing /etc/hosts and /etc/hostname, various services might have issues with the change as well. Mysql and postfix are installed by default in ubuntu. A broken postfix won't affect most ubuntu users, since it's a background email server that isn't used by much.
Postfix:
sudo editor /etc/postfix/main.cf
sudo service postfix restart
The default config for mysql doesn't use hostname, so it will work fine as-is. If you have customized it, edit the files in /etc/mysql/ and restart the service.
You may also want to edit /etc/motd (message of the day), which is shown on virtual terminals and remote logins. That one won't harm anything though.
Other services that you may have installed that would need fixing are apache, bind9, etc. In each case, find and edit the hostname in their config and restart the service.
add a comment |
up vote
18
down vote
up vote
18
down vote
In addition to editing /etc/hosts and /etc/hostname, various services might have issues with the change as well. Mysql and postfix are installed by default in ubuntu. A broken postfix won't affect most ubuntu users, since it's a background email server that isn't used by much.
Postfix:
sudo editor /etc/postfix/main.cf
sudo service postfix restart
The default config for mysql doesn't use hostname, so it will work fine as-is. If you have customized it, edit the files in /etc/mysql/ and restart the service.
You may also want to edit /etc/motd (message of the day), which is shown on virtual terminals and remote logins. That one won't harm anything though.
Other services that you may have installed that would need fixing are apache, bind9, etc. In each case, find and edit the hostname in their config and restart the service.
In addition to editing /etc/hosts and /etc/hostname, various services might have issues with the change as well. Mysql and postfix are installed by default in ubuntu. A broken postfix won't affect most ubuntu users, since it's a background email server that isn't used by much.
Postfix:
sudo editor /etc/postfix/main.cf
sudo service postfix restart
The default config for mysql doesn't use hostname, so it will work fine as-is. If you have customized it, edit the files in /etc/mysql/ and restart the service.
You may also want to edit /etc/motd (message of the day), which is shown on virtual terminals and remote logins. That one won't harm anything though.
Other services that you may have installed that would need fixing are apache, bind9, etc. In each case, find and edit the hostname in their config and restart the service.
edited Jul 9 '13 at 19:32
mullens
32
32
answered Dec 6 '10 at 17:20
ImaginaryRobots
7,14142636
7,14142636
add a comment |
add a comment |
up vote
14
down vote
The host name uniquely identifies your computer on the local network (and possibly on the Internet as well) so it's not a good idea to change it unless you know what you are doing.
But you can change the shell prompt not to display the .belkin
(domain name part):
export PS1='u@h w> '
See the bash man page and specifically the section on prompting for more information.
add a comment |
up vote
14
down vote
The host name uniquely identifies your computer on the local network (and possibly on the Internet as well) so it's not a good idea to change it unless you know what you are doing.
But you can change the shell prompt not to display the .belkin
(domain name part):
export PS1='u@h w> '
See the bash man page and specifically the section on prompting for more information.
add a comment |
up vote
14
down vote
up vote
14
down vote
The host name uniquely identifies your computer on the local network (and possibly on the Internet as well) so it's not a good idea to change it unless you know what you are doing.
But you can change the shell prompt not to display the .belkin
(domain name part):
export PS1='u@h w> '
See the bash man page and specifically the section on prompting for more information.
The host name uniquely identifies your computer on the local network (and possibly on the Internet as well) so it's not a good idea to change it unless you know what you are doing.
But you can change the shell prompt not to display the .belkin
(domain name part):
export PS1='u@h w> '
See the bash man page and specifically the section on prompting for more information.
answered Oct 26 '10 at 8:36
Riccardo Murri
13.3k54349
13.3k54349
add a comment |
add a comment |
up vote
14
down vote
Another better and safe way to rename hostname
Install ailurus
Add the PPA and update your repository
sudo add-apt-repository ppa:ailurus && sudo apt-get update
Install ailurus
sudo apt-get install ailurus
- After installation it will be found under Applications>>System Tools>>Ailurus
5
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
38
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
9
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
add a comment |
up vote
14
down vote
Another better and safe way to rename hostname
Install ailurus
Add the PPA and update your repository
sudo add-apt-repository ppa:ailurus && sudo apt-get update
Install ailurus
sudo apt-get install ailurus
- After installation it will be found under Applications>>System Tools>>Ailurus
5
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
38
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
9
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
add a comment |
up vote
14
down vote
up vote
14
down vote
Another better and safe way to rename hostname
Install ailurus
Add the PPA and update your repository
sudo add-apt-repository ppa:ailurus && sudo apt-get update
Install ailurus
sudo apt-get install ailurus
- After installation it will be found under Applications>>System Tools>>Ailurus
Another better and safe way to rename hostname
Install ailurus
Add the PPA and update your repository
sudo add-apt-repository ppa:ailurus && sudo apt-get update
Install ailurus
sudo apt-get install ailurus
- After installation it will be found under Applications>>System Tools>>Ailurus
answered Dec 19 '10 at 18:43
karthick87
46.8k53166217
46.8k53166217
5
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
38
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
9
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
add a comment |
5
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
38
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
9
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
5
5
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
Why is this getting negative votes? Should be better to configure something with a dedicated tool than muck around on the command line and break things in the process.
– endolith
Jan 20 '11 at 3:49
38
38
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
Installing such a big software just to change a hostname is a bit of an overkill
– Nemo
Jun 17 '11 at 1:56
9
9
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
I agree that this is overkill -- in particular because the software not available in the repositories but has to be installed from a PPA...
– Marcel Stimberg
Jul 5 '11 at 16:55
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
@karthick87 perhaps mention in your answer that this is a large piece of software (with other configuration options)? - personally I agree with endolith that a tool with a single, simple change point is better than lots of command line operations (I use Ubuntu Tweak, also currently available from a PPA)
– d3vid
Oct 14 '11 at 7:19
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
I think that you can break a lot more things (and more easily) using this tool, than just replacing a word in a couple of files. It exposed too many things to you.
– gerlos
Jan 20 '16 at 18:53
add a comment |
up vote
9
down vote
If you don't want to play with a text editor, Ubuntu Tweak (grab the deb from their website) has that as one of the little things you can play with (along with lots of other little tweaks that you might want to make but don't really want to play around with the terminal and the files themselves).
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
You can also add Ubuntu Tweak as a PPA withsudo add-apt-repository ppa:tualatrix/ppa
thensudo apt-get update
thensudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
1
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
add a comment |
up vote
9
down vote
If you don't want to play with a text editor, Ubuntu Tweak (grab the deb from their website) has that as one of the little things you can play with (along with lots of other little tweaks that you might want to make but don't really want to play around with the terminal and the files themselves).
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
You can also add Ubuntu Tweak as a PPA withsudo add-apt-repository ppa:tualatrix/ppa
thensudo apt-get update
thensudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
1
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
add a comment |
up vote
9
down vote
up vote
9
down vote
If you don't want to play with a text editor, Ubuntu Tweak (grab the deb from their website) has that as one of the little things you can play with (along with lots of other little tweaks that you might want to make but don't really want to play around with the terminal and the files themselves).
If you don't want to play with a text editor, Ubuntu Tweak (grab the deb from their website) has that as one of the little things you can play with (along with lots of other little tweaks that you might want to make but don't really want to play around with the terminal and the files themselves).
answered Dec 7 '10 at 3:04
dkuntz2
479311
479311
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
You can also add Ubuntu Tweak as a PPA withsudo add-apt-repository ppa:tualatrix/ppa
thensudo apt-get update
thensudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
1
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
add a comment |
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
You can also add Ubuntu Tweak as a PPA withsudo add-apt-repository ppa:tualatrix/ppa
thensudo apt-get update
thensudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
1
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
Out of curiosity, is there any particular reason why Ubuntu Tweak is not in the software repos?
– Olivier Lalonde
Dec 7 '10 at 22:31
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
They never got around to adding it/haven't been accepted. You can add their repo to your list either right after starting tweak or through the terminal/repo list.
– dkuntz2
Dec 7 '10 at 23:40
You can also add Ubuntu Tweak as a PPA with
sudo add-apt-repository ppa:tualatrix/ppa
then sudo apt-get update
then sudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
You can also add Ubuntu Tweak as a PPA with
sudo add-apt-repository ppa:tualatrix/ppa
then sudo apt-get update
then sudo apt-get install ubuntu-tweak
– d3vid
Oct 14 '11 at 7:15
1
1
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
note that since ~13.04 Ubuntu Tweak no longer provides this option
– d3vid
Jun 15 '14 at 11:32
add a comment |
up vote
9
down vote
Use the hostname
command to change your hostname
sudo hostname newname
However, this does not edit your hosts file, which you must do so as to make sure that your computer recognizes itself
gksudo /etc/hosts
And add a new entry for your hostname pointing to 127.0.0.1
127.0.0.1 oldname newname
You could remove the old entry as well, but I prefer to keep it there.
add a comment |
up vote
9
down vote
Use the hostname
command to change your hostname
sudo hostname newname
However, this does not edit your hosts file, which you must do so as to make sure that your computer recognizes itself
gksudo /etc/hosts
And add a new entry for your hostname pointing to 127.0.0.1
127.0.0.1 oldname newname
You could remove the old entry as well, but I prefer to keep it there.
add a comment |
up vote
9
down vote
up vote
9
down vote
Use the hostname
command to change your hostname
sudo hostname newname
However, this does not edit your hosts file, which you must do so as to make sure that your computer recognizes itself
gksudo /etc/hosts
And add a new entry for your hostname pointing to 127.0.0.1
127.0.0.1 oldname newname
You could remove the old entry as well, but I prefer to keep it there.
Use the hostname
command to change your hostname
sudo hostname newname
However, this does not edit your hosts file, which you must do so as to make sure that your computer recognizes itself
gksudo /etc/hosts
And add a new entry for your hostname pointing to 127.0.0.1
127.0.0.1 oldname newname
You could remove the old entry as well, but I prefer to keep it there.
edited Oct 19 '15 at 11:41
answered Jun 17 '11 at 1:55
Nemo
6,52654062
6,52654062
add a comment |
add a comment |
up vote
7
down vote
The following command change the hostname on the fly but to make it permanent, you have to edit /etc/hostname
:
echo 'new_hostname' > /proc/sys/kernel/hostname
Open a new terminal session and you'll see it right away.
With systemd
in place, the proper way to do it is
hostnamectl set-hostname "new_name"
add a comment |
up vote
7
down vote
The following command change the hostname on the fly but to make it permanent, you have to edit /etc/hostname
:
echo 'new_hostname' > /proc/sys/kernel/hostname
Open a new terminal session and you'll see it right away.
With systemd
in place, the proper way to do it is
hostnamectl set-hostname "new_name"
add a comment |
up vote
7
down vote
up vote
7
down vote
The following command change the hostname on the fly but to make it permanent, you have to edit /etc/hostname
:
echo 'new_hostname' > /proc/sys/kernel/hostname
Open a new terminal session and you'll see it right away.
With systemd
in place, the proper way to do it is
hostnamectl set-hostname "new_name"
The following command change the hostname on the fly but to make it permanent, you have to edit /etc/hostname
:
echo 'new_hostname' > /proc/sys/kernel/hostname
Open a new terminal session and you'll see it right away.
With systemd
in place, the proper way to do it is
hostnamectl set-hostname "new_name"
edited Feb 14 '17 at 0:00
wjandrea
7,78642258
7,78642258
answered Nov 5 '12 at 23:50
Terry Wang
6,17932224
6,17932224
add a comment |
add a comment |
up vote
4
down vote
If you want a GUI assisted process install Ubuntu-Tweak. Among other uses of this app is the ability to change computer name through tab "Computer-Details" -> "Hostname"
add a comment |
up vote
4
down vote
If you want a GUI assisted process install Ubuntu-Tweak. Among other uses of this app is the ability to change computer name through tab "Computer-Details" -> "Hostname"
add a comment |
up vote
4
down vote
up vote
4
down vote
If you want a GUI assisted process install Ubuntu-Tweak. Among other uses of this app is the ability to change computer name through tab "Computer-Details" -> "Hostname"
If you want a GUI assisted process install Ubuntu-Tweak. Among other uses of this app is the ability to change computer name through tab "Computer-Details" -> "Hostname"
answered Jun 17 '11 at 0:20
13east
1,65221523
1,65221523
add a comment |
add a comment |
up vote
3
down vote
SystemSettings -> Details -> Overwiev (default opened in U16.04) - Device Name.
but additionally you must change name in /etc/hosts. Ubuntu BUG()?
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
add a comment |
up vote
3
down vote
SystemSettings -> Details -> Overwiev (default opened in U16.04) - Device Name.
but additionally you must change name in /etc/hosts. Ubuntu BUG()?
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
add a comment |
up vote
3
down vote
up vote
3
down vote
SystemSettings -> Details -> Overwiev (default opened in U16.04) - Device Name.
but additionally you must change name in /etc/hosts. Ubuntu BUG()?
SystemSettings -> Details -> Overwiev (default opened in U16.04) - Device Name.
but additionally you must change name in /etc/hosts. Ubuntu BUG()?
answered Sep 8 '16 at 13:21
udroidman
311
311
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
add a comment |
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
I think this a rather nice way to change the hostname.
– jawtheshark
Sep 8 '16 at 13:48
add a comment |
up vote
2
down vote
Open a terminal and
sudo sed -i '1s/.*/desired-name/g' /etc/hostname
# you need restart to effect with...
sudo shutdown -r 0
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
add a comment |
up vote
2
down vote
Open a terminal and
sudo sed -i '1s/.*/desired-name/g' /etc/hostname
# you need restart to effect with...
sudo shutdown -r 0
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
add a comment |
up vote
2
down vote
up vote
2
down vote
Open a terminal and
sudo sed -i '1s/.*/desired-name/g' /etc/hostname
# you need restart to effect with...
sudo shutdown -r 0
Open a terminal and
sudo sed -i '1s/.*/desired-name/g' /etc/hostname
# you need restart to effect with...
sudo shutdown -r 0
answered Oct 26 '10 at 14:32
SergioAraujo
36025
36025
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
add a comment |
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
Warning: won't work with Ubuntu 18+ which is running cloud-init by default, which controls hostname on boot.
– nslntmnx
Sep 1 at 7:12
add a comment |
protected by Community♦ Jan 17 '17 at 22:56
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?
1
Try editing /etc/ hosts. gksudo gedit /etc/hosts and replace server-name.belkin by whatever name you desire.
– LFC_fan
Oct 26 '10 at 8:39
2
Do you want to change the actual server name, or just the way it's displayed in the prompt?
– Dave Jennings
Oct 26 '10 at 18:07
2
Voting to reopen, because this is a superset (allows restart).
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Feb 5 '17 at 17:27
how does this question get closed in favor of one asked over a year later?
– warren
Aug 24 '17 at 16:42
@warren the current consensus is to close by "quality": meta.stackexchange.com/questions/147643/… Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Apr 19 at 11:59