1833767 Members
2395 Online
110063 Solutions
New Discussion

Modify hostname

 
SOLVED
Go to solution
j773303
Super Advisor

Modify hostname

Is it possible modify hostname only affect on current telnet session?

For example: Assume hostname=HOSTA
In telnet Session1: Modify hostname to HOSTB

In telnet Session2: the hostanme still HOSTA

Thanks a lot.
Hero
12 REPLIES 12
Sivakumar TS
Honored Contributor
Solution

Re: Modify hostname


Hi,

NO, It is not possible.

May be you can set the hostname temporarily by #hostname HOSTB which will be appilcable till next reboot or next time you change the hostname using #hostname command. But whenever you change the hostname it WILL be applicable for ALL users/sessions connected to the server.

Regards,

Siva
Nothing is Impossible !
Yogeeraj_1
Honored Contributor

Re: Modify hostname

hi,

assuming the application or the script that you are going to work with it queries the hostname environment variable, you can just do:

export HOSTNAME=HOSTB

unfortunately, the hostname HOSTB command will not work! it does the change across the system

good luck

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Arunvijai_4
Honored Contributor

Re: Modify hostname

Hi,

It is not possible. Once you modify the hostname it affects the entire system. Who ever logs in, will see HOSTB, not HOSTA.

Hope this is clear.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Senthil Prabu.S_1
Trusted Contributor

Re: Modify hostname

Hi,
It is impossible to my knowledge.
But, possible to change the hostname in all sessions temperiorly, by executing

$hostname


HTH,
Prabu.S
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Muthukumar_5
Honored Contributor

Re: Modify hostname

Yep.

Use like,

# hostname

# uname -S

--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Modify hostname

If you are changing with hostname then it will be using same hostname until reboot. For different sessions you have to setup hostname. Else put it in $HOME/.profile.

If you want to have original hostname then /sbin/init.d/hostname stop;/sbin/init.d/hostname start will give that.

--
Muthu
Easy to suggest when don't know about the problem!
Senthil Kumar .A_1
Honored Contributor

Re: Modify hostname

Hi,

Please do not change the hostname using "hostname" or "uname",Though temperory this could cause trouble to the apps which are already refering the system with the old hostname.

Ex: CDE sessions for instance.

First let us know what is the purpose you are trying to achieve in wanting to do so.

Probably, someone here could provide a workaround solution based on your requirement.

Regards,
Senthil Kumar .A

P.S: Furthermore,I would stongly discourage doing so in production systems.More over only root can set the hostname temperorily using "hostname" command, so u can realize the gravity of doing the same right....
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Yogeeraj_1
Honored Contributor

Re: Modify hostname

hi,

just one clarification. (did test it)

hostname HOSTB

command will change the hostname of the server at system level. Such that all sessions will be affected. Even those already connected. The hostname value will change for all sessions!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Arunvijai_4
Honored Contributor

Re: Modify hostname

Hello,

You can find more information by looking at the man page, # man hostname

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Deepak.R
Frequent Advisor

Re: Modify hostname

Hi,

I would go with Senthil Kumar,

Pls be clear with your objective before going ahead and changing hostname while system is up and running. Your applicattions would go for a toss.

thanks
deepak
Deepak.R
Frequent Advisor

Re: Modify hostname

Hi,

I would go with Senthil Kumar,

Pls be clear with your objective before going ahead and changing hostname while system is up and running. Your applicattions would go for a toss.


thanks
deepak
rick jones
Honored Contributor

Re: Modify hostname

Sooo, _why_ do you want to change the hostname for a specific telnet session?

I suppose, that someone _really_ careful could replace the hostname command with a script and move the real hostname command somewhere that a shell user might not normally find it. Of course, that itsn't terribly robust, and there would still be the issue of the uname command, and then applications launched from that telnet session that called gethostname() and such...
there is no rest for the wicked yet the virtuous have no pillows