Terminal on Ubuntu Server 24.04 via PuTTY - where to change text colors?

Bo Berglund bo.berglund at gmail.com
Sun Oct 19 12:51:43 UTC 2025


On Sat, 18 Oct 2025 02:04:00 -0400, Jon LaBadie <ubu at labadie.us> wrote:

>On Fri, Oct 17, 2025 at 09:57:53AM +0200, Bo Berglund wrote:
>>I have a pair of 24.04 Ubuntu servers, which I mainly interface with using PuTTY
>>on Windows. I also use PuTTY against my many Raspberry Pi units.
>>
>>I have long wondered about the display of file lists (ls -la) where certain
>>files get text colors depending on their extension...
>>And if I use nano to edit a script file it shows different colors if the file is
>>set to be executable or not...
>
>You probably have an alias for the ls command in your bash config files.
>For example I have:
>
>alias ls='ls -v --color=auto '
>
>Your setting is probably '--color=always' or '--color' as Ubuntu 
>defaults (incorrectly IMO) to 'always'.  With the 'auto' setting color
>is ON if the output is going to a terminal where humans will look
>at the output.  But if going elsewhere, eg. files or pipes, were 
>programs may process the data, color extraneous and is turned off.
>
>>I don't like the selected colors so I want to change them, but where?
>>Is it something done in PuTTY or is it an Ubuntu setting and/or nano setting?
>
>"ls" uses the environment variable "LS_COLORS" to specify file/color
>associations.
>
>The command "dircolors" is a convenient way to set the variable in
>your shell config files.  It outputs an assignment of LS_COLORS and
>an export of the variable.
>
>$ dircolors
>LS_COLORS='...very long string...';export LS_COLORS
>
>Use this in the config files as:
>
>eval $(dircolors)
>
>I captured the dircolors output directly in my .profile to make
>a local alteration.  ".pdf" files are not colored by default so
>I added an entry for them.
>
>"dircolors -p" output a single long column of its database for
>easier examination.  Some comments are included also.
>
>A fuller explanation of the database can be found on the manpage
>for "dir_colors" in section five.  (Note the "_" is not a typo)
>
>-- 
>Jon H. LaBadie                  ubu at labadie.us

Thanks for your explanation!

My alioas for ll is:
alias ll='ls -al --time-style="+%Y-%m-%d %H:%M"'

Used to get a sensible timestamp output rather than the US AM/PM junk...


Is there a way to "override" a *couple* of the color definitions without having
to put all of them into my .bashrc file?

What I mean is that after the system has created the  LS_COLORS define, can one
run some simpler command to just *change* 2-3 of the color defines for the file
types I want modified?

I have found this in my .bashrc file so I assume this is when the colors are
defined on user login:

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval
"$(dircolors -b)"

I don't really understand what this does....

It seems to suggest that there are two dircolors commands, one at
/usr/bin/dircolors and one at ~/.dircolors....

How can I handle it such that I don't modify the default color settings but can
use a modified set of color definitions from my .bashrc file and activate it
easily?

I might later want to go back to the default and therefore it should not be
modified.



-- 
Bo Berglund
Developer in Sweden




More information about the ubuntu-users mailing list