关于需要root权限启动图形应用记录
环境
- Kernel: 6.8.4-arch1-1
- OS: Arch Linux x86_64
- DE: hyprland
问题来源
在vmware中安装win11,想更改Edit>Preferences>Memory到"Fit all virtual machine memory into reserved host RAM"来提高访问内存效率,但必须用root运行vmware才能改变.
直接使用sudo vmware会出现
➜ ~ sudo vmware
Authorization required, but no authorization protocol specified
(vmware:28905): Gtk-WARNING **: 14:53:33.168: cannot open display: :0.0
解决方案
尝试使用DISPLAY=:1运行sudo vmware,问题还是存在
➜ ~ DISPLAY=:1 sudo vmware
Authorization required, but no authorization protocol specified
(vmware:29900): Gtk-WARNING **: 15:03:21.949: cannot open display: :1
使用xhost临时允许用启本地用户的X seesion 。参考:arch wiki xhost
➜ ~ sudo pacman -S xorg-xhost
➜ ~ xhost si:localuser:root
Authorization required, but no authorization protocol specified
xhost: unable to open display ":0.0"
仍然显示unable to open display ":0.0",尝试使用DISPLAY=:1运行
➜ ~ DISPLAY=:1 xhost si:localuser:root
localuser:root being added to access control list
然后再次使用sudo运行vmware
➜ ~ DISPLAY=:1 sudo vmware
运行成功
别忘了关闭对root的授权
➜ ~ DISPLAY=:1 xhost -si:localuser:root
localuser:root being removed from access control list
标签:localuser,xhost,sudo,图形,权限,root,DISPLAY,vmware
From: https://www.cnblogs.com/yysog/p/18126078