No color for ls -l after being root on bash shell
Code:
su But as normal user ls -l displays directories in blue and executable files in green. It's konsole. How can i edit the bash configuration for root user to display directories in blue? |
Your normal user probably has an alias like:
alias ls='ls --color=tty' As that user just type "which ls" to see. Once you determine that you can add it to root's .bashrc or .profile. |
There may be a restriction on user number in /etc/profile.d/colorls.[your shell here]. (Which is where the alias is defined). It's worth having a look. I'm not sure why this is done.
|
Quote:
There is no such files in /etc or /home/user which ls for normal user: /usr/bin/ls which ls for root user: /bin/ls |
Quote:
Code:
su - |
Quote:
The files are simply text files. If you aren't familiar with them then you probably want to look for and go through a bash tutorial (there many on the internet) before you try anything. You do NOT want to make your root account unusable. |
Quote:
There is a file named "profile" in /etc. |
Quote:
|
Quote:
Code:
alias su="su -" Code:
ls='/bin/ls $LS_OPTIONS' Personally I just use "su -" when i want root's environment to be pure (as a login shell) but if you really want to shorten this the first supplied alias will do in which case running "su -" will have the opposite effect than normal running the interactive shell. |
Quote:
/etc/profile and /etc/bashrc affect all users whereas .profile and .bashrc in a user's home directory only affect that user. That is to say /etc/profile and /etc/bashrc do global settings (assuming you're using bash) whereas .profile and .bashrc are specific only to the single user. When you type "su <user>" you're saying - switch user without invoking his environment. When you type "su - <user>" you are saying switch user and invoke his environment. There are various things that might be set for a specific user that might not be set for other users - for example the PATH variable used by root is often different than that for users simply because the commands root can use are broader than those end users can use. |
Also, if you add a .bash_profile file in a user directory, any .bashrc in the same directory will be ignored.
|
Quote:
|
Sorry about the resurrection. However, you sure this is not how it works? I figured, since I suddenly had problems that 'ls' did not give any colors in my user shell. The shell itself looked pretty mush like BASH though, and when I looked up the $SHELL variable it return BASH, so I was very well on the right shell. After one additional launch (by simply typing 'bash') I suddenly had colors in 'ls'. After 'exit', I -- once again -- had no colors. I could not find the logic here. I had the default .bashrc file in my home directory. Then I recalled that I had lately written a simple ~/.bash_profile with a couple of lines. I simply tried removing this file, and then re-logged. Now, colors were showing correctly. How do you explain this? Should I perhaps make a new thread for this issue? Like I said, I got it figured, and by simply adding my log on lines to the end of .bashrc (instead of .bash_profile), I have it solved. I'm just trying to find out what's popping under the hood here.
|
What you describe is exactly the opposite of the default behaviour that you will see in Slackware. Slackware sets the colour ls alias from a file in /etc/profile.d which means it won't be available to any non-login shells that you launch from the command line. I don't know which distro you're using or how its profiles are written, so I can't guess why you're seeing what you are, but I can tell you how it is supposed to work:
Depending on whether it is started as a login shell or not, bash will either run /etc/profile (~/.bash_profile, ~/.profile, etc.) or ~/.bashrc. The existence of .~/.bash_profile has no bearing on whether .bashrc will run or not. All that matters is whether the shell is a login shell or not, and bash will run one or the other depending on that alone. What I like to do is have a ~/.bash_profile that does this: Code:
case $- in If you want to go to the horse's mouth, have a read of the "INVOCATION" section of the bash man-page. P.S. $SHELL isn't a reliable way of determining what the current shell is. Code:
gazl@ws1:~$ ksh |
read this
http://www.linuxquestions.org/questi...oblems-914640/ and this docs.slackware.com/howtos:cli_manual:shells?do=export_pdf Quote:
hope this helps |
All times are GMT -5. The time now is 07:19 PM. |