Изменить оболочку linux

На моем сервере Centos7 у меня есть разные оболочки для моих пользователей.

Например, терминал как root выглядит так:

[root @ hostname www] # .

Терминал от имени другого пользователя выглядит как bash-4.2 $ .

Если я наберу echo $ 0 , чтобы получить оболочку, используемую в данный момент, я получаю / bin / bash для другого пользователя и -bash для моего корневого каталога.

Нужно ли мне настраивать оболочку для моего другого пользователя, чтобы он выглядел как оболочка для моего root?

Есть ли способ использовать оболочку, используемую в Debian ( bash )чтобы увидеть полный путь к моему местоположению? ( root @ server: / var / www # вместо root @ server www ).

Спасибо за вашу помощь.

0
задан 6 July 2020 в 23:04
2 ответа

Похоже, у вашего пользователя отсутствуют файлы скелета, по умолчанию .bashrc , .bash_profile и т. Д., Которые обычно копируются в дом пользователя каталог из / etc / skel при создании пользователя. Вы можете скопировать эти файлы самостоятельно, если они отсутствуют или повреждены.

4
ответ дан 4 January 2021 в 09:17

Приглашение пользователя определяется значением переменных оболочки PS1, PS2, PS3, PS4.

PS1 – The value of this parameter is expanded and used as the primary prompt string. 
      The default value for Bash is \s-\v\$ .
PS2 – The value of this parameter is expanded as with PS1 and used as the secondary 
      prompt string. The default value for Bash is >
PS3 – The value of this parameter is used as the prompt for the select command
PS4 – The value of this parameter is expanded as with PS1 and the value is printed 
      before each command bash displays during an execution trace.

Обычно пользователь настраивает только PS1.

Bash позволяет настраивать эти переменные вставив один или несколько экранированных специальных символов:

\a : ASCII bell character
\d : The date in “Weekday Month Date” format (e.g., “Tue May 26”)
\D{format} : the format is passed to strftime(3) and the result is inserted into
the prompt string; an empty format results in a locale-specific time representation. 
The braces are required
\e : Tne ASCII escape character
\h : The hostname up to the first ‘.’
\H : The full hostname
\j : The number of jobs currently managed by the shell
\l : The basename of the shell's terminal device name
\n : A newline
\s : The name of the shell
\t : The current time in 24-hour HH:MM:SS format
\T : The current time in 12-hour HH:MM:SS format
\@ : The current time in 12-hour am/pm format
\A : The current time in 24-hour HH:MM format
\u : The username of the current user
\v : The current version of bash (e.g., 2.00)
\V : The current release of bash, version and patch level (e.g., 4.12.0)
\w : The current working directory, with $HOME abbreviated with a tilde
\W : The basename of the current working directory, with $HOME abbreviated 
     with a tilde
\! : The history number of this command
\# : The command number of this command
\$ : If the effective UID is 0, a #, otherwise a $
\nnn : The character corresponding to the octal number nnn
\\ : A backslash
\[ : Begin sequence of non-printing characters, which could be used to embed 
     a terminal control sequence into the prompt
\] : End sequence of non-printing characters

Пример:

fpm@fpmurphy ~]$ PS1="[\d \t \u@\h:\w ] $ "
[Sun Jul 05 23:44:17 fpm@fpmurphy:~ ] $ 

Чтобы сохранить настраиваемую подсказку при перезагрузке или выходе из системы, добавьте подсказку пользователям $ HOME / .bashrc или создайте это приглашение по умолчанию для всех пользователей, добавьте его в / etc / bashrc или создайте запись в /etc/bashrc.d в зависимости от вашего дистрибутива.

1
ответ дан 4 January 2021 в 09:17

Теги

Похожие вопросы