Q:今天在Ubuntu 14下普通用户ssh登录shell发现,使用ls命令查看目录时,发现文件夹和文件都是相同颜色显示!这不合理啊,linux下会根据文件类型而已不同颜色显示的啊!这样看起来才好!

A:切换到root下,一切正常。所以猜想应该是shell的设置问题。

Solve:如何设置呢?

vi ~/.bashrc


#!/bin/bash

if [ -x /usr/bin/dircolors ]; then

     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"

    alias ls='ls --color=auto'

     alias grep='grep --color=auto'

     alias fgrep='fgrep --color=auto'

    alias egrep='egrep --color=auto'

fi

红色这一行是比较重要的。其他的都是环境判断。

~/.dircolors存储了关于颜色的配置文件,所以想修改默认颜色就得修改它。

记得修改了.bashrc以后要注销,重新登录才能生效!