I have an Ubuntu 12.04 fresh installation where I want to change the 'hostname' (machine name'. I have followed several instructions, such as from:


but all of them end with 'Cannot Open Display' problem. Basically, I have a GUI (desktop) installed. I switch to the Terminal by CTRL ALT F2 key and run commands.

What is happening? Am I missing some package? Note, I can do the stat command on /etc/hostname and /etc/hosts files so perhaps Permissions are okay?


  • That's pretty old, for 11.04 Natty. I think we have a newer guide around here... let me see if I can find it.
    – Seth
    Feb 19, 2013 at 0:04

1 Answer 1


If you are following that guide it tells you to open gedit. gedit needs a GUI environment to work. So you have two options (personally I don't see why you go to Ctrl+Alt+F2 to get to the terminal, but anyway)

  1. Stay in GUI and run the commands via the gnome-terminal (just press the Windows-key and type terminal)

  2. After pressing Ctrl+Alt+F2, replace "gksu gedit" with "sudo vim" or "sudo nano"

  • Doing 'sudo nano' did the trick! ('sudo vim' did not work). And good tip about the Windows to get to the Terminal. Much better. Thank you very much! Feb 18, 2013 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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