2

How can I display hostname along with user when I login to Linux machine? Now I can see only part of host name where I could not able to identify the server name. would like to display as below; For example:

[centos@yourfullhostname]$

if changed to root then

[root@yourfullhostname]$ 
1

Did you read the manual before asking the question?

PS1='[\u@\H]$ '
0

This has been answered in the Unix & Linux exchange already, but the answer is to add PS1="\H$ " to your /etc/bash.bashrc

https://unix.stackexchange.com/questions/218174/how-to-show-the-host-name-in-linux-commandline-prompt

  • 2
    Assuming "yourfullhostname" means the FQDN, \h is incorrect; it should be \H instead. – Tommiie Sep 28 '18 at 6:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.