Tmux $ HOMEが設定されていません。

Tmux $ HOMEが設定されていません。

DebianからUbuntuに切り替えると、tmuxの動作に違いがあることがわかりました。

予想/前の動作tmuxインスタンスを起動したユーザーに基づいて$ HOME(およびすべての種類の関連設定)を設定します。

$ echo $HOME
/home/tacov

$ sudo tmux
# echo $HOME
/root
# exit

$ sudo -unachov tmux
$ echo $HOME
/home/nachov

不要/新しい動作により$ HOMEが設定されません。

$ echo $HOME
/home/tacov

$ sudo tmux
# echo $HOME
/home/tacov
# exit

$ sudo -unachov tmux
$ echo $HOME
/home/tacov

.profileとそのようなファイルは間違った$ HOMEからロードされるので、解決策がないと思います。ホームディレクトリが正しく設定されました。

$ egrep 'tacov|root' /etc/passwd
root:x:0:0:root:/root:/bin/bash
tacov:x:1000:1000:TacoV,,,:/home/tacov:/bin/bash

元の動作を元に戻すにはどうすればよいですか?

ベストアンサー1

コメントで説明したように:

sudo違いは何も設定にありませんtmux

-iまたは、オプションを指定したら、-Hそれを読み、設定して、.profile期待どおりに機能します。$HOME

からman sudo

 -H, --set-home
             Request that the security policy set the HOME environment
             variable to the home directory specified by the target user's
             password database entry.  Depending on the policy, this may
             be the default behavior.

 -i, --login
             Run the shell specified by the target user's password data‐
             base entry as a login shell.  This means that login-specific
             resource files such as .profile, .bash_profile or .login will
             be read by the shell.  If a command is specified, it is
             passed to the shell for execution via the shell's -c option.
             If no command is specified, an interactive shell is executed.
             sudo attempts to change to that user's home directory before
             running the shell.  The command is run with an environment
             similar to the one a user would receive at log in.  Note that
             most shells behave differently when a command is specified as
             compared to an interactive session; consult the shell's man‐
             ual for details.  The Command environment section in the
             sudoers(5) manual documents how the -i option affects the en‐
             vironment in which a command is run when the sudoers policy
             is in use.

おすすめ記事