Поставил себе sudo, но при выполнении sudo -s знак с $ не меняется на #. Хотя при переключении через su $ меняется на #. Настройки профиля не менял (ни в /etc ни в home юзера). Видимо это траблы самого sudo. Как сделать что бы после переключение на root'a знак $ менялся на #?
(man sudo) писал(а):...
-i
The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of the user that the command is being run as. The command name argument given to the shell begins with a -
to tell the shell to run as a login shell.
...
-s
The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd(5).
...
То есть при использовании параметра "-s" оболочка запускается не как оболочка логина в отличие от параметра "-i". Теперь смотрим:
(man bash) писал(а):...
INVOCATION
...
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
...
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
...
А теперь вспоминаем, где именно устанавливается переменная PS1, и понимаем, в чём здесь дело, почему это не ошибка sudo, и какой параметр нужно использовать для достижения желаемого результата.
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
Перевод:
Когда запускается оболочка, не являющаяся оболочкой логина, в интерактивном режиме, она читает и выполняет команды из ~/.bashrc, если этот файл существует.
Именно так запускается оболочка при вызове sudo с параметром "-s".
Вы записываете нужные вам команды в ~/.profile, который не исполняется при таком запуске оболочки. Вас удивляет, что: