Hey evryone! I’m a new user of Ubuntu and during he installation i didn’t pay much attantion and didn’t set a computername. The name now annoys me. Can anyone tell me ho can i change it?
Hostname is stored in 2 files.
- /etc/hosts
-
/etc/hostname
There might be a method to change the computer's name using a gui but I couldn't find one.
- enter terminal from menu Applications > System Tools > MATE Terminal (keyboard short cut = Ctrl + Alt + t)
- make a copy of both files using this command - you will be prompted for your password and there will be no indication while you're typing
sudo cp /etc/hosts /etc/hosts.bu && sudo cp /etc/hostname cp /etc/hostname.bu
- open /etc/hosts in a gui text editor using this command - you will be prompted for your password
gksudo pluma /etc/hosts
replace the computer name with your choice; in a default setup this should be on line 2
remember to save the file
using pluma's menu open /etc/hostname
replace the computer name with your choice; in a default setup there's one line
remember to save the file - reboot your computer
@pfeiffep
when i go:
sudo cp /etc/hosts /etc/hosts.bu && sudo cp /etc/hostname cp /etc/hostname.bu
i get:
cp: target ‘/etc/hostname.bu’ is not a directory
my bad
prior to using the 2 commands starting with sudo
cd /etc
then
sudo cp hosts hosts.bu && sudo cp hostname hostname.bu
@pfeiffep Thank you! It worked!
Glad it worked out for you. So others might benefit please mark the selection solved ... look for the solution check box like John did in this thread
Since 'gksu' has disappeared from ubuntuMATE version 18.04, the following will work for step 3 above:
(for newbies)
- type: gedit admin:///etc/hosts [return]
(will have to authenticate with your password; ignore warnings)
change 2nd line in edit window from old computer name to new name, then SAVE.
type: gedit admin:///etc/hostname [return]
(will have to authenticate again; ignore warnings)
change first (or probably only) line in edit window from old name to new name, then SAVE.
- Reboot computer.