LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   ls in color for user and su -, but not su (https://www.linuxquestions.org/questions/slackware-14/ls-in-color-for-user-and-su-but-not-su-59455/)

itsjustme 05-12-2003 05:45 PM

ls in color for user and su -, but not su
 
In the initial terminal after booting and before startx, as user and as 'su -', I see the blue directory entries and those light blue files with the ampersands on the end of them and the other white files. And in some directories I see the red files, which appear to be compressed files. And then there are the yellow files in /dev.

If I just do 'su', all the files and directories show up as white, no colors.

Just curious why that is.

Incidentally, this is part of my iniitial foray into slackware and I'm still fairly new to linux in general.
Also, is there a link to some document that describes the different colors used for listing files and directories, or is that just something that you figure out as you go?

Thanks....

trn 05-12-2003 06:22 PM

its because when you initialy boot up or are a normal user then bash reads profile information from .bashrc or .profile in your home dir and there is probably an alias for ls with color but when you su bash reads the profile info from the /root directory. You can su -m to match profile or -l or somthing else like that to keep your user settings while su'ing.

itsjustme 05-12-2003 06:48 PM

Oh, ok, I had a similar situation with the PS1 environment variable the other day, but I just today reformatted and reinstalled slackware - because I didn't like the way I had it partitioned.
So, anyway, the initial install of Slackware 9.0 doesn't create any .bashrc files, or .bash_profile files, or .profile files. I will have to create these from scratch.

It does have an /etc/profile file.

So much to learn. Thanks for the input.

itsjustme 05-12-2003 09:13 PM

I just discovered:

eval 'dircolors -b'

in my /etc/profile file.

So, I should be able to put that in my newly created .bash_profile files along with PS1 prompt variable, and then, of course, anything else that comes along as I get the environments set up for su and the user(s).

man dircolors doesn't tell which colors are associated with which file types, but dircolors does apparently set the color.

And I realize that figuring out the colors is just a matter of paying attention.

regards...

itsjustme 05-12-2003 09:28 PM

d'oh!!

That eval 'dircolors -b' didn't work in the .bash_profile. The PS1 assignment did work.

I assume then that I can put some alias line in there, such as maybe, like kinda sorta -> 'alias ls=ls --color', or some such?

Oh, and this is now in xterm, in windowmaker, in slackware 9.0.

regards....

Edit: man, I guess I'm just having Monday evening brain farts. I bet the colors in xterm have nothing to do with .bash_profile, eh? Or, maybe it does. The PS1 thing works in there.


DaOne 05-13-2003 07:48 PM

Quote:

'alias ls=ls --color'
Did you try this yet? I would think creating an alias like this should work. Although I don't know if it needs to be in bash_profile as opposed to creating it from the CL.

itsjustme 05-13-2003 07:52 PM

I am easily distracted by the WTF mystique of linux. This issue was part of a WTF stack from another WTF stack and I haven't tried the alias thing yet. I should get back to that tomorrow.

:D

webtoe 05-14-2003 02:13 PM

the alias thing will need some quote marks in me thinks.

Anyway, the whole colour thing is because of the following fact me thinks. Just using "su" will cause you to hold root priveledges BUT not have root's environment variables. If you login at the login prompt as root, or use su - , then you will have root's environment. This means that you will have the colour thing and certain paths will be there. I found this when I couldn't compile something which you had to be root for. I just su to become root, but this didn't work coz it could never find the right library locations etc. Logged in at the command prompt and tried it and it worked without a hitch.

There are so many nooks and crannies all over the place to explore. Collectively we must know most of them......

HTH and is right

Alex

itsjustme 05-16-2003 02:42 PM

ok, finally got around to it. Copied my .bashrc and .bash_profile from /home/username into /root and added:

alias ls="ls --color"

to the .bash_profile.

And, exited from su and the su'ed again, and there were the colors with ls.

Now, I'm not really sure why the colors in ls work for the user without this in the user's .bash_profile. I can only assume that is has something to do with the

eval 'dircolors -b'

in /etc/profile.

Is there another . (dot) file in the home directory that points to the /etc/profile file?

Thanks for all the replies.


All times are GMT -5. The time now is 12:06 PM.