aliases 命令在 CentOS 中用于查看和管理 shell 別名。Shell 別名允許用戶為常用的命令或命令序列創建簡短的別名,以便更快地執行它們。以下是一些常用的 aliases 命令參數:
alias
alias 別名
例如,查看 ll 別名的定義:
alias ll
alias 別名='命令'
例如,創建一個名為 ll 的別名,使其等同于 ls -l:
alias ll='ls -l'
unalias 別名
例如,刪除 ll 別名:
unalias ll
默認情況下,使用 alias 命令創建的別名只在當前 shell 會話中有效。要使別名在每次啟動新的 shell 會話時都生效,可以將別名定義添加到 shell 的配置文件中。對于大多數 CentOS 用戶,配置文件是 ~/.bashrc 或 ~/.bash_profile。
例如,將 ll 別名添加到 ~/.bashrc 文件中:
echo "alias ll='ls -l'" >> ~/.bashrc
然后重新加載配置文件:
source ~/.bashrc
alias -p
alias 別名 --verbose
通過這些命令,你可以方便地管理和使用 shell 別名,提高命令執行的效率。