[SOLVED] bash prompt doesn't change from $ to # for su
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to change the bash prompt and based on the man pages \$ should show a $ which changes to a # for a SU. However, this doesn't happen on my machine, it's $ for both user and SU.
The line in .bashrc is:
export PS1="\u@\h:\w\$"
I assume you mean the prompt for root. You will have to edit root's .bashrc for that. It is located in /root/.bashrc.
Also: Make sure that you use
su -
to switch to root. This will give you a full login shell where root's .bashrc is definitely being sourced.
Well if it is symlinked to the same thing ... why would it change?? Remembering '\$' means take away the special meanings for the $ sign to give you a $ sign.
so I su and do echo $EUID and I get 0
which means, as I understand, that the $ should turn into a #. why does the symlink change anything? it's just a pointer to a .bashrc file to run.
note the PS1 line is in double quotes (so it shouldn't be a literal $):
export PS1="\u@\h:\w\$"
so I su and do echo $EUID and I get 0
which means, as I understand, that the $ should turn into a #. why does the symlink change anything? it's just a pointer to a .bashrc file to run.
note the PS1 line is in double quotes (so it shouldn't be a literal $):
export PS1="\u@\h:\w\$"
I still think it is better to not link root's bashrc to a user ones. However, if you want to keep it that way then you have to replace the double quotes with single quotes - as suggested be kenhelm. Then you will get the '#' when you switch to root. Make sure to check if there are several branches which set PS1 in your script. If you are not sure which one sets the prompt then make sure to change all of them to single quotes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.