1、vim /etc/bashrc ###针对全局用户
注意:/etc/bashrc 文件内其他任何内容如果不是专门要修改,请不要删除,会出现其他问题
[root@Allen ~]# vim /etc/bashrc
# /etc/bashrc
alias h='date'
# System wide functions and aliases
# Environment stuff goes in /etc/profile
[root@Allen ~]# source /etc/bashrc ####使创建的别名立刻生效
2. vim/root/.bashrc ###只有root用户有权限
注意:/root/bashrc 文件内其他任何内容如果不是专门要修改,请不要删除,会出现其他问题
[root@Allen ~]# source /etc/bashrc
# .bashrc
alias n='hostname'
# User specific aliases and funct
##########设置好后,退出保存
重新连接终端生效
3.用alias 命令可以查看当前命名好的别名
[root@Allen ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias h='date'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias n='hostname'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'