我对这个 centos 终端和 aws 非常陌生。我想问你如何更改终端名称并将默认名称替换为 ec2user@ip。请帮帮我。
答案1
我们是在谈论终端提示符吗?如果是,您正在查看变量PS1
。从 bash 中,可以通过发出例如来更改它export PS1=\u@\h\$
(这很可能与您已有的类似)。将后面的部分更改=
为您想要的任何内容。
根据您想要的提示,您需要在导出中使用不同的变量。以下是可用变量的列表:
\d The date, in "Weekday Month Date" format (e.g., "Tue May 26").
\h The hostname, up to the first . (e.g. deckard)
\H The hostname. (e.g. deckard.SS64.com)
\j The number of jobs currently managed by the shell.
\l The basename of the shell's terminal device name.
\s The name of the shell, the basename of $0 (the portion following the final slash).
\t The time, in 24-hour HH:MM:SS format.
\T The time, in 12-hour HH:MM:SS format.
\@ The time, in 12-hour am/pm format.
\u The username of the current user.
\v The version of Bash (e.g., 2.00)
\V The release of Bash, version + patchlevel (e.g., 2.00.0)
\w The current working directory.
\W The basename of $PWD.
\! The history number of this command.
\# The command number of this command.
\$ If you are not root, inserts a "$"; if you are root, you get a "#" (root uid = 0)
\nnn The character whose ASCII code is the octal value nnn.
\n A newline.
\r A carriage return.
\e An escape character (typically a color code).
\a A bell character.
\\ A backslash.
\[ Begin a sequence of non-printing characters. (like color escape sequences). This
allows bash to calculate word wrapping correctly.
\] End a sequence of non-printing characters.
在 PS1 中试验各种值,一旦找到了您喜欢的集合,您就可以粘贴命令~/.bashrc
以使更改永久生效。