I am trying to change my prompt to my hostname (Aidan) I used
PS1=“\h \d \u]"
when I used it, it only changed to “localhost” does anyone know what I am doing wrong? I have the user created in the GECOS field with the full name.
If you want the user's real name from the GECOS field, I think you need to fetch it manually. I don't think there's a way to do it automatically, at least in Bash.
So,
gecos=$(getent passwd $USER | cut -d: -f5 | cut -d, -f1)
PS1='$gecos ... \$ '
You need to change the contents of /etc/hostname to the actual name of your host, and then reboot. You can change the name of your host for the current session using the 'hostname' command (if logged in as root), but any change you make will be lost on the next reboot if you have not also updated /etc/hostname .
/etc/passwd
.
“
a typo? (Note the difference with a regular double quote character,"
)hostname
?"
be replaced with“
or”
. Also, please add information such the expected and actual prompts to your question (instead of doing it in comments), since comments may be deleted and are less readable.