3

Я очень новичок в этом терминале Centos и AWS. Я хотел бы спросить вас, как изменить имя терминала и заменить имя по умолчанию на ec2user @ ip. Пожалуйста, помогите мне.

1 ответ1

2

Мы говорим о терминальной подсказке? Если это так, вы смотрите на переменную 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 чтобы сделать изменение постоянным.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .