LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (http://www.linuxquestions.org/questions/fedora-35/)
-   -   How to change hostname on shell [user@tochange] (http://www.linuxquestions.org/questions/fedora-35/how-to-change-hostname-on-shell-%5Buser%40tochange%5D-518581/)

guarriman 01-12-2007 04:00 AM

How to change hostname on shell [user@tochange]
 
Hi.

I'm using Fedora Core 2, and would like to change the hostname
on my shell:
--------
[user@pc04]#
--------
(I'd like to change from pc04 to pc-john)

I've been investigating, and I could edit these files:
/etc/sysconfig/network
/etc/hosts

Is this the way or must I change other parameters?

Thank you very much,

reddazz 01-12-2007 04:01 AM

Thats the right way to do it.

koca 01-15-2007 01:04 AM

hi,
it depends what you want exactly. If you want change hostname too, you can change it +- how you describe. But if you want change just hostname on shell, you can modify variable $PS1 which is your variable shell prompt which is displayed.
Ie:
if you want to have this one :
[user@pc04]#
instead
[user@hostname]#
you set $PS1 variable as : export PS1="[\u@pc04]#" - you can try to run this command under shell console to see what happened. If you want set up it permanently when you logon, just append it to your .bashrc or .bash_profile or .profile file (it depend on shell when you are using).
Here you are some other possibilities for change PS1:
# \t - time
# \d - date
# \n - newline
# \s - Shell name
# \W - The current working directory
# \w - The full path of the current working directory.
# \u - The user name
# \h - Hostname
# \# - The command number of this command.
# \! - The history number of the current command


All times are GMT -5. The time now is 09:30 PM.