Make your Linux virtual terminal colorful (1)--ls color settings

Source: Internet
Author: User

[Root@www ~]# man-k ls_colors
/usr/share/man/overrides/man1/lftp.1.gz? [Ynq] Y
--------------------------------------------------------------------------------------------------------------- --------------------------------

Here is a easy-to-do-you-set different colours for different kinds of files when using the ls command.

Add the following lines to the bottom of your ~/.bashrc file-

alias ls= ' ls--color '
ls_colors= ' di=1:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90 '
Export Ls_colors

The first line makes LS, the --color parameter by Default,which tells LS-to-display files in different colours Based on thesetting of the ls_colors variable.

The second line was the tricky one, and what I had worked out Sofar had been by trial and error. The parameters (Di, FI, etc.) Refer to different Linux file types. I had worked them out Asshown

di  = directory
fi  = file
ln  = symboliclink
pi  = FIFO file
so  = socketfile
BD  = Block (buffered) special file
cd  = character (unbuffered ) Special file
or  = symbolic linkpointing to a non-existent file (orphan) Br>mi  =non-existent file pointed to by a symbolic link (visible when Youtype ls -l)
ex  = file which isexecutable (ie. have ' x ' set in permissions).

The *.rpm=90 parameter at theend tells LS-to-display any files ending in. rpm in the Specifiedcolour, with this CAs E colour (dark grey). This can is applied toany types of files (eg. you could use ' *.png=35 ' to make JPEG filesappear purple.) As many or as few parameters as you can gointo the ls_colors variable, as long asthe parameters is separate D by colons.

Using Trial and error (and a little bash script I wrote ... my firstone ever!:) I worked out all the colour codes, at least myinterpretation of them-

0  = default colour
1   = Bold
4   = underlined
5   = Flashing text
7   = Reverse Field
= Red
= Green
= Orange
= Blue
= Purple
= Cyan
PNS = Grey
= Black background41 = Red background
= Green background
= orange background
= blue background
= Purple background
Cyan Background
= Grey background
= dark grey
= Light Red
* * * light green
= YELLOW
94 = light blue
* Purple
= Turquoise
= Dark grey background
101 = Light Red background
102 = Light Green background
103 = Yellow background
104 = light blue background
* = Light purple background
10 6 = Turquoise Background

These can even is combined, so the A parameter like:
Di=5;31;42
In your ls_colors variable would makedirectories appear in flashing red text with a greenbackground!

Setting ls_colors does more than justmake your LS listings look pretty (although it certainly does dothat), it is Also very helpful in identifying files while wadingthrough a file system.

Make your Linux virtual terminal colorful (1)--ls color settings

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.