change a hostname

Asked by Api

how do I change hostname or rather computer name? If I edit /etc/hosts file through root will that be a problem? can i change the pc name completely in this way?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu sudo Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Luky Winarto (luckyborneo) said :
#1

Hi Api,

You can do it through GUI:
System > Administration > Network
then choose General Tab, then change the hostname you like.

or

You can do it through terminal, run this command:
$ sudo gedit /etc/hostname

Hopefully that will help you.

-Luky-

Revision history for this message
Api (roy-apratim) said :
#2

Thanks Luky, it worked.

But the main issue is still unsolved.

How to use sudo?

whenever i'm using sudo in terminal i'm getting an error message: "unable to resolve host".

how to fix this?

-api-

Revision history for this message
Luky Winarto (luckyborneo) said :
#3

Usually, it is because the content of /etc/hosts and /etc/hostname is different. So, you have to make the same both of them. For example:

$ cat /etc/hostname
myubuntu

$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 myubuntu

Hopefully, that will help you.

-Luky-

Revision history for this message
Api (roy-apratim) said :
#4

Thanx for your time.

I did this before.

I entered as 'root' ,then edited thru command nano /etc/hosts and did the entire thing at boot.

Now, my hosts file in etc/hosts/ contains:

127.0.0.1 localhost ubuntu
127.0.1.1 ubuntu.domain1

But still the same error is coming. How to resolve? Pl. help.

Revision history for this message
Luky Winarto (luckyborneo) said :
#5

Indeed, this is bug
https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/32906

Try this trick:
Go to System > Administration > Network
Then choose General Tab and clear Domain Name that you have typed before. Try to reboot your ubuntu.

-Luky-

Can you help with this problem?

Provide an answer of your own, or ask Api for more information if necessary.

To post a message you must log in.