在 CentOS 中,您可以通过编辑 /etc/hosts
文件或者创建/编辑 ~/.bashrc
或 ~/.bash_profile
文件来更新 aliases 设置
方法一:编辑 /etc/hosts
文件
打开终端。
输入以下命令以使用文本编辑器(如 vi 或 nano)打开 /etc/hosts
文件:
sudo vi /etc/hosts
或者
sudo nano /etc/hosts
example.com
添加到本地主机,可以添加以下行:127.0.0.1 example.com
保存并关闭文件。
重启网络服务以使更改生效:
sudo systemctl restart network
方法二:编辑 ~/.bashrc
或 ~/.bash_profile
文件
打开终端。
输入以下命令以使用文本编辑器(如 vi 或 nano)打开 ~/.bashrc
或 ~/.bash_profile
文件:
vi ~/.bashrc
或者
nano ~/.bashrc
或者
vi ~/.bash_profile
或者
nano ~/.bash_profile
l
的别名,用于列出目录内容,可以添加以下行:alias l='ls -l'
保存并关闭文件。
使更改生效,运行以下命令:
source ~/.bashrc
或者
source ~/.bash_profile
现在,您已经成功更新了 CentOS 中的 aliases 设置。