在 CentOS 中,要永久设置 aliases,您需要将它们添加到相应的 shell 配置文件中。以下是一些常见 shell 的配置文件:
对于 Bash shell(默认 shell):
alias your_alias='your_command'
,按 Enter 键。~/.bashrc
文件(如果使用的是 root 用户,则为 /root/.bashrc
),在文件末尾添加 alias your_alias='your_command'
,然后保存并关闭文件。要使更改生效,请在终端中运行 source ~/.bashrc
。对于 Zsh shell:
alias your_alias='your_command'
,按 Enter 键。~/.zshrc
文件(如果使用的是 root 用户,则为 /root/.zshrc
),在文件末尾添加 alias your_alias='your_command'
,然后保存并关闭文件。要使更改生效,请在终端中运行 source ~/.zshrc
。对于 Fish shell:
alias your_alias 'your_command'
,按 Enter 键。~/.config/fish/config.fish
文件(如果使用的是 root 用户,则为 /root/.config/fish/config.fish
),在文件末尾添加 alias your_alias 'your_command'
,然后保存并关闭文件。要使更改生效,请在终端中运行 source ~/.config/fish/config.fish
。完成上述步骤后,您的 aliases 将在新的终端会话中永久生效。