You are not logged in.
Hi, sometimes when a type su and insert the root password, in the shell appears bash-3.2#; other times appears root@galahad and this is ok.
Only is when a type su, with su - always appears my root@galahad in my shell.
What is wrong with the command su?
Greetings
Last edited by aqamar (2009-05-05 03:05:28)
Offline
man su
man bash
running `su -` makes it a login shell which --i believe-- affects what files are sourced and can therefore affect the variable $PS1 which determines your prompt; running just `su` is not a login shell and that must mean whatever file defines your root's $PS1 is not being sourced. hence the bash fallback prompt.
me, in both my ~/ and root's home /root/ i have a .bash_profile which sources a .bashrc which defines a PS1 string. i get the correct PS1 with `su` or `su -`
i hope all that made sense.
┌─[ 12:23 ][ blue:~ ]
└─> cat .bash_profile
. $HOME/.bashrc
┌─[ 12:23 ][ blue:~ ]
└─> grep ^PS1 .bashrc
PS1="\[$B\]┌─\[$W\][ \[$Y\]\A \[$W\]][ \[$G\]\h:\w \[$W\]]\n\[$B\]└─\[$Y\]> \[$W\]"
┌─[ 12:24 ][ blue:~ ]
└─> su
Password:
[ blue /home/patrick ] > exit
exit
┌─[ 12:24 ][ blue:~ ]
└─> su -
Password:
[ blue ~ ] > cat .bash_profile
. $HOME/.bashrc
[ blue ~ ] > grep ^PS1 .bashrc
PS1="[ \[$R\]\h \w\[$W\] ] > "
[ blue ~ ] > see the difference?
edit: i really should use Preview before Submit sometimes.
Last edited by brisbin33 (2009-05-05 13:25:26)
//github/
Offline
I can confirm the 'issue', but I don't know where one should look to fix it. The thing is, a regular su will give you root permissions but not the PATH values of the root user (and other environment variables). Su - will give you a 'full' root session, and also its prompt.
Edit: #8 from this topic may provide the answer, but I'm at work, so I can't check .
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
running `su -` makes it a login shell which --i believe-- affects what files are sourced and can therefore affect the variable $PS1 which determines your prompt; running just `su` is not a login shell and that must mean whatever file defines your root's $PS1 is not being sourced. hence the bash fallback prompt.
Correct.
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
I can confirm the 'issue', but I don't know where one should look to fix it. The thing is, a regular su will give you root permissions but not the PATH values of the root user (and other environment variables). Su - will give you a 'full' root session, and also its prompt.
Edit: #8 from this topic may provide the answer, but I'm at work, so I can't check .
i get the correct prompt with both 'su' and 'su -' by simply having /.bash_profile -> /.bashrc in _both_ my ~/ and /root/ if that's the behavior you want, that's the way to do it. the 'difference' i was showing in the second part of my earlier post was simply that 'su -' moves root into his home (/root/) while 'su' keeps him in the cwd (/home/patrick/). the prompt works either way though.
//github/
Offline
@brisbin33: thanks a lot, i copy all my ~/.bash* to /root/ and now always show "root@myhost"; who knows why sometimes show "bash-3.2" and othertimes "root@myhost"... BTW: your PS1 rocks!!!
sometimes have a feel of hate/love to archlinux, because is helping me to learn and dont be lazy
Offline