Show full hostname in bash?

7,627

Solution 1

The bash prompt is configured by the PS1 variable. You can configure it simply by setting the variable for example like this:

export PS1="$(hostname -f):~$ "

If you want to make the configuration permanent you can put the export command in your ~/.bashrc file.

I recommend reading the ArchWiki Page for more information.

Solution 2

For Debian 10 open file located at: /etc/bash.bashrc

change 21st line from:

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$

to:

PS1='${debian_chroot:+($debian_chroot)}\u@\H:\w\$

\h becomes \H

then do following command:

source /etc/bash.bashrc

or restart your bash session/relogin.

Share:
7,627

Related videos on Youtube

Flash Thunder
Author by

Flash Thunder

I don't know everything, but I like to learn new things.

Updated on September 18, 2022

Comments

  • Flash Thunder
    Flash Thunder over 1 year

    Any way to show full hostname in bash instead of partial?

    Now for domain.com it's:

    user@domain:~$

    Would like it to be:

    [email protected]:~$

    Debian 8.5

  • Flash Thunder
    Flash Thunder almost 8 years
    seems that changing \h to \H worked aswell... anyway... how do I set it up so it would automatically use modified bashrc on adduser?
  • Henrik Pingel
    Henrik Pingel almost 8 years
    Configuration files for new users are stored under /etc/skel. unix.stackexchange.com/questions/26607/…