为什么在“su - user”之后没有创建 $XDG_RUNTIME_DIR (/run/user/$UID) 目录?:
administrateur@localhost:~$ su - test
Password:
test@localhost:~$ systemctl --user
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
test@localhost:~$ ls /run/user/$UID
ls: cannot access '/run/user/1004': No such file or directory
test@localhost:~$ groups
test
test@localhost:~$
logout
administrateur@localhost:~$
EDIT0:做 asudo loginctl enable-linger test
保留/run/user/$UID
目录,但XDG_RUNTIME_DIR
变量仍未定义:
administrateur@localhost:~$ sudo loginctl enable-linger test
administrateur@localhost:~$ sudo su - test
test@localhost:~$ ls /run/user/$UID/bus
/run/user/1004/bus
test@localhost:~$ echo $XDG_RUNTIME_DIR
test@localhost:~$
logout
administrateur@localhost:~$