# Colorizing Login Shell



## goosed (Jan 17, 2012)

I have a question about adding color to my shells. I may just be confused on what I'm doing, so please be gentle!

I have my root login set to use bash. I edit my .bashrc file to include some color for the login prompt. However when I log in, there is no change.

Now when I edit the .profile file with the same information, I am able to get color out of the prompt. I thought that when logging in using the bash shell, your login would pull information from the .bashrc file. Any help would be appreciated, thank you.


----------



## fonz (Jan 18, 2012)

goosed said:
			
		

> I thought that when logging in using the bash shell, your login would pull information from the .bashrc file. Any help would be appreciated, thank you.


From the shells/bash man page:


> When [red]an interactive shell that is not a login shell[/red]  is  started,  bash
> reads  and executes commands from ~/.bashrc, if that file exists.



Fonz

P.S. Be careful with logging in as root. It is generally considered a Very *Bad* Idea (tm).


----------



## wblock@ (Jan 18, 2012)

Setting root's shell to bash is generally a mistake.  It gets really interesting when the system boots in single user mode and /usr isn't mounted.


----------



## SirDice (Jan 18, 2012)

As noted by wblock, do NOT change root's shell. You'll be in really hot water next time you try to update your system to the next major version.


----------



## vertexSymphony (Jan 18, 2012)

But it's all okay if you want to change toor's (which is uid 0) shell, that's why that user is there in the first place.


----------



## goosed (Jan 18, 2012)

Thank you for the replies guys. What should root's default shell be?


----------



## goosed (Jan 18, 2012)

Also, to touch on what you said fonz; what is the difference between logging in with the shell set to bash vs. an interactive shell. Please forgive my ignorance. Thank you.


----------



## vertexSymphony (Jan 18, 2012)

goosed said:
			
		

> Thank you for the replies guys. What should root's default shell be?




```
cat /etc/shells | grep -v /usr
```
any of these is fine, as long as it's on the root filesystem with the needed dependencies ... I would recommend you the default â†’ tcsh
As others said, if you boot in single user, only / will be mounted, and if /usr and/or subdirectories are in another partition, they won't be mounted ... and there's your access to the shell's binary.

If you want to use another shell for root, check this:


```
pw usermod -s /usr/local/bin/bash -n toor# or anything that allows changing the shell
su - toor
```
The system actually comes with "another root" that's called toor for this purposes.
I would tell you to read login(1)() 

Regards.


----------



## fonz (Jan 18, 2012)

goosed said:
			
		

> What should root's default shell be?


Something that's in /bin, I think the default is /bin/csh.


			
				goosed said:
			
		

> what is the difference between logging in with the shell set to bash vs. an interactive shell.


Login vs. non-login and interactive vs. non-interactive aren't really different shells, they are different _modes_ that a shell can be in. Bash (as well as others such as tcsh(1) etc.) can be started as a login shell or as a non-login shell and it can be started as an interactive shell or a non-interactive shell.

When a shell is used _interactively_, it's connected to a terminal so that it can interact with a human user typing commands. The opposite use (a _non-interactive_ shell) is typically found in shell scripts.

Depending on how bash is started (as a login shell yes or no, interactively yes or no), it will read different initialisation files. The manpage tells you exactly which files are read, in which order, in which case.

Hope this clarifies things a bit, but the manpage probably explains it better than I can.

Fonz


----------



## wblock@ (Jan 19, 2012)

goosed said:
			
		

> Thank you for the replies guys. What should root's default shell be?



Left alone.  But /bin/csh is the will of Landru.


----------



## manas (Jan 19, 2012)

I made the mistake of changing root's default shell. I noticed this oddly named account 'toor' soon after and a quick search made me realise my folly.


----------



## goosed (Jan 19, 2012)

Thank you for the information. That does make a lot of sense! And a lot of stupidity on my part 

I set my root shell to use /bin/csh. I verified that logging in as root does pull information from ~/.cshrc. I will try to avoid logging in as root, and this does help to clarify things. Thank you all again for your help.


----------



## UNIXgod (Jan 19, 2012)

Check this out: http://www.ccs.neu.edu/home/katz/unix-colors.html

I use gnuls for coloring ls but bsdls also can do it. Getting it to work on zsh autocomplete I remember was a research project unto itself. I don't know if csh has color. I enjoy keeping root simple a default. Black and white reminds me when I have multi-terms open that I am root.

If you decide to use gnuls look at this for customization: http://blog.wompom.org/index.php/2008/01/26/ls-color-considered-harmful/

dircolor will output a template to be used and read by your variable set in your shells rc file.( i.e. in the user directory). You'll also want to alias ls to gnuls as it's prefixed not to stomp on /bin/ls.

Good luck


----------



## UNIXgod (Jan 20, 2012)

I also wanted to add to look at the man page for bsdls() for coloring FreeBSD's implementation of ls().


----------



## SirDice (Jan 20, 2012)

If you want ls to use colors in the output just set CLICOLOR.

Add to your ~/.cshrc:

```
setenv CLICOLOR
```


----------

