Linux file type and color identification collation

Source: Internet
Author: User

Linux file type and color identification collation

Using tools:

ls Command

ls–l: display the details of files and directories in regular format

Example:-rw-r--r--1 root root 0 October 13:32 2016-10-12-13-32-11

-rw-------. 1 root root 1487 9 month 10:56 anaconda-ks.cfg

drwxr-xr-x 3 root root month 10:18 Application

According to the example, the file names of various files are displayed in different colors to differentiate

File type description:

    - : Regular documents, ordinary documents;

D : Directory file, path mapping;

b : block device files; support random access by "block";

C : A character device file that supports linear access in "character" units;

Mojornumber : The main device number, which indicates the device type, and then determines the driver to be loaded;

Minornumber : The secondary device number that identifies the different devices in the same type;

L : Symbolic link file;

P : Command pipeline file;

s : Socket socket file;

File Color Description:

Blue: directory ;

Green: executable file ;

Red: compressed Files ;

Light blue: link file ;

White: other documents ;

Yellow: device file, including block, Char, FIFO.

Flashing red: There is a problem with the linked file;

Expand:

1 , You can use Dircolors-p to see the default color settings, including various colors and "bold", underline, flashing and other definitions.

2 , in the/etc/dir_colors file, this is a coloring control of the template.

3 . Ways to modify other colors:

First of all

# vi/etc/dir_colors

Within the set "DIR 01;34", the color setting for the LS command's directory, 01 for bold, and 34 for font blue.

I changed it to "DIR 01;37;44", 37 is the font white, 44 is the word background blue, the visual effect can also, but also accustomed to accept.

Then, execute

# eval ' dircolors/etc/dir_colors '

4 , The above method is for the global modification, the individual user modification method:

/etc/dir_colors file CP to ~/and renamed. Dir_colors, then modify this file.

The following is an official document description:

Linux/unixcommand: dir_colors

Namedir_colors-configuration file for
Dircolors
(1)
DescriptionThe Program
ls
(1) uses the environment variablels_colorsTo determine the colorsin which the filenames is to be displayed. This environment variable isusually set by a command like
Eval ' dircolors some_path/dir_colors '
Found in a system default shell initialization file, like/etc/profileOr/ETC/CSH.CSHRC. (See Also
dircolors
(1).) Usually, the file used here is/etc/dir_colorsAnd can beoverridden by a. Dir_colorsFile in one ' s home directory.
This configuration file consists of several statements, one per line. Anythingright of a hash mark (#) is treated as a comment, if the hash mark was at thebeginning of a line or was preceded by At least one whitespace. Blank lines areignored.
TheGlobalsection of the file consists of any statement before Thefirst TermStatement. Any statement in the global section of the the file isconsidered valid for all terminal types. Following the global section is one Ormoreterminal-specificSections, preceded by one or more TermStatements which specify the terminal types (as given by the Termenvironment variable) The following declarations apply to. It is alwayspossible to the override a global declaration by a subsequent terminal-specificone.
The following statements is recognized; Case is insignificant:
TermTerminal-type
Starts a terminal-specific section and specifies which terminal it applies to. Multiple TermStatements can used to create a section which appliesfor several terminal types.
COLOR Yes|all|no|none|tty
(Slackware only; ignored by GNU
dircolors
(1).) Specifies that colorization should is enabled (YesOr All), never enabled (NoOrNone), or enabled if the output is aterminal (TTY). The default isNo.
eightbit Yes|no
(Slackware only; ignored by GNU
dircolors
(1).) Specifies that Eight-bit ISO 8859 characters should is enabled Bydefault. For compatibility reasons, this can also is specified as 1 forYesor 0 forNo. The default isNo.
OPTIONSOptions
(Slackware only; ignored by GNU
dircolors
(1).) Adds command line options to the defaultlsCommand line. Theoptions can is any validlscommand line options, and should include Theleading minus sign. Please note thatdircolorsDoes not verify thevalidity of these options.
NORMALcolor-sequence
Specifies the color used for normal (non-filename) text.
FILEcolor-sequence
Specifies the color used for a regular file.
DIRcolor-sequence
Specifies the color used for directories.
LINKcolor-sequence
Specifies the color used for a symbolic link.
Orphancolor-sequence
Specifies the color used for a orphaned symbolic link (one which points to anonexistent file). If This is unspecified,lswould use theLINKColor instead.
MISSINGcolor-sequence
Specifies the color used for a missing file (a nonexistent file whichnevertheless have a symbolic link pointing to it). If This is unspecified,lswould use theFILEColor instead.
FIFOcolor-sequence
Specifies the color used for a FIFO (named pipe).
SOCKcolor-sequence
Specifies the color used for a socket.
DOORcolor-sequence
(Supported since File-utils 4.1) Specifies the color used for a door (Solaris2.5 and later).
BLKcolor-sequence
Specifies the color used for a block device special file.
CHRcolor-sequence
Specifies the color used for a character device special file.
EXECcolor-sequence
Specifies the color used for a file with the executable attribute set.
Leftcodecolor-sequence
Specifies theLeft codeFor Non-iso 6429 terminals (see below).
Rightcodecolor-sequence
Specifies theRight codeFor Non-iso 6429 terminals (see below).
Endcodecolor-sequence
Specifies theEnd CodeFor Non-iso 6429 terminals (see below).
*extension color-sequence
Specifies the color used for any file this ends inextension.
.extension color-sequence
Same as*.extension. Specifies the color used for all file Thatends in.extension. Note that the period are included in the Extension,which makes it impossible to specify an extension not starting with a PE Riod,such as~ForEmacsBackup files. This form should is consideredobsolete.
ISO 6429 (ANSI) color Sequencesmost color-capable ASCII terminals today use ISO6429 (ANSI) color sequences, and many Commo n terminals without colorcapability, includingxtermAnd the widely used and cloned DEC Vt100,will recognize ISO 6429 color codes and harmlessly eliminate them from theoutput or emulate them.lsUses ISO 6429 codes by default, Assumingcolorization is enabled.
ISO 6429 Color sequences is composed of sequences of numbers separated bysemicolons. The most common codes is:
0 To restore default color
1 for brighter colors
4 for underlined text
5 for flashing text
For black foreground
For red foreground
For green foreground
Yellow (or brown) foreground
For Blue foreground
for purple foreground
Cyan Foreground
PNS (or gray) foreground
Max for black background
Background for Red
For green background
Yellow (or brown) background
For blue background
Purple background
Cyan Background
Background (or gray)
Not all commands would work on all systems or display devices.
lsUses the following defaults:
NORMAL0 Normal (non-filename) text
FILE0 Regular File
DIRDirectory
LINKSymbolic link
OrphanUndefined orphannedsymbolic link
MISSINGUndefined Missing file
FIFONamed Pipe (FIFO)
SOCKSocket
BLK44;37 Block Device
CHR44;37 Character Device
EXECExecutable file
A Few terminal programs does not recognize the default properly. If all text getscolorized after your do a directory listing, change theNORMALandFILECodes to the numerical codes for your normal foreground and backgroundcolors.
Other TERMINAL TYPES (Advanced CONFIGURATION) If you have a color-capable (orotherwise highlighting) TERMINAL (or printer!) Which uses a different set ofcodes, you can still generate a suitable setup. To doing so, you'll have the to usetheLeftcode,Rightcode, andEndcodeDefinitions.
When writing out a filename,lsGenerates the following output sequence:Leftcode TypeCode Rightcode filename Endcode, where theTypeCodeis the color sequence this depends on the type orname of file. If theEndcodeis undefined, the sequenceLeftcodenormal Rightcodewould be used instead. The purpose of the left-andrightcodes is merely to reduce the amount of typing necessary (and to hide uglyescape codes AW Ay from the user). If they is not appropriate for yourterminal, you can eliminate them by specifying the respective keyword on a lineby itse Lf.
Note:If theEndcodeis defined in the Global section of Thesetup file, itcannotis undefined in a terminal-specific section of Thefile. This means anyNORMALDefinition would has no effect. A differentEndcodeCan, however, be specified, which would has the same effect.
ESCAPE Sequencesto Specify control-or blank characters in the color sequencesor filename extensions, either C-style \-esc Aped notation orStty-style^-notation can be used. The C-style notation includes the following characters:
\aBell (ASCII 7)
\bBackspace (ASCII 8)
\eEscape (ASCII 27)
\fForm Feed (ASCII 12)
\ nNewline (ASCII 10)
\ rCarriage Return (ASCII 13)
\ tTab (ASCII 9)
\vVertical Tab (ASCII 11)
\?Delete (ASCII 127)
\nnnAny character (octal notation)
\xnnnAny character (hexadecimal notation)
\_Space
\\backslash (\)
\^Caret (^)
\#Hash Mark (#)
Please note that escapes is necessary to enter a space, backslash, caret, orany control character anywhere in the string, As well as a hash mark as thefirst character.


Linux file type and color identification collation

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.