'hostname some_name' does not change the hostname.
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
hostname will print the name of the system as returned by the gethostname(2) function.
The host name is usually set once at system startup in /etc/rc.d/rc.inet1 or /etc/init.d/boot (normally by
reading the contents of a file which contains the host name, e.g. /etc/hostname)
So I guess that you need to reboot for the change to take effect.
If you run say 'hostname my_new_host' as root
and then run just 'hostname' does it give the right answer?
I think it should change it, but on your bash prompt for example, it might not change till you logout and log in. I think on reboot it will change back to whats in your hostname conf file if you don't change it there (/etc/HOSTNAME )
Yes, I had to edit /etc/HOSTNAME. But then, I need to do two things. (1) Edit that file. (2) Run hostname. Why does the hostname command not modify /etc/HOSTNAME? It would be easier.
/etc/HOSTNAME
This is where your computer's hostname is defined.
May I suggest that you start READING about Slackware, which would prevent all the needless questions I've seen in the past weeks (months?). Please use http://docs.slackware.com/ - it's why we have setup that site.
hostname is a linux command interacting only with the linux kernel (syscall). So it only changes the running kernel's "hostname" parameter.
It does not change any configuration file.
If you want to make changes persistent, you must perform what netconfig does:
- change /etc/HOSTNAME
- change /etc/hosts, the line related to 127.0.0.1 with the host name
- change /etc/NetworkManager/NetworkManager.conf "hostname=" line (if used)
- change /etc/hosts, the line related to 127.0.0.1 with the host name
127.0.0.1 is localhost and localhost only, and should not be changed to any other host names or numerous things break.
In special cases, you can add an entry with the official IP adress of the machine and its host name to /etc/hosts. But the better practice is to have a working DNS setup and completely keep away from /etc/hosts. It's obsolete anyway.
If my questions were needless I do not think I would be asking them. Anyways, needless or not, I'll make the questions that come to my mind.
stf92, I have noticed that you like using various UNIX/Linux commands in ways that they're not designed in the first place. My recommendation to you: read the fine Slackbook from the first to the last page. Try out all the commands you find in it. Play with them.
Swim from one end of the pool to the other. Then come back and ask questions, and I'm sure folks here will be pleased to answer them.
127.0.0.1 is localhost and localhost only, and should not be changed to any other host names or numerous things break.
In special cases, you can add an entry with the official IP adress of the machine and its host name to /etc/hosts. But the better practice is to have a working DNS setup and completely keep away from /etc/hosts. It's obsolete anyway.
FYI: The netconfig script that is still included with Slack 14.0 will write the hostmane (and domain) into this file.
If you've given the system a hostname during the install, /etc/hosts must be edited if you decide to change the system hostname and DO NOT use the netconfig script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.