Advertisement

Unix, change the name of the computer?

Started by January 15, 2006 10:10 PM
12 comments, last by johnnyBravo 18 years, 8 months ago
Hi I've just reinstalled solaris 10, and I some how missed setting the computer's name during the installation. How would I change the computer's name? Thanks
Look at the man page for hostname

Also, the /etc/hosts file maps your hostname to your ip. To if your localhost is foo then foo would be your computers network name...

# cat /etc/hosts::1                     localhost.andreib.com localhost127.0.0.1               localhost.andreib.com localhost192.168.0.2             zig.andreib.com zig192.168.0.2             zig.andreib.com.


So check out the manpage for /etc/hosts also.
Advertisement
When I first entered 'hostname' it showed:
unknown

So I then set the hostname like so:
hostname myunix

But when I restart the server, the hostname reverts back to unknown.

Also after setting the hostname I called 'cat hosts' it showed:
127.0.0.1 localhost
192.168.0.194 unknown # Added by DHCP

I'm a little bit confused on what exactly to do.

Thanks alot
In order for the hostname you want to be set on bootup, you need to change it in the /etc/hosts file. Also use the hostname command so you don't have to wait for a reboot for your new hostname to take effect. In short, use both (change /etc/hosts and use the hostname command), and it'll work how I think you're expecting it to.
Perhaps Solaris differs from Gentoo Linux in this regard, but I understood that /etc/hosts is only used for host lookup, not to find your hostname upon boot.

I have to set /etc/conf.d/hostname (other Linux distros use other files, so I wouldn't be surprised if Solaris used something different).
Quote: Original post by johnnyBravo
When I first entered 'hostname' it showed:
unknown

So I then set the hostname like so:
hostname myunix

But when I restart the server, the hostname reverts back to unknown.

Also after setting the hostname I called 'cat hosts' it showed:
127.0.0.1 localhost
192.168.0.194 unknown # Added by DHCP

I'm a little bit confused on what exactly to do.

Thanks alot


Edit /etc/hosts and change unknown to myunix. Run hostname myunix as root and you're set.
Advertisement
Quote: Original post by Nathan Baum
Perhaps Solaris differs from Gentoo Linux in this regard, but I understood that /etc/hosts is only used for host lookup, not to find your hostname upon boot.

I have to set /etc/conf.d/hostname (other Linux distros use other files, so I wouldn't be surprised if Solaris used something different).


Yeah solaris doesn't have a etc/conf.d

Quote:
Edit /etc/hosts and change unknown to myunix. Run hostname myunix as root and you're set.



The hosts file is read only. Maybe it has something to do with me selecting DHCP in the installation?
Quote: Original post by johnnyBravo
The hosts file is read only. Maybe it has something to do with me selecting DHCP in the installation?

You have to modify /etc/hosts as root! ;)
Deniz ÖzsenSoftware Engineerhttp://www.symbian.com/
Quote: Original post by Deniz
Quote: Original post by johnnyBravo
The hosts file is read only. Maybe it has something to do with me selecting DHCP in the installation?

You have to modify /etc/hosts as root! ;)


I'm logged in as root.
To edit it I used "vi /etc/hosts"

but when i goto save it, it gives me a read only message.

Thanks
Try a
> chmod u+w /etc/hosts
as root to set the file write-able for the owner. It probably has the write flag not set. (The syntax is valid for linux; don't know whether it is also valid for solaris, but I assume it to be.)

This topic is closed to new replies.

Advertisement