Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi:
My prompt, when in the CLI, is of the form element1@element2:/#<present working dir> '.
Assuming I'm root, which I am, element1= 'root'. And I'd like to change element2. I issue
'hostname john', logout and login, and there is 'john' as element2. Fine. But if I reboot, element2 is no longer 'john' but the old one.
Code:
> less /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
# For loopbacking.
127.0.0.1 localhost
127.0.0.1 my_base_hostname.my_domain_name my_base_hostname
# End of hosts.
Modifying the third field in the second line has no effect. I can reboot but element2 is still in the prompt. I guess I can change the prompt by specific commands, but what I want to change, besides the prompt, is the hostname. Also, TCP/IP is mentioned above and perhaps all this has only to do with internet (or whatever its name is). However, in the hostname manual page they speak of the system host name and say /etc/hosts is consulted at boot time. So, "system host name" and the two lines in /etc/hosts are related.
/etc/hosts maps an IP address to a hostname. That's all. It doesn't change a system's hostname, it doesn't change your prompt.
If you want to change your PC's name, the best way to do it is from the GUI system administration tool. For example, in OpenSUSE, you might use "Yast, network configuration". In Slackware, you might want to use "netconfig".
If you want to change your prompt, you can do it on a per-user basis by editing your "$HOME/.bashrc" initialization file:
/etc/hosts maps an IP address to a hostname. That's all. It doesn't change a system's hostname, it doesn't change your prompt.
If you want to change your PC's name, the best way to do it is from the GUI system administration tool. For example, in OpenSUSE, you might use "Yast, network configuration".
If you want to change your prompt, you can do it on a per-user basis by editing your "$HOME/.bashrc" initialization file:
I did 'hostname darkstar', then I booted. Miracle. The prompt now says root@darkstar if I'm root. But in KDE, Kmail notifies: 'Kmail already seems to be running on my_base_hostname'. The thing is that before hostname, I had run netconfig, although I made an early quit. What now?
I did 'hostname darkstar', then I booted. Miracle. The prompt now says root@darkstar if I'm root.
OK.
Quote:
But in KDE, Kmail notifies: 'Kmail already seems to be running on my_base_hostname'.
Do you literally mean my_base_hostname or are you unwilling to post the real name?
Quote:
The thing is that before hostname, I had run netconfig, although I made an early quit.
So you have half-configured things, not let things finish and "made an early quit"?
Quote:
What now?
Maybe this is a question you should have asked yourself before you chose to "make an early quit".
Because I have no idea how badly you have managed to mess things up so far. Please post the output of
Code:
cat /etc/hostname
I discovered some years ago that changing the hostname is not something to be undertaken lightly. I was completely locked out for several hours while I searched for a solution. Eventually I was able to fix it.
Perhaps linux distros are more robust now. Perhaps not: Most people never change the hostname.
But if all you want to do is change your terminal prompt, then the link you were given at post #4 by paulsm4 would have fixed it.
My final clarification question is this: Do you just want to change your terminal prompt, or your machine's hostname?
Thanks tredegar for your reply. I'll make myself clear.
(a) I literally mean my_base_hostname. This is the old name. The new one is darkstar.
(b) About netconfig, in the middle of it I became afraid of netconfig making things worse. So I quited it.
(c) /etc/hostname is does not exist in my system. I pass you /etc/hosts:
Code:
root@darkstar:~# cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
# For loopbacking.
127.0.0.1 localhost
127.0.0.1 darkstar.example.org darkstar
# End of hosts.
root@darkstar:~#
(d) Terminal prompt: I'm not specially intrested in it, although I'm tired of seeing 'my_base_hostname' all the time. And I would like it to be a reflex of the base hostname.
(e) (d) may be obscure. Let's limit ourselves to the machine's hostname, although fixing the problem my modification originated is of priority here. To answer your final question, I want to change the machine's hostname.
Edit: I do not care about Kmail any more, because I've made up my mind to use mailx, the cli application. Nor do I mind about loosing my mail, although several hours of grep running should tell me where in the disk it is. So, I invite you to continue our chat in the forum Linux-General, in the thread by title 'About mailx'. I think it's an entirely new matter.
How stupid of me. Of course I must firstly fix the hostname problem. So I'll CONTINUE TO posting on this forum for the moment. Regards.
If you want to change your PC's name, the best way to do it is from the GUI system administration tool. For example, in OpenSUSE, you might use "Yast, network configuration". In Slackware, you might want to use "netconfig".
The problem is that changing "hostname" typically involves changing a couple of different files - using a tool like "netconfig" makes it easier to avoid making any mistakes.
The problem is that changing "hostname" typically involves changing a couple of different files - using a tool like "netconfig" makes it easier to avoid making any mistakes.
'Hope that helps .. PSM
Hi:
It's kind of you, Paul, to have posted again. I've run netconfig again and I see I can set any hostname I wish with at most the penalty of having to reset the cable modem and rebooting. My connexion is DHCP. Last time I ran netconfig it left things this way:
Hostname: my_base_hostname [I went back to the old one]
Domain name: example.org
IP address: (use DHCP server)
Netmask: (use DHCP server)
Gateway: (use DHCP server)
Nameserver: (use DHCP server)
I have internet connectivity, and my system, AFAIK runs OK, KMail left aside. What I am now really interested is in running mailx (aka mail or a renewed version of the traditional mail). I have read the manual all throu and will keep reading it until I understand what's the key to make it work.
All I ask you, for the moment, is if the above settings (netconfig) are pertinent to proper functioning of mailx. Regards.
@frankbell: Excuse my delay, frankbell.
Quote:
In my Slackware box, the host name is in /etc/HOSTNAME, not /etc/hostname.
The same in mine:
>cat /etc/HOSTNAME
my_base_hostname.example.org
Whereas etc/hostname looks like
# For loopbacking.
[ip address 1] localhost
[ip address 1] my_base_hostname.example.org my_base_hostname
I use DHCP. So, as you have made me see, there is no need for other entries. Actually, my problem has shifted in the direction of a proper utilization of mailx. What you've seen above are the settings made by netconfig, run as root from the text mode console. I see I must create an account in order to send or receive mail. I quote from mailx manual:
First you need the following data from your ISP: the host name of
the IMAP or POP3 server, user name and password for this server,
and a notice whether the server uses SSL/TLS encryption.
Say the first three data are
POP3 server host name= xxx.com.ar
User name= me
Password= pwd1
where xxx only contains alphabetic chars. (namely, chars 'a' through 'z'). What do I do with them? I understand the man pages must be written in a rather technical language or otherwise they'd be tutorials. But how can I create an account? Regards.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.