You are not logged in.
Pages: 1
I was following the Archwiki guide on colouring the bash prompt and found that if I open gnome-terminal and use 'su root' I get a colourised prompt but if I used 'su - root' which I found out to be the same as 'su -l root' then I didn't.
Some further research told me that -l makes the shell a login shell but I still don't really understand what that is or how it is any different. Can anyone enlighten me? Thankyou.
Offline
A shell will produce a different environment when started as a login shell than when not. You should read your shell's manpage for a description of the process. Assuming you are using bash as your shell, you would want to read the section titled INVOCATION.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
I may be mistaken, but I believe the major difference is that when you su using a login shell, all of the login scripts for that shell run when it is instantiated. On my system, that includes changing to the new user's $HOME.
Without the -l, the system changes to the new user, but things like the CWD and PATH remain unchanged
For the purposes of system administration where you are switching to root, I don't think it matters which you use -- unless you do or don't what to change the environment.
[edit: added a missing verb. Note to self: Don't post when you are tired]
Last edited by ewaller (2010-05-29 14:41:48)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
So in normal use, there's no issue using su -l or just su?
Offline
So in normal use, there's no issue using su -l or just su?
I would say that is true. In practice, I almost always use sudo. The only time I actually change to root is if I'm trying to write to a pipe to a second program which also needs root privilege. I am too lazy to figure out the correct incarnation for that. I don't believe I have ever used su -l
edit: fixed typo
Last edited by ewaller (2010-05-29 16:08:12)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
In a nice way to put it, without -l, it will just change users. With it, it will take that user to their home directory and use their config files.
Hope I was right on that one
Offline
The common solution is to source ~/.bashrc from ~/.profile, e.g. add
. $HOME/.bashrc
to ~/.profile
So that your bashrc gets sourced regardless of whether it's a login shell or not.
Offline
Thankyou all
Offline
Pages: 1