Skip to main content
GameDev.net gamedev.net
🔒 Locked

Unix, change the name of the computer?

Started by johnnyBravo Jan 15, 2006 at 10:10 PM 12 replies 1.9k views
Original Post
johnnyBravo
johnnyBravo
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
realgames
realgames
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.
johnnyBravo
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
Corfe
Corfe
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.
Nathan Baum
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).
realgames
realgames
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.
johnnyBravo
johnnyBravo
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.

[/quote]

The hosts file is read only. Maybe it has something to do with me selecting DHCP in the installation?
Deniz
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! ;)
johnnyBravo
johnnyBravo
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
haegarr
haegarr
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.)
johnnyBravo
johnnyBravo
Quote:
Original post by haegarr
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.)


Ah I was able to edit after setting the write flag, but after I restarted the machine, the hosts file had reverted it back to 'unknown'.

Quote:
Original post by Anonymous Poster
In Solaris you normally create a /etc/nodename with the name of the hostname and edit /etc/rcS.d/S30network.sh from


I found the /etc/rcS.d/ folder, but nothing resembling 'S30network.sh'.

Thanks.
johnnyBravo
johnnyBravo
Quote:
Original post by Anonymous Poster
Try creating it and see if it helps? ;)


Oh sorry :), some how I missed the 'create' part of the message.

It works fine now, thanks alot.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.