TypechoJoeTheme

尘遇 logo

当我遇上你
排行榜
统计

为 Debian 下 root 用户的 ls 命令开启颜色显示

醉书生站长
2个月前
0 评论
169 阅读
检测收录...
07/17
本文最后更新于2021年07月17日,已超过71天没有更新,若内容或图片失效,请留言反馈。

用过 Debian 的应该都知道,它的 root 用户使用 ls 命令时的输出默认是不带颜色显示的。

这虽然不是什么大问题,但对使用体验的影响还是不小的。查了一些资料后找到了解决方案,在这里记录一下吧。

问题详情

使用 root 用户登录一个刚刚安装好的 Debian 系统,然后使用 ls 命令试试。输出结果是不带颜色显示的。这导致我们很难把文件、文件夹、可执行文件、普通文件区分开来,十分影响使用体验。

解决方案

解决方法其实很简单,修改用户目录下的 .bashrc 文件,把 ls 设置为带颜色参数的 ls 命令的别名(alias)即可。当然,这个别名实际上也不需要我们去手动添加,.bashrc 文件中本来就有,我们只要将其取消注释就行了。

使用 vim 编辑 .bashrc 文件:

vim ~/.bashrc

打开该文件后我们可以找到如下几行:

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "`dircolors`"
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'

这里第一行的注释已经说得很清楚了:如果你想要 ls 命令被“着色”,可以把下面几行取消注释。根据这一说明,我们把下面几行的注释取消掉后保存文件即可。

按照上面的步骤修改好后,重新开一个对话使用 ls 命令试试看。可以发现输出结果已经自动带上颜色显示了,文件、文件夹等不同类型的输出一目了然。

本文共376个字数,您已阅读:平均阅读时长≈1分钟。
朗读
点赞
0
赞赏
海报
人生
欢迎
要时间嘉许,等春风得意,我正好遇上你!

微信/QQ/支付宝三合一收款码

微信
QQ
支付宝
打开微信/QQ/支付宝扫一扫,即可进行扫码打赏!
版权属于:

尘遇

最后修改:

2021 年 07 月 17 日 09 : 40 PM

本文链接:

https://chenyu.me/1433.html(转载时请注明本文出处及文章链接)

暂无评论

光阴者,百代之过客

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. xz秀才
    2021-09-22
  2. 小斌秀才
    2021-09-22
  3. 小李秀才
    2021-09-19
  4. 梦浪的小虾米秀才
    2021-09-18

    {!{data:image/webp;base64,UklGRrwYAABXRUJQVlA4WAoAAAAwAAAAtQMAKwEASUNDUBgCAAAAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANkFMUEg3EgAAAfCGbdtqp9m2HTh13K1QDS5tKZSrA6e90UoI7u5FA4VZiruEFlKcixarCw6jBqEhLVocJpZGCO4Quv/YR+Ycc2aOM2Nc416WRMQESKb/M/2f6f9M/2f6P9P/mf7P9H+m/zP9n+n/TP875UVGRWsurLDDAN53XbVMAoD1bqv2d8GjXFbTYHi4iKuq/CY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