Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I think the screenshot should show what's going on. I open a shell, and dir colors don't work. I run bash again, and dir colors work. What's going on?

enter image description here

share|improve this question
    
Better show us the outputs of the alias ls, echo $LS_OPTIONS and echo $LS_COLORS commands both when colors work and when not. –  manatwork Feb 10 '12 at 16:28
    
I moved my PS1 line below the "source global definitions" section. I guess the color alias was in the global bashrc. Learn something every day! –  LVLAaron Feb 10 '12 at 16:45
    
@LVLAaron The configuration process in general (i.e. this applies to many programs) reads global settings before user specific settings so that users can override defaults with their own preferences. You would only put your own settings before sourcing a global file if you intentionally want any global settings to override your own. If that is not your goal, move everything after the "source global definitions" part. –  jw013 Feb 10 '12 at 22:08
add comment

2 Answers

.bashrc is only read for non-login shells. So when you first log in, its not read. When you run bash again, its not a login shell, so it reads it and your settings take effect.

The simplest solution to this is to create ~/.bash_profile with the following contents:

source .bashrc

This will make a login shell read the config used for non-login shells.

share|improve this answer
add comment

I think you gave some command which unaliased everything and after that when you gave bash command again, the .bashrc was read again and all the variables were aliased again and it executed that alias commands which are mentioned in the .bashrc file of root user and I can see one command is there which is aliasing ls command also, so that's why the color came again.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.