给linux shell 添加ll命令支持

有的linux发行版默认添加了ll命令,也就是ls -l的缩写形式的支持,大大提高了命令行的输入效率。

但有部分linux发行版默认没有加入ll支持,也发现一些新手用户不清楚怎么增加这个命令,这里介绍下修改的方法,以bash为例。

在用户的根目录下有个隐藏文件.bashrc,打开后,一般会有以下这段代码

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
fi

在alias ls='ls --color=auto'后面增加一行alias ll='ls -l --color=auto'就行了

修改后的代码如下

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias ll='ls -l --color=auto'
fi

当然,这是针对单个用户的修改,要给所有用户增加这个别名,可以对/etc下的全局脚本配置文件做修改。

原文地址:https://www.cnblogs.com/cner/p/13819027.html