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

Is it possible to only reset the background color or text color back to default (not both!)


echo -e "\033[32;41mFoo bar\033[30m baz" # Doesn't reset background color
echo -e "\033[32;41mFoo bar\033[0m baz" # Resets the background color and text color

Is there anyway to do this?

I know I can assign the background color in the second statement, but the color will be unknown. (echo -e "\033[32;41mFoo bar\033[0m baz")

share|improve this question
up vote 1 down vote accepted

The colors 39 and 49 means the default color, for the foreground and the background respectively. \e[0m is equivalent to \e[22;24;25;27;28;39;49m (not bold, not underlined, not blinking, not inverse, not hidden, default foreground, default background).

You can find the terminal control sequences in the xterm documentation (most terminals follow xterm's lead nowadays).

share|improve this answer

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.