从别的系统拷贝的文件或者挂载u盘时候,ls出现块状的颜色

本文解析了Linux下ls命令显示颜色的原理,特别是如何通过/etc/DIRCOLORS文件配置不同的文件类型和权限对应的显示颜色。文章详细解释了颜色配置字符串的组成,并针对特定情况如目录权限设置为777时出现的颜色块进行了调整说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ls 查看之所以能出现颜色,主要是因为 /etc/DIRCOLORS

文件设置的关系




关于从别的系统拷贝的文件或者挂载u盘时候,ls出现块状的颜色

一般是因为目录权限设置为777



# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00	# no color code at all
DIR 01;34	# directory
STICKY_OTHER_WRITABLE 00;30;42 # dir that is sticky and other-writable (+t,o+w)
#OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
OTHER_WRITABLE 00;34 # dir that is other-writable (o+w) and not sticky
STICKY 37;44	# dir with the sticky bit set (+t) and not other-writable



修改 OTHER_WRITEABLE 为00;34; 取消前景色


这样就去掉了目录的颜色块









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值