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

Jon LaBadie ubu at labadie.us
Sun Oct 19 21:48:52 UTC 2025


On Sun, Oct 19, 2025 at 02:51:43PM +0200, Bo Berglund wrote:
>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)
>>
>
>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...

Works for me here.  You might try "long-iso" which gives the same output
here.  A separate alias for "ls" rather than "ll" may have an influence.

>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)"
>
>It seems to suggest that there are two dircolors commands, one at
>/usr/bin/dircolors and one at ~/.dircolors....

Not quite, a command and a datafile the command "might" use.
>
>I don't really understand what this does....

First, does the command exist.  Assuming it does, run it with your
personal datafile - if it exists - otherwise use the dafaults.

>
>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.

As you would prefer to not have the color data in the bash config
files 1) leave the "if" statment above alone and 2) create your own
data base in ~/.dircolors.

Populate the file with the defaults:

   dircolors --print-database > ~/.dircolors

Then use your favorite editor to modify or add entries.

Documentation on the db format is in dir_colors

$ man -s 5 dir_colors

-- Jon H. LaBadie                  ubu at labadie.us



More information about the ubuntu-users mailing list