这个bash shell别名在哪里configuration?

以root身份login到CentOS 6.5系统时,我运行

># alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 

我想修改所有用户的alias ll='ls -l --color=auto'alias ll='ls -lha --color=auto'cat /etc/bashrccat /root/.bashrc分别为:

 ># cat /etc/bashrc # /etc/bashrc # System wide functions and aliases # Environment stuff goes in /etc/profile # 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. # are we an interactive shell? if [ "$PS1" ]; then if [ -z "$PROMPT_COMMAND" ]; then case $TERM in xterm*) if [ -e /etc/sysconfig/bash-prompt-xterm ]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm else PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' fi ;; screen) if [ -e /etc/sysconfig/bash-prompt-screen ]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen else PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"' fi ;; *) [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default ;; esac fi # Turn on checkwinsize shopt -s checkwinsize [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " # You might want to have eg tty in prompt (eg more virtual machines) # and console windows # If you want to do so, just add eg # if [ "$PS1" ]; then # PS1="[\u@\h:\l \W]\\$ " # fi # to your custom modification shell script in /etc/profile.d/ directory fi if ! shopt -q login_shell ; then # We're not a login shell # Need to redefine pathmunge, it get's undefined at the end of /etc/profile pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } # By default, we want umask to get set. This sets it for non-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 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi # Only display echos from profile.d scripts if we are no login shell # and interactive - otherwise just process them to set envvars for i in /etc/profile.d/*.sh; do if [ -r "$i" ]; then if [ "$PS1" ]; then . "$i" else . "$i" >/dev/null 2>&1 fi fi done unset i unset pathmunge fi # vim:ts=4:sw=4 

 ># cat /root/.bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi 

它是/etc/profile.d/colorls.sh,它包含两个对ll引用:

 ># cat /etc/profile.d/colorls.sh # color-ls initialization #when USER_LS_COLORS defined do not override user LS_COLORS, but use them. if [ -z "$USER_LS_COLORS" ]; then alias ll='ls -l' 2>/dev/null alias l.='ls -d .*' 2>/dev/null # Skip the rest for noninteractive shells. [ -z "$PS1" ] && return COLORS= for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \ "$HOME/.dir_colors" "$HOME/.dircolors"; do [ -e "$colors" ] && COLORS="$colors" && break done [ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \ [ "x`tty -s && tput colors 2>/dev/null`" = "x256" ] && \ COLORS="/etc/DIR_COLORS.256color" if [ -z "$COLORS" ]; then for colors in "/etc/DIR_COLORS.$TERM" "/etc/DIR_COLORS" ; do [ -e "$colors" ] && COLORS="$colors" && break done fi # Existence of $COLORS already checked above. [ -n "$COLORS" ] || return eval "`dircolors --sh "$COLORS" 2>/dev/null`" [ -z "$LS_COLORS" ] && return grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return fi alias ll='ls -l --color=auto' 2>/dev/null alias l.='ls -d .* --color=auto' 2>/dev/null alias ls='ls --color=auto' 2>/dev/null 

那么,我编辑/etc/profile.d/colorls.sh,如果是的话,在哪里出现? 还是有更好的方法去做呢?

如果你的所有用户都有.bashrc引用来执行/ etc / bashrc,那么在这个文件的底部添加一行就可以覆盖以前的别名。

在/ etc / bashrc的底部添加一些注释和新的别名,如:

 # Setting ll alias -- August 2014 # by XXXX alias ll='ls -lha --color=auto' 

我认为这是一个干净简单的select来修改colorls.sh。

编辑:

你是对的。 更好的方法是创build/etc/profile.d/custom.sh并在其中添加别名。

事实上,我应该解决我的答案。

只需创build文件/etc/profile.d/custom.sh,在其中添加自定义项并为其设置执行标志。

有用的其他信息: http : //www.thelinuxdaily.com/2010/08/setup-a-universal-user-profile-with-etcprofile-dcustom-sh/