Jump to content

Change hostname


LLfan

Recommended Posts

Alright, I did a google search on how to do this and came up with 3 solutions:Option 1 = Edit: /etc/hosts Option 2 = Edit: /etc/sysconfig/networkNow, I do not want to edit anything I can royally mess up, so could someone walk me through how to do this step by step on my Mandrake Linux 9.1 pc?Mike

Link to comment
Share on other sites

Are you trying to change how you name the host where you connect to the Internet? If so did you look at going to the Mandrake Control Center -->Network and Security-->Configure hostname?

Link to comment
Share on other sites

Sorry should have been clearer. When I open up my terminal I get: [mike@x1-6-00-0a-e6-15-9e-4b mike] which isn't too appealing to mine eyes. =)I ran hostname in the terminal and got: x1-6-00-0a-e6-15-9e-4bThat is nonsense to me and I would like to change it as long as it will not effect my internet connection.Sorry I wasn't more clear. B) Mike

Link to comment
Share on other sites

Hostname is used to connect to the Internet if I have it correctly. That looks like it is including your MAC address. Does your connection tie in to the specific computer? If so it might require the MAC address. If I type hostname in a terminal I get "localhost" which is the default when you don't give it a name. That leads me to believe that is what your connection requires.

Link to comment
Share on other sites

Hostname is used to connect to the Internet if I have it correctly.  That looks like it is including your MAC address.  Does your connection tie in to the specific computer?  If so it might require the MAC address.  If I type hostname in a terminal I get "localhost" which is the default when you don't give it a name.  That leads me to believe that is what your connection requires.
I am on a cable modem and it is not connected directly but to a hub which connects to the modem.
Link to comment
Share on other sites

Miketry:# hostname new_nameand close the console and open it again . . . did that help ??B) BrunoVery strange prompt you have . . .
No good Bruno--I didn't get an error, but it didn't seem to change anything--I closed and opened it again and still the same.
Link to comment
Share on other sites

MikeHere we go:As root: # SAVE=$PS1 # vi /home/mike/.bashrc i ( to put vi in insert mode ) and type: PS1="[\u:\w]$ " ( watch the space between $ and " ) Esc ( to put vi back in command mode ) ZZ ( 2x capital Z to save the file ) Ctrl+D to log out as root Ctrl+D to close the console Open the console again and tell me if you like what you see . . be very careful typing . . .B) Bruno

Link to comment
Share on other sites

MikeHere we go:As root: # SAVE=$PS1 # vi /home/mike/.bashrc i ( to put vi in insert mode ) and type: PS1="[\u:\w]$ "  ( watch the space between $ and " ) Esc ( to put vi back in command mode ) ZZ ( 2x capital Z to save the file ) Ctrl+D to log out as root Ctrl+D to close the console Open the console again and tell me if you like what you see . . be very careful typing . . .B) Bruno
CHecking for mandrake updates...so will try in a bit. =)Thanks, will let you know how it goes. What exactly is that doing--remember I am new to Linux, B)
Link to comment
Share on other sites

It backs up and tweaks your prompt . . . . . to:[mike:~]$nice short and effective . . . B) . . . plus it will show the directory you´re in . . ¨~¨ is the ¨/home¨ it starts off with . . if you do ¨cd /mnt¨ it will change to:[mike:/mnt]$Is that okay for you ?? ( there are other options if you want it longer )B) Bruno

Link to comment
Share on other sites

MikeAnytime you go into Vi or Vim you are editing files that you use to run Linux. That is why you always have to be very careful. When in Vi you always use an "i" to put it in insert mode. Then when you are done making your changes you do the escape to take it back out of insert mode and then two capital Zs to save the file followed by the two Control Ds to take you back out of it. It is something you will go to when you need to do some editing to change a configuration in a file. It is always a good idea to save your file first so you can restore it if you goof up and then to check everything again before you press save. Good luck with it. As long as you pay attention to details you will be fine.

Link to comment
Share on other sites

It backs up and tweaks your prompt . . . . . to:[mike:~]$nice short and effective . . . B) . . . plus it will show the directory you´re in  . . ¨~¨ is the ¨/home¨ it starts off with . . if you do ¨cd /mnt¨ it will change to:[mike:/mnt]$Is that okay for you ?? ( there are other options if you want it longer )B) Bruno
That is perfect Bruno--thank you.Teacher, thank you for the added explanation, I always feel I learn best if I fully understand the workings of it. I will try this later today when I get time, thanks.Will definately let you know how it goes.
Link to comment
Share on other sites

MikeHere we go:As root: # SAVE=$PS1 # vi /home/mike/.bashrc i ( to put vi in insert mode ) and type: PS1="[\u:\w]$ "  ( watch the space between $ and " ) Esc ( to put vi back in command mode ) ZZ ( 2x capital Z to save the file ) Ctrl+D to log out as root Ctrl+D to close the console Open the console again and tell me if you like what you see . . be very careful typing . . .B) Bruno
Alright, got it to where it is: [root:/home/mike]$However, "Esc ( to put vi back in command mode ) ZZ ( 2x capital Z to save the file )"I hit escape and nothing seemed to happen. Nevertheless I typed in ZZ and got "bash: ZZ: command not found"Did I do something wrong?
Link to comment
Share on other sites

[root:/home/mike]$
Are you logged in as root ??
I hit escape and nothing seemed to happen.
As you hit escape you indeed see nothing happening but ZZ should then not return an error message . . . . Could you do:cat /home/mike/.bashrcand paste me the things you see in the next post ?B) Bruno
Link to comment
Share on other sites

[root:/home/mike]$ cat /home/mike/.bashrc# .bashrc# User specific aliases and functions# Source global definitionsif [ -f /etc/bashrc ]; then        . /etc/bashrcfi[root:/home/mike]$

Hope that makes sense to you! =)

Link to comment
Share on other sites

Well it does Mike . . . the changes you made are not in there . . the file was not saved correctly, you will have to do it again.Now let me be clear on the saving of the file:Esc ( puts the vi editor in commandmode, vi has an ¨insert¨ and a ¨command¨ mode . . i puts it in ¨insert mode¨ and Esc puts it back in command mode . . . ZZ is the ¨save¨ command for vi )If by any chance starting vi like:# vi /home/mike/.bashrc brings an error, it means there is a swapfile we have to delete first, you can see that in Konqueror if you set it to show ¨hidden¨ files . . . it will have a green icon and be called .bashrc~ ( don´t delete the normal .bashrc )Hope you´re still following . . . . B) Bruno

Link to comment
Share on other sites

Still following...will attempt to do it again, but I am not sure why the save did not go through. Have to get back to work but will certainly try this later in the day and let you know how it goes and if I had to delete the file.Mike :)

Link to comment
Share on other sites

MikeEvery once in a while that seems to happen. When it does, if you don't get rid of that swap file then you are in for troubles. I am not sure whether it is a fluke in the program or whether we accidently brush the wrong keys. It has happened to me a time or two and it is a pain to recover from unless you use the Konqueror to find that hidden file and remove it. Good luck.

Link to comment
Share on other sites

MikePerhaps do an excercise first:vi Tesst ( will open an empty textfile called Tesst )i ( insert mode )type away some text just a few linesEscZZthen:cat /home/mike/Tesstand see if the lines you typed are there . . . then do:vi Tesst ( it will open the same file )i ( insert mode )make some changes in the textEscZZcat /home/mike/Tesstand see if the changes sticked . . if so you´re an expert in vi and you can delete the Tesst file . . :DThen start with the .bashrcand put the line I gave you:

[root:/home/mike]$ cat /home/mike/.bashrc# .bashrc# User specific aliases and functionsHERE# Source global definitionsif [ -f /etc/bashrc ]; then    . /etc/bashrcfi[root:/home/mike]$
Good luck Mike !!:) Bruno
Link to comment
Share on other sites

MikeThe trick to showing hidden files is first you have to have Konqueror on a folder such as home. If it is in a web browser mode, you can't change it. I usually click on the home button (the house) and then go to View-->Show Hidden files. You will know it is a hidden file because it will have a period in front of it such as ".gnome". :)

Link to comment
Share on other sites

Alright, there is no .bashrc~ and no green icon. I'd attach a screen shot but don't think it's possible.What do you make of this? There is a bash_history, bash_logout, bash_profile, and bashrc, but NO green icon and no bashrc~ :)

Link to comment
Share on other sites

You did see lots of hidden files other than the .bashrc? I have lots of hidden files. If you have a lot of hidden files but no .bashrc~ then we are okay. Do you need to go to View--> Sort and sort by date or name to make sure it is not just separate from the rest? If you sort by date it should be one of your most recent files.Just reassure me first that you have double checked and you can see the other hidden files. If so, and it is not there, then you should be able to do your editing. That would mean we don't have a bad copy to get rid of first! You would then be ready to open your console, go back into vi and edit your .bashrc. Ready?

Link to comment
Share on other sites

Surprisingly enough, I don't have the option to sort by date. But I did sort by name, and yes I see about 30 directories and files that were not there before. Alright, I will go and try this 1 more time. =) If I don't post back in 5 mins. email yourself, Bruno, and a general PC practitioner my way as I have broken my pc. :)

Link to comment
Share on other sites

Okay. Just remember to go slow and be careful. If you do it just as Bruno posted it you will be okay. We will send out the search penquins for you!

Link to comment
Share on other sites

Same problem. Everything works OK, then I hit escape, nothing happens, and then ZZ gives bad command.I did notice this however, after I hit Escape, I Held the shift key to get my 2 capitalized Zs and the first one did not show. Did it again and same thing, so I have to do it 3 times just to display 2 zs.<edit>Once again, no .bashrc~ created.

Link to comment
Share on other sites

When you press the Escape key it does not show anything. When you press the first Z it shows up at the bottom middle and the second Z should give you the command prompt.Let's try a different way to do this. With your hidden files showing.1. Rightclick on .bashrc2. Select open with > kwrite3. PS1="[\u:\w]$ " ( watch the space between $ and " )4. Save your file (but do not add an extension to it). That should do your editing and save your file.

Link to comment
Share on other sites

I hope this way works for you. However, the best way to edit is using vi as there is less chance of corruption in your files. Command line does not use an editor not designed for it and it doesn't add anything to it that should not be there. You don't run any risk of accidently saving it as a text file when in vi either. At lesat you don't have a bashrc~ file for us to worry about. That is good. Now let us know how your results worked using KWrite.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...