LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Terminal font colors, what does they mean? (http://www.linuxquestions.org/questions/linux-newbie-8/terminal-font-colors-what-does-they-mean-857846/)

LittlePenguin 01-21-2011 02:10 PM

Terminal font colors, what does they mean?
 
QQ, what means those colors?, so far I know that cyan means a folder, and regular green is a normal file, like a sort of executable.

But there are others, like bold green, brown, red (I think red is a zip file), and so on.

I looked into the colors profile inside the Terminal application but nothing tells me what those colors mean.

Thx!

xeleema 01-21-2011 02:41 PM

Greetingz!

You're talking about the colors of files when you use "ls" in a terminal session, right?
These colors used to make certain file types stand out, typically by extention (.so, .sh, .tgz, .jpg, and so on).

Since you didn't mention what Linux Distribution you're running, I'll go over my "Red Hat Enterprise Linux"-compatible system (CentOS).
(Different Linux distributions implement colors for the "ls" command differently)

To find out what colors are set where, you can either;

a) Type "env|grep ^LS_COLORS"
This should show an environment variable with all the colors defined.

b) Type "ls -l /etc|grep -i colors"
Code:

-rw-r--r--  1 root    root    2.5K Feb 28  2010 DIR_COLORS
-rw-r--r--  1 root    root    2.4K Feb 28  2010 DIR_COLORS.xterm

They're called by one of two scripts in /etc/profile.d (colorls.csh or colorls.sh)

Here's my DIR_COLORS (I've bolded the relevent section)
Code:

# Configuration file for the color ls utility
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty
# Extra command line options for ls go here.
# Basically these ones are:
#  -F = show '/' for dirs, '*' for executables, etc.
#  -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0
# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM xterm
TERM rxvt
TERM xterm-color
TERM color-xterm
TERM vt100
TERM dtterm
TERM color_xterm
TERM ansi
TERM screen
TERM screen.linux
TERM kon
TERM kterm
TERM gnome
TERM konsole
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00      # global default, although everything should be something.
FILE 00        # normal file
DIR 01;34      # directory
LINK 01;36      # symbolic link
FIFO 40;33      # pipe
SOCK 01;35      # socket
BLK 40;33;01    # block device driver
CHR 40;33;01    # character device driver
ORPHAN 01;05;37;41  # orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to
# This is for files with execute permission:
EXEC 01;32

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
.cmd 01;32 # executables (bright green)
.exe 01;32
.com 01;32
.btm 01;32
.bat 01;32
.sh  01;32
.csh 01;32
.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z  01;31
.Z  01;31
.gz  01;31
.bz2 01;31
.bz  01;31
.tz  01;31
.rpm 01;31
.cpio 01;31
.jpg 01;35 # image formats
.gif 01;35
.bmp 01;35
.xbm 01;35
.xpm 01;35
.png 01;35
.tif 01;35


LittlePenguin 01-21-2011 03:02 PM

Thx a lot for your answer!, Im gonna change that dark blue.. cant see it over my black console.

Btw, Im using Debian Squeeze, and yes, I was talking about the font colors when you run ls commands.

Edit.: ls -l /etc|grep -i colors gives me nothing :)

xeleema 01-21-2011 03:42 PM

Quote:

Originally Posted by LittlePenguin (Post 4233362)
Thx a lot for your answer!, Im gonna change that dark blue.. cant see it over my black console.

You're welcome! Yeah, that always drives me nuts. Now if you figure out how to change the default comment-color in vim, *that'd* be awesome.
(It's also dark-blue, and I can't find a way to change it that works on both Linux & Solaris)

Quote:

Originally Posted by LittlePenguin (Post 4233362)
Edit.: ls -l /etc|grep -i colors gives me nothing :)

Well, it's probably stored as an environment variable (env | grep -i color), or in a shell profile file somewhere...although I'm not too sure where in Debian Squeeze that would be at.

See, the whole "Color output" thing for the "ls" command has been around so long, everyone (each distribution) seems to have their own way of doing it.
Kind of like managing Network devices; every distro has their own idea of what to call their scripts, how many scripts to use, etc, etc. All just to get a NIC plumbed, IP'd, and online.

Check and see if you have a dircolors command ("which dircolors"), and if so, it's man page ("man dircolors") might lend some insight into how they (Debian folks) do it in color.

tommyttt 01-22-2011 02:29 AM

Quote:

Originally Posted by LittlePenguin (Post 4233362)
Thx a lot for your answer!, Im gonna change that dark blue.. cant see it over my black console.

Btw, Im using Debian Squeeze, and yes, I was talking about the font colors when you run ls commands.

Edit.: ls -l /etc|grep -i colors gives me nothing :)

Many linux distros have a file called /etc/DIR_COLORS which can be edited to change the colors.

Here's a short Bash script to display all the color combinations as they will appear on your display:
Code:

#!/bin/bash
#
#  This file echoes a bunch of color codes to the
#  terminal to demonstrate what's available.  Each
#  line is the color code of one forground color,
#  out of 17 (default + 16 escapes), followed by a
#  test use of that color on all nine background
#  colors (default + 8 escapes).
#

T='gYw'  # The test text

echo -e "\n        00m    40m    41m    42m    43m\
    44m    45m    46m    47m";

for FGs in '    m' '  1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
          '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
          '  36m' '1;36m' '  37m' '1;37m';
  do FG=${FGs// /}
  echo -en " $FGs \033[$FG  $T  "
  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
  done
  echo;
done
echo
exit 0

Save it as "show-colors.sh" (or whatever name you want), change it to executable (sudo chmod +x filename), and save it in your executable path.

Tom


All times are GMT -5. The time now is 02:06 AM.