0

When I type echo at here:

skyI@skyI-MP-i1640:~$ echo $XDG_RUNTIME_DIR    
/run/user/1000

It displays /run/user/1000, but when type echo here:

root@skyI-MP-i1640:/SLAM/DSO/dso# echo $XDG_RUNTIME_DIR

It does not display the /run/user/1000

Why and how can I solve it?

2 Answers 2

0

Each user has environment variables. XDG_RUNTIME_DIR is most likely not defined in root user's environment or is being overwritten as empty.

To fix it in your current shell (temporarily), login as root and type export XDG_RUNTIME_DIR="/run/user/1000"

To fix it every time root logs in you can define it in ~root/.profile. Just add the line export XDG_RUNTIME_DIR="/run/user/1000" at the bottom of the file. Then either source ~/.profile or logout & login again.

You can verify which environment variables are defined in the current shell, type env, or a specific one with env | grep XDG_RUNTIME_DIR

1
  • While technically correct answer, I don't think it is what the requester needs, to have root using user directory. Question is why they need the variable and how it is set for regular user.
    – marosg
    Jun 4, 2020 at 6:11
0

it is solved. Sorry very simple answer. Why: They are different user. Different users have different .bashrc files. How: Just export like this, export XDG_RUNTIME_DIR="/run/user/1000"

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .