Linux下ll命令

ll命令其實就是ls -l,當然如果想顯示隱藏信息就是 ls -al。

我個人是特別喜歡ll代替ls -al命令,並且還要有顏色的那種。

今天卸載軟件重新安裝環境變量怎麼都不對了,一生氣把環境變量都清空了。命令:unset PATH

然後就手動添加環境變量:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin

但是ll命令卻沒有了。

解決方案一(沒有顏色):

在~/.bashrc文件最上面添加

alias ll='ls -la'
 

然後運行命令:source ~/.bashrc

此時ll就有了,並且重新打開終端也生效,但是沒有顏色,如下圖:

解決方案二:

從另一臺機器上覆制了一份/etc/profile文件過來發現就有顏色了。可能是我之前的/etc/profile文件壞了。

centos7文件內容如下,其他系統不清楚是否一樣:

網盤鏈接:

鏈接: https://pan.baidu.com/s/1iqDphAxqxxTuB-H75LRpGA 提取碼: zzp2 

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}


if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`/usr/bin/id -u`
        UID=`/usr/bin/id -ru`
    fi
    USER="`/usr/bin/id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then 
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

unset i
unset -f pathmunge

千萬不要放在windows系統裏編輯這個文檔,linux和windows編碼方式不同,我就在windows下打個空格然後就報錯:

-bash: $'\r': command not found
用上述文件替換自己的/etc/profile

執行命令:source /etc/profile

好了,現在所有的終端打開都可以使用ll並且是有顏色的了:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章