在 CentOS(以及大多数 Linux 发行版)中,**别名(alias)**是 shell 提供的一个功能,不同 shell 查看方式略有区别。下面以 bash 为例,这是 CentOS 默认的 shell。
alias
输出示例:
alias cp='cp -i'
alias ll='ls -l'
alias mv='mv -i'
alias rm='rm -i'
alias ll
或
type ll
别名通常定义在以下文件中(按加载顺序):
~/.bashrc
~/.bash_profile
/etc/bashrc
/etc/profile
grep -R "alias ll" ~/.bashrc /etc/bashrc
有些命令被别名覆盖,可用:
type ls
输出示例:
ls is aliased to `ls --color=auto'
\ls
或
command ls
type -a ls
| 场景 | 命令 |
|---|---|
| 查看所有别名 | alias |
| 查看某个别名 | alias 名称 |
| 查看是否别名 | type 命令 |
| 别名配置文件 | ~/.bashrc |
| 系统级别名 | /etc/bashrc |
alias
或
which 命令
如果你愿意,我可以帮你: