PDA

View Full Version : [ubuntu] 11.04 Need Help with Terminal



GiuHei3u
March 11th, 2012, 11:28 PM
While trying to delete my hostname using ctrl,alt, T and using gksudo and gedit and deleting my hostname in both /exe/hostname and /exe/hosts and saving my prompt should have been ...

username@~$ but instead it is

username@linux~$ and I have no idea where the "linux" came from.

Now my ctrl,alt, T to bring up the terminal does not work to use gedit to fix it. I can bring up the ctrl,alt, f1 or f3 but of course it will not allow me to edit those two folders.

Can anyone help in this regard?

thanks.

matt_symes
March 11th, 2012, 11:37 PM
Hi

Press CTRL and ALT and F1 together. This will bring up a console and not a terminal.

Enter your user name and password. The password will not be echoed to the screen.

Then type (double check each command before hitting the enter key - any your not sure of then ask)


echo "<computer_name>" | sudo tee /etc/hostname

Change <computer_name> to your computer name.

Then type (notice the extra -a after tee. This is very important !)


echo "127.0.0.1 <computer_name>" | sudo tee -a /etc/hosts

Make sure the computer name is the same as the one you just added to the hostname file.

Then reboot with


sudo reboot

Let me know how this goes.

Kind regards

GiuHei3u
March 12th, 2012, 12:00 AM
Hi

Press CTRL and ALT and F1 together. This will bring up a console and not a terminal.

Enter your user name and password. The password will not be echoed to the screen.

Then type (double check each command before hitting the enter key - any your not sure of then ask)


echo "<user_name>" | sudo tee /etc/hostnameChange <user_name> to your user name.

Then type (notice the extra -a after tee. This is very important !)


echo "120.0.0.1 <user_name>" | sudo tee -a /etc/hostsMake sure the user name is the same as the one you just added to the hostname file.

Then reboot with


sudo rebootLet me know how this goes.

Kind regards

I am already confused. My username when I login to the computer is John.
so the code should be ....
echo john | sudo tee /etc/hostname ??? nothing after hostname? because when I hit enter "john" appears and then I get the prompt John@linux~$

and you mention to make sure the user name is the same as the one I just added to the hostname file.
I don't know what name is in the hostname file.

I should never have attempted trying to change this stupid hostname. This has been going on for 3 hours now.

Thanks.

matt_symes
March 12th, 2012, 12:21 AM
Hi


I am already confused. My username when I login to the computer is John.

Your user name and computer name can be different.

Take a look at mine. The whoami command will tell you your username.

This is mine.


matthew@matthew-Aspire-7540:~/k3_radio$ whoami
matthew
matthew@matthew-Aspire-7540:~/k3_radio$

The command hostname will tell you your computer name.

This is mine.


matthew@matthew-Aspire-7540:~/k3_radio$ hostname
matthew-Aspire-7540
matthew@matthew-Aspire-7540:~/k3_radio$

As you can see my user name is matthew and my computer name is matthew-Aspire-7540.

You need your computer name in two files for your system to work correctly. One is /etc/hostname and the other is /etc/hosts.

In my case this would add my computer name to my host file


echo "matthew-Aspire-7540" | sudo tee /etc/hostname

It will output the text matthew-Aspire-7540 on the console or terminal and also add it to rthe file /etc/hostname.

On your PC the command line will still say

John@linux~$

You are just updating the file /etc/hostname at this point

You can check this with


cat /etc/hostname

On my machine


matthew@matthew-Aspire-7540:~/k3_radio$ cat /etc/hostname
matthew-Aspire-7540
matthew@matthew-Aspire-7540:~/k3_radio$

The second command


echo "127.0.0.1 matthew@matthew-Aspire-7540" | sudo tee -a /etc/hosts

will append 127.0.0.1 matthew-Aspire-7540 to the file /etc/hosts file.

On your PC the command line will still say

John@linux~$

You are just updating the file /etc/hosts at this point

You can check this with


cat /etc/hosts

Mine would look like


matthew@matthew-Aspire-7540:~$ cat /etc/hosts
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 matthew-Aspire-7540
matthew@matthew-Aspire-7540:~$

You need to change matthew-Aspire-7540 to the name you want to call your computer.

When you reboot using


sudo reboot

that is when the change you have made to your computer name will start to take effect and you will see

John@<your_computer_name>~$

where <your_computer_name> is the name you have chosen for your computer.

I hope this is clearer for you. The confusion is my fault when i typed <user_name> instead of <computer_name> in the first post in this thread. Sorry about that; it's late here :( I will edit my first post.

Kind regards

matt_symes
March 12th, 2012, 12:36 AM
Hi

I just wanted to point something out. Ubuntu is case sensitive so


hello

is not the same as


Hello

is not the same as


hElLo

Therefore


ctl atl T

is not the same as


ctrl alt t

You need ctrl alt t to display the terminal.

Also


John

is not the same as


john

Thanks yetiman64 for pointing that out.

You can also get to a terminal by typing


terminal

or


xterm

into the dash and hitting the enter key

EDIT:

Also there is a typo in my second command (it should be 127.0.0.1 and not 120.0.0.1)


echo "127.0.0.1 <user_name>" | sudo tee -a /etc/hosts

EDIT2:

The last thing i wanted to say was don't give up. Sometimes these things can be frustrating i know but i'm sure it was the same when you first used Windows. It just unfamiliar.

Kind regards

UnknownFearNG
March 12th, 2012, 02:31 AM
Hi
The last thing i wanted to say was don't give up. Sometimes these things can be frustrating i know but i'm sure it was the same when you first used Windows. It just unfamiliar.

Couldn't agree more with what Matthew has said. Problems arise anywhere and everywhere. Don't just uninstall Linux and go back to Windows or OS X. We are here to help and, with the knowledge we all give you, you will learn from your problems and be able to pass it on to other users.

kevdog
March 12th, 2012, 04:22 AM
Matt

You really spent a lot of time on the explanation. Great work. I'm fairly certain I would not have been so patient.

critin
March 12th, 2012, 06:50 AM
While trying to delete my hostname using ctrl,alt, T and using gksudo and gedit and deleting my hostname in both /exe/hostname and /exe/hosts and saving my prompt should have been ...

username@~$ but instead it is

username@linux~$ and I have no idea where the "linux" came from.

Now my ctrl,alt, T to bring up the terminal does not work to use gedit to fix it. I can bring up the ctrl,alt, f1 or f3 but of course it will not allow me to edit those two folders.

Can anyone help in this regard?

thanks.

This worked good for me and it's very easy.

http://www.liberiangeek.net/2011/03/change-hostname-computer-name-ubuntu-11-04-natty/

If you delete the host name, it automatically reverts to linux I believe.

ckasux
March 12th, 2012, 06:59 AM
Matt

You really spent a lot of time on the explanation. Great work. I'm fairly certain I would not have been so patient.
linux needs more like him .i rember when i fist started 10 to 15 yr ago no one like that
i try to do the same the more help you give the farster linux evolves

matt_symes
March 12th, 2012, 12:03 PM
Hi

I am kind of beginning to think i might have misread the OP's first post. I thought he could only use the consoles for input but i think i might have been wrong about that now i have reread it this morning.

Thanks for the kind words though.

For the OP. If you press ATL and F2 together you will get the run command window.

In that window type


gksudo gedit /etc/hostname

You can then add your host name (the name you want to call your computer <computer_name>) using an easy interface just like notepad in Windows.

You can edit your hosts file the same way by typing


gksudo gedit /etc/hosts

In there you would add


127.0.0.1 <computer_name>


If you delete the host name, it automatically reverts to linux I believe.

or it reverts to user@localhost. At least it did on my precise install last night when i tested it.

Kind regards

GiuHei3u
March 12th, 2012, 12:20 PM
Matt,
thank you for everything yesterday. You were very patient with me and through your instruction everything is back up and running as it should. This was a great learning experience for me and some day when I am at the level to instruct other's I will remember your class act and have it as a role model.

All the best to you Matt.

Respectfully,

GumShoeGrant.