[root@localhost ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
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'
[root@localhost ~]# alias ls='ls --color=auto'
[root@localhost ~]# alias a='a+b'
等号间不能有空格
[root@localhost ~]# alias a = 'a+b'
alias a='a+b'
-bash: alias: =: 未找到
-bash: alias: a+b: 未找到
但是这样的设置只在当前控制台有效,可以在两个地方修改使其一直有效:
本用户家目录下的 .bashrc 文件中,这个只会在本用户登陆时有效
/etc/profile 文件,所有用户都会生效
[root@localhost ~]# cat ~/.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
[root@localhost ~]# tail -3 /etc/profile
unset i
unset -f pathmunge
alias a="a+b"