linux添加自定义的命令!

修改了/root/下的.bashrc

-bash-4.1# vi .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


if [ -f ~/bash_aliases ]; then
. ~/bash_aliases
elif [ -f bash_aliases ]; then
. bash_aliases
else
echo " no bash_aliases found !"
fi

~

/etc/下的 bashrc 

文末尾增加


if [ -f bash_aliases ]; then
    . /etc/bash_aliases;
   echo " 1111111 aasb";
fi    
 

或者修改/etc/profile,

执行 .  bashrc 或 . .bashrc 或通过source执行(会有echo信息), 只能在当前shell生效, 新开的shell就不行(没有echo信息)!reboot 重启都不行!

———— 可能是因为我修改了/root 根目录的缘故吧。。。

后面在 /etc/profile.d/ 增加一个sh脚本, 就可以了!,每次新开shell窗口都会有echo !

参考

http://blog.csdn.net/chenchong08/article/details/7833242 —— 这里其实说的不准确,当修改了/root 根目录

原文地址:https://www.cnblogs.com/FlyAway2013/p/4713670.html