Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just started using dwm a couple days ago and I'm using xterm (uxterm) as a terminal emulator.

However, I'm noticing that certain applications (like vi/vim, ls, and others) that output in color are using bright colors and (sometimes) bold fonts. My terminal's background color is a dark pastel so I'd like the colors to match.

How can I change these colors, is there a way to use #xxxxxx colors?

share|improve this question
up vote 11 down vote accepted

Xterm is configured via X resources. This is how you might configure it for white on black, with a lighter blue than the default (adjust the color as you see fit, obviously):

XTerm.VT100.background:         Black
XTerm.VT100.color0:             Black
XTerm.VT100.color1:             Red
XTerm.VT100.color2:             Green
XTerm.VT100.color3:             Yellow
XTerm.VT100.color4:             CornflowerBlue
XTerm.VT100.color5:             Magenta
XTerm.VT100.color6:             Cyan
XTerm.VT100.color7:             White
XTerm.VT100.colorBD:            White
XTerm.VT100.colorBDMode:        true
XTerm.VT100.colorUL:            Yellow
XTerm.VT100.colorULMode:        true
XTerm.VT100.cursorColor:        Red
XTerm.VT100.foreground:         White

You can use X color names (you can see all the color names with xcolors or in a file called rgb.txt which may be somewhere under /etc/X11, /usr/X11 or /usr/share/X11 or some similar location depending on your system) or #RRGGBB. colorBD is the color used for bold; with colorBDMode set to false (the default), this setting is ignored and bold text is displayed in a bold font. The same goes for colorUL, colorULMode and underline. You can go beyond color8 (up to color255, or less depending on the xterm version and compile-time configuration). color8 through color15 correspond to 0–7 with bold; colors beyond 16 are rarely used by applications unless you've explicitly configured them.

Put these settings into a file called ~/.Xdefaults. Most systems load this file automatically when you log in. If yours doesn't, add this command to your X startup script:

xrdb -merge ~/.Xdefaults

To test the appearance of foreground color 42 over background color 17, run this in a shell in that terminal:

printf '\033[38;5;%dm\033[48;5;%dm%s\033[0m\n' 42 17 "Hello, world."

If your xterm is compiled without extended color support, you'll need to use the classical control sequences:

printf '\033[3%dm\033[4%dm%s\033[0m\n' 4 1 "Hello, world."

The foreground and background color must be in the range 0–7 in that case. If your xterm is compiled with 16-color support, replace [3 and [4 by [9 and [10 respectively to select the bright versions (colors 8–15).

share|improve this answer
Thanks @Gilles, this is perfect – n0pe Aug 15 '11 at 21:26
I've been toying around with this and it seems to change the colors of ls you need to edit the /etc/DIR_COLORS file. I see color codes in here, but I'm only allowed a certain number of them. Namely, 42 doesn't work but instead gives me a green background. – n0pe Aug 16 '11 at 22:10

You can do that by editing the .Xdefaults file in your home directory. You can just try some other people available .Xdefaults settings, like this one that uses "zenburn" dark color scheme. You'll use just the lines begining with "xterm". Just tested that it works this way for uxterm as well. If for some reason it doesn't for you, change the line beginnings to "uxterm".

share|improve this answer
When applying mentioned here .Xdefaults setting change, this article might help : joeldare.com/wiki/linux:change_xterm_to_white_on_black and here wiki.archlinux.org/index.php/… – Grzegorz Wierzowiecki Dec 2 '11 at 10:26

Your Answer


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.