Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LS_OPTION variable 1

Status
Not open for further replies.

NiceButDim

Programmer
Feb 12, 2002
154
GB
Don’t know if this is the correct forum, but here goes… Cut a long story short, I’ve noticed that the variable LS_OPTIONS is being set at some point during a session. I think it is related to doing an ‘su’. Currently when I first log in the variable isn’t set and all ‘ls’ commands return listings in a single color. Later though listings appear in multiple colors. Does anyone know what it is that changes this variable?
Thanks, john.


john.
 
If you're using the Bash shell, when you start a login shell, it sources a file called [tt]/etc/profile[/tt], and then it sources a file in your home directory (if it exists), which can be called either [tt].profile[/tt], [tt].bash_profile[/tt], or [tt].bash_login[/tt].

Thesse are usually used to set up environment variables and other values that will be exported to any other processes (including shells) you start, and thus only need to be set once, when you first log in.


When you start a non-login shell, it reads a file in your home directory called [tt].bashrc[/tt].

This is normally used to set up aliases and other values that don't get exported, and thus need to get set for each shell instance you use.


Now, in practice, there's really no reason that a login shell shouldn't have aliases set when they do get set for other shells. So usually, users put something like the following in their [tt]~/.profile[/tt]:
Code:
if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi
This causes aliases to be set for login shells as well as for non-login shells.

If a user removed this line from their [tt]~/.profile[/tt], then their login shell might exhibit different behavior than other shells they start.


As far as [tt]su[/tt] is concerned, if you do
Code:
su - user
then you get a login shell, but if you do
Code:
su user
then you get a non-login shell. This carries the same implications for startup shells as mentioned above.


That might get you started on tracking down the problem.


An additional factoid: there's usually an [tt]/etc/bashrc[/tt] file that, while not an "official" startup file, is useful as a non-login analogue to [tt]/etc/profile[/tt]. It normally gets sourced by a user's default [tt]~/.bashrc[/tt] file. Again, a user may have changed this.
 
The ls command usually doesn't show color. Colors are show if you include the --color or --color=tty parameter to ls. Most distros will alias the ls --color command as just plain ls. You can check out your environment command aliasing with the alias command. Color definitions are stored in /etc/DIS_COLORS.


--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top