User Tools

Site Tools


wiki:set_bash_prompt_fqdn

Set bash prompt to FQDN

Set FQDN in /etc/hosts:

127.0.1.1 www.example.org example.org

Run script that changes hostname in kernel:

/etc/init.d/hostname.sh

In .bashrc change:

if [ "$color_prompt" = yes ]; then
  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
  PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

to

if [ "$color_prompt" = yes ]; then
  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@$(hostname -f)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
  PS1='${debian_chroot:+($debian_chroot)}\u@$(hostname -f):\w\$ '
fi

Logout then login again.

Tested on

  • Debian 8 Jessie

See also

References

wiki/set_bash_prompt_fqdn.txt · Last modified: 2022/11/01 11:07 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki