ls -l 支持简写 ll 并且附带颜色显示

绕海飞行的鱼🐟 发布于 2023-03-20 1 次阅读


Debian 装完后,默认不支持 ll 列出目录详细,必须得用 ls -l 来才行,而且没显示颜色,对于某些可赋予可执行的 sh 文件看的不太清楚,虽然重装机会不多,这里姑且也记录一下~

方法很简单,首先编辑下配置文件:

nano ~/.bashrc

这里以 Debian 11 默认内容为例,想要行前面的 # 去掉就可以了。(没有的就手动加)

# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022

# 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'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

Ctrl+O 保存,Ctrl+X 退出。最后要使刚刚的配置生效,再输入:

source ~/.bashrc

现在再输 ll 应该可以被识别了,文件/文件夹相应权限也有颜色标识了,一目了然~