CentOS modify the color of the folder displayed by the ls command

The lsfolder name displayed by the default command under CentOS is dark blue, which is very ugly! You can customize by changing the following configuration:

1. Copy the /etc/DIR_COLORS file to .dir_colors of the current home directory

  cp /etc/DIR_COLORS ~/.dir_colors

2. Modify the color corresponding to DIR in ~/.dir_colors

  vim ~/.dir_colors

  第88行:DIR 01;34(01:粗体,34:蓝色)

  修改为:DIR 01;33(01:粗体,33:黄色)

Insert picture description here
3. Exit and reconnect, lsyou can see the effect in the future

Tip: You can use vim /nameto find namestrings in files

1. File type
1) For direct use, there are the following types:
no NORMAL, NORM global default
fi FILE ordinary file
di DIR directory
ln SYMLINK, LINK, LNK link
pi FIFO, PIPE pipe
do DOOR Door
bd BLOCK, BLK block device
cd CHAR , CHR character device
or ORPHAN target does not exist to symbolic link
so SOCK socket Socket
su SETUID owner setuid valid file
sg SETGID belonging group setuid valid to file
tw STICKY_OTHER_WRITABLE Directory that is sticky and other-writable (t,ow)
ow OTHER_WRITABLE Directory that is other-writable (ow) and not sticky
st STICKY Directory with the sticky bit set (t) and not other-writable
ex EXEC Executable file (ie has'x' set in permissions)
mi MISSING Non-existent file pointed to by a symbolic link (visible when you type ls -l)
lc LEFTCODE, LEFT Opening terminal code
rc RIGHTCODE, RIGHT Closing terminal code
ec ENDCODE, END Non-filename text
2) The extension is passed ". "Plus the extension
  *.extension Every file using this extension eg *.jpg
2. The specific code of the effect is as follows
* Effect list:
00 Default
01 Bold
04 Underline
05 Flash
07 Reverse display
08 Hide
* Color list:
31~37 respectively Indicates that the foreground color is red, green, orange, blue, purple, cyan, and gray
90~97, respectively, indicates that the foreground color is dark gray, light red, light green, yellow, light blue, lavender, cyan, white,
40~47 respectively. The background color is black, red, green, orange, blue, purple, cyan, gray
100~106, respectively, indicating that the background color is dark gray, light red, light green, yellow, light blue, light purple, cyan

The above content is referenced from: blog

In addition, if you modify the above configuration and the colors of some files are not clear (as shown in the figure below), it may be a permission problem (the permissions of the directories in the figure below are all 777):
Insert picture description here
Take the modification of the permissions of the public directory as an example. 701Or 711:
Insert picture description here
Comparing the above figure, you can see that the public directory displays the color of the DIR configured above after the permission is changed.

Change directory permissions in bulk:

chmod -R 权限 目录名 #递归地指定目录名及其下的所有文件配置为指定权限

But we can't change the directory permissions in order to see the name of the directory. So you can use the command:

ls --color=none

Control not to display colors:
Insert picture description here
temporarily change the color scheme: clone this item:

git clone https://github.com/seebi/dircolors-solarized.git

After cloning to the local, execute the following:

cd  dircolors-solarized
cp dircolors.256dark ~/.dircolors

You can use the color matching set by the project, which is 777also valid for the directory with the permission .
Note that this project can only temporarily change the color matching, and the original color matching will be restored after reconnection.

Guess you like

Origin blog.csdn.net/weixin_44559752/article/details/109810740