How to change the Linux font and background color

Source: Internet
Author: User
How to change the Linux font and background color-Linux general technology-Linux technology and application information. Linux users must be familiar with the black and white text on the text interface and the white and black text on X. These two colors can be said to be classic and clear. However, you can change the font and background color based on your preferences.

The following describes how to change the font and background color of RedHat:

Command:
PS1 = "[\ e [32; 1m \ u @ \ h \ W] \ $" to see what the effect is
Or
Export PS1 = "[\ e [32; 1m \ u @ \ h \ W] \ $" for the differences between the two, please refer to the relevant information of environment variables.

Explanation:
PS1: an environment variable. It is called a prompt variable. It is case sensitive and followed by the number "1"
Not the letter "I"

\ E [32; 1 m: This is the escape character that controls the font and background color, 30 ~ 37 is the font color, 40 ~ 47 is the background color
In the example, the 32; 1 m digit position can be reversed, for example, \ e [1; 32 m. If it is in the X environment, you can change the range of 1 to 0 ~ 10, some useless places: 0 or do not write (\ e [0; 32 m or \ e [; 32 m) Show light color, 1: Show highlighted 4: underline ..... if the effect is not good but cannot be restored, do not write the number before m, for example, \ e [32; m, or log out directly before logging in.

\ U \ h \ W: Some escape characters, which are explained in detail below:
\ D: represents the date, in the format of weekday month date, for example: "Mon Aug 1"
\ H: complete host name. For example, if my machine name is fc4.linux, this name is fc4.linux.
\ H: only the first name of the host. In the preceding example, the name is fc4, and the name of. linux is omitted.
\ T: The display time is in the 24-hour format, for example, HH: MM: SS.
\ T: The display time is in the 12-hour format.
\ A: The display time is in the 24-hour format: HH: MM.
\ U: Account name of the current user
\ V: BASH version information
\ W: complete working directory name. In the home directory ~ Replace
\ W: Use basename to get the working directory name. Therefore, only the last directory is listed.
#: Commands issued
\ $: The prompt character. If it is root, the prompt is: #, and the normal user is: $
\ N: Creates a new row.

The font is not limited to one color. It can have multiple colors:
PS1 = "[\ e [32; 1 m \ u @ \ e [35; 1 m \ h \ e [31; 1 m \ W] \ $"

The preceding two Commands will expire after logging out. Use the following method to make them permanently effective:

Vi/etc/profile
Add a line under "export PATH...": export PS1 = "[\ e [32; 1m \ u @ \ h \ W] \ $"

Log out and log on again. If it does not take effect, run the source/etc/profile command or restart the machine.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.