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.

관련 정보