ubuntu 25 突破pipewire 不能以root帐号运行 系统没有声音输入输出设备

ubuntu 25 系统以root帐号进入图形界面的话是没有声音的,并且录屏也不可用,原因是pipewire 不能以root帐号运行,检查pipewire状态可以发现:

bash 复制代码
root@lm:~# systemctl --user status pipewire pipewire-pulse wireplumber
○ pipewire.service - PipeWire Multimedia Service
     Loaded: loaded (/usr/lib/systemd/user/pipewire.service; enabled; preset: enabled)
     Active: inactive (dead)
TriggeredBy: ○ pipewire.socket
  Condition: start condition unmet at Thu 2026-05-14 13:46:32 CST; 12min ago
             └─ ConditionUser=!root was not met

5月 14 13:46:32 lm systemd[1859]: pipewire.service - PipeWire Multimedia Service was skipped because of an unmet cond>

○ pipewire-pulse.service - PipeWire PulseAudio
     Loaded: loaded (/usr/lib/systemd/user/pipewire-pulse.service; enabled; preset: enabled)
     Active: inactive (dead)
TriggeredBy: ○ pipewire-pulse.socket
  Condition: start condition unmet at Thu 2026-05-14 13:46:32 CST; 12min ago
             └─ ConditionUser=!root was not met

5月 14 13:46:32 lm systemd[1859]: pipewire-pulse.service - PipeWire PulseAudio was skipped because of an unmet condit>

○ wireplumber.service - Multimedia Service Session Manager
     Loaded: loaded (/usr/lib/systemd/user/wireplumber.service; enabled; preset: enabled)
     Active: inactive (dead)

5月 14 13:46:32 lm systemd[1859]: wireplumber.service: Bound to unit pipewire.service, but unit isn't active.
5月 14 13:46:32 lm systemd[1859]: Dependency failed for wireplumber.service - Multimedia Service Session Manager.
5月 14 13:46:32 lm systemd[1859]: wireplumber.service: Job wireplumber.service/start failed with result 'dependency'.

编辑启动文件

/usr/lib/systemd/user/pipewire.service

bash 复制代码
# 注释掉 ConditionUser=!root

root@lm:~# cat /usr/lib/systemd/user/pipewire.service
[Unit]
Description=PipeWire Multimedia Service

# We require pipewire.socket to be active before starting the daemon, because
# while it is possible to use the service without the socket, it is not clear
# why it would be desirable.
#
# A user installing pipewire and doing `systemctl --user start pipewire`
# will not get the socket started, which might be confusing and problematic if
# the server is to be restarted later on, as the client autospawn feature
# might kick in. Also, a start of the socket unit will fail, adding to the
# confusion.
#
# After=pipewire.socket is not needed, as it is already implicit in the
# socket-service relationship, see systemd.socket(5).
Requires=pipewire.socket dbus.service 
#ConditionUser=!root

[Service]
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
Type=simple
ExecStart=/usr/bin/pipewire
Restart=on-failure
Slice=session.slice

[Install]
Also=pipewire.socket
WantedBy=default.target
root@lm:~# 

编辑启动文件

/usr/lib/systemd/user/pipewire-pulse.service

bash 复制代码
# 注释掉 ConditionUser=!root

root@lm:~# cat /usr/lib/systemd/user/pipewire-pulse.service
[Unit]
Description=PipeWire PulseAudio

# We require pipewire-pulse.socket to be active before starting the daemon, because
# while it is possible to use the service without the socket, it is not clear
# why it would be desirable.
#
# A user installing pipewire and doing `systemctl --user start pipewire-pulse`
# will not get the socket started, which might be confusing and problematic if
# the server is to be restarted later on, as the client autospawn feature
# might kick in. Also, a start of the socket unit will fail, adding to the
# confusion.
#
# After=pipewire-pulse.socket is not needed, as it is already implicit in the
# socket-service relationship, see systemd.socket(5).
Requires=pipewire-pulse.socket
#ConditionUser=!root
Wants=pipewire.service wireplumber.service pipewire-media-session.service
After=pipewire.service wireplumber.service pipewire-media-session.service
Conflicts=pulseaudio.service

[Service]
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
Type=simple
ExecStart=/usr/bin/pipewire-pulse
Restart=on-failure
Slice=session.slice

[Install]
Also=pipewire-pulse.socket
WantedBy=default.target
root@lm:~# 

重新加载服务

bash 复制代码
# 启动 PipeWire 用户服务
systemctl --user daemon-reload
systemctl --user start pipewire pipewire-pulse
systemctl --user enable pipewire pipewire-pulse
相关推荐
Web3探索者1 天前
可视化服务器管理和传统命令行区别是什么?新手教程:Linux 运维到底该用图形界面还是 SSH 命令行?
linux·ssh
zylyehuo1 天前
Linux系统中网线与USB网络共享冲突
linux
荣--1 天前
一键部署不是为了省时间 —— 它是把"买来的 PaaS"变成"自己的平台"的拐点
运维·zabbix·工程化·一键部署·平台化·边界设计
江华森1 天前
动手实战学 Docker — 从零到集群编排完全指南
运维
Avan_菜菜2 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
Sokach10152 天前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
SelectDB3 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao3 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3104 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode4 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏