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.
You can name it whatever you want or need it to be for a server etc...Just do a netconfig or edit the HOSTNAME, NETWORKING and hosts files and change it to what you need...
although the name of the machine is usually the same as it's network name, it's not law, so isn't inter-related
in order to be able to ping the name you need to add the entry to /etc/hosts, but that's for a network, which is where the difference comes in, you only need to ping your own machine if you're on a network, so you don;t need to worry about that if you're only on a standalone box. 127.0.0.1 is always localhost, as that's an internal, pretend network, but i guess you might get away with adding the host name after it, not really that useful tho, as far as i can see.
ok, so reading your post again i get a little bit the wrong end of the stick.. but i hope some of that is useful. the hostname is network based, nothing to do with 127.0.0.1
Well, it's easier if you can do a netconfig and it'll prompt for answers, but not ever distro has it. It depends on what you are wanting to do. I assume in KDE the network config could work just as well. Your dynamic connection shouldn't matter if you are only configuring the "cosmetic" name for your machine. The 127.0.0.1 is in ever distros files. That IP allows the box to work as a loopback device so that you don't have to have a network. I guess i'm confused as to what exactly you want it used for? Let us know...Now i'm conflustered.. LOL
Using the command hostname, what do you use that name for?
You can just add an extra entry to /etc/hosts with your IPand name you want can't you?
But then if you have another machine you want to connect to it with and you want to use your machine name instead of IP don't you have to have a hosts file on the new machine with the name of the first machine in it?
And you can't do this with DHCP assigned addresses can you?
Basically the ultimate goal is just so that I can ssh or ftp to servername and not IP. I guess that's my long term goal here.
If I use a static IP address on this machine and put an extra entry into /etc/hosts like:
myipaddress myhostname alias
then it works and I can ping that name and alias.
BUT
1. The hostname command will change the hostname only temporarily. Upon reboot it will revert to whatever is in the /etc/hosts file. So I still don't know why you would use the command hostname.
2. What do you do if you have a DHCP assigned address instead of a static one?
Originally posted by acid_kewpie although the name of the machine is usually the same as it's network name, it's not law, so isn't inter-related
in order to be able to ping the name you need to add the entry to /etc/hosts, but that's for a network, which is where the difference comes in, you only need to ping your own machine if you're on a network, so you don;t need to worry about that if you're only on a standalone box. 127.0.0.1 is always localhost, as that's an internal, pretend network, but i guess you might get away with adding the host name after it, not really that useful tho, as far as i can see.
ok, so reading your post again i get a little bit the wrong end of the stick.. but i hope some of that is useful. the hostname is network based, nothing to do with 127.0.0.1
The actualy hostname of a machine is configured by the /etc/HOSTNAME file. what the /etc/hosts file basically is a precursor to DNS. You can read up on the details by doing a man hosts and man hostname
as someone said before, the easiest thing to try is a
# hostname thenameyouwanthere
but i have had systems where that hasnt worked. if you have a mainstream distro, there are almost always GUI tools to configure this. even slackware has a GUI for it (a rarity in slackware). netconf, netconfig are things you might be trying.
Failing that, try linuxconf on redhat or yast2 on suse
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.