Short answer: set XDG_RUNTIME_DIR
sudo su -l employee_login
export XDG_RUNTIME_DIR=/run/user/$(id -u)
pacmd list-sinks | grep "Built-in Audio"
Explanation
The trick is that PulseAudio looks in ${XDG_RUNTIME_DIR} for the sockets it needs to communicate to the daemon. However, XDG_RUNTIME_DIR is set by PAM (Pluggable Authentication Modules for Linux) when a user logs in. When you use sudo
or su
, you've skipped PAM and so that variable is unset.
Step 1: Become the user
sudo su -l employee_login
The su
command sets your effective UID (user ID) to the same as the employee you are trying to help. This is necessary because PulseAudio is persnickety about such things and will refuse to work.
The -l
is not strictly necessary, but it sometimes helps with debugging possible issues as it runs the user's login scripts.
The sudo
is unnecessary before su -l employee_login
if you have already elevated your privileges to root.
Step 2: Set XDG_RUNTIME_DIR
export XDG_RUNTIME_DIR=/run/user/$(id -u)
Setting XDG_RUNTIME_DIR is necessary because that is where the PulseAudio daemon, which is launched when the user logs in, creates the sockets pulse/native
and pulse/cli
used for communication with clients. [Footnote 1]
Step 3: Use PulseAudio
pacmd list-sinks | grep "Built-in Audio"
The pacmd
tool lets one introspect (or reconfigure) a running PulseAudio daemon. One can think of PulseAudio's term sink as meaning "speakers" and source as meaning "microphone".
Here we are running PulseAudio's list-sinks
command which lists all available output devices. We use grep
to check for the presence of "Built-in Audio" because, in the original question, the employees' machines were supposed to have that disabled and thus not available as a possible sink.
Note that pacmd
(and its younger cousin pactl
) are much more powerful than this and can be used to not only diagnose but remotely fix problems. For example, if the audio output is correct, but the wrong microphone is being chosen by default, one could do something like:
pactl set-default-source alsa_input.usb-USB_Camera_USB_Camera_SN0001-02.analog-mono
Tip: pacmd
and pactl
are best used with bash-completion installed so one can use TAB twice to see options and once to complete long source/sink names. However, avoid the peculiar command-line builtin to pacmd
as it does not use libreadline
and has no history or completion.
Footnote 1
Technically, the PulseAudio daemon does not always use XDG_RUNTIME_DIR. For example, if the daemon is started when that variable is unset, it'll use /tmp with a symlink to it in ~username/.config/pulse/audiodevice-runtime. Similarly, one could configure PulseAudio to share sockets with other users or between containers.