我可以如何更改AWS ubuntu ec2 shell提示名称

当我们使用ubuntu服务器连接到aws ec2实例时,login后我在bash shell中看到以下提示

Ubuntu的@ IP-XX-XX-XX-XX

有没有办法可以改变这个文本,而不会影响服务器上的任何networking连接?

我已经search,但没有find任何可以指导我在这方面更好的东西。 我会很感激提供的任何帮助。

你想要的Google关键词是“如何更改ubuntu命令提示符”,或者“如何更改bash命令提示符”。 这个线程是第一个查询的第二个命中。 我会根据SF偏好将它复制到这里

只为当前terminal实例更改它只需input

 PS1='\u:\W\$ ' and press enter. 

要改变它“永久”

在〜/ .bashrc中find以下部分:

 if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi 

删除@ \ h,并将\ wreplace为大写\ W,以便它变成:

 if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ ' fi 

您可以使用“主机名”命令更改主机名。

 $~ hostname yourdomain.com 

然后login回你的服务器,提示名称将被改变。