Ubuntu 16.04非sudo启动Wireshark等应用显示缩放异常求助
Hey there, let's work through this frustrating scaling problem you're hitting. The key clue here is that apps work fine with sudo but break as a regular user—this almost always boils down to environment variable differences or permission-related conflicts that mess with display settings. Here are actionable fixes to try, ordered from quick tests to more permanent solutions:
1. Test with Correct XDG_RUNTIME_DIR
Root uses a different XDG_RUNTIME_DIR than your regular user, which can cause apps to misread display scaling configs. Try launching the app from your user terminal with this variable explicitly set:
XDG_RUNTIME_DIR=/run/user/$(id -u) wireshark
If this fixes the scaling, you can make it permanent by editing the app's .desktop file (usually in /usr/share/applications/ or ~/.local/share/applications/). Find the Exec= line and prepend the variable:
Exec=env XDG_RUNTIME_DIR=/run/user/$(id -u) wireshark %U
2. Force GTK/Qt Scaling Values
Sometimes regular user profiles don't pass the correct scaling flags to Qt/GTK apps. Try setting these environment variables temporarily first:
export GTK_SCALE=1 export QT_SCALE_FACTOR=1 wireshark
If this works, add the two export lines to your ~/.profile or ~/.bashrc file so they apply every time you log in.
3. Fix X Server Access Permissions
Occasionally, regular users don't have proper access to the X server, leading to display glitches when running apps that need special privileges (but not root). Try this quick test:
xhost si:localuser:$USER wireshark
If scaling works now, add that xhost command to your ~/.xsessionrc file to auto-apply it on login. Avoid using xhost + (it's insecure, as it opens your X server to all users).
4. Use Polkit Instead of Sudo (Recommended)
Running apps like Wireshark with sudo is not just a security risk—it's the root cause of your environment mismatch. Instead, use Polkit to grant necessary permissions while keeping the app running as your regular user:
For Wireshark:
- Add your user to the
wiresharkgroup:sudo usermod -aG wireshark $USER - Create a Polkit rule file to authorize Wireshark:
Paste this content:sudo nano /etc/polkit-1/rules.d/50-wireshark.rulespolkit.addRule(function(action, subject) { if (action.id == "org.wireshark.chcap" && subject.isInGroup("wireshark")) { return polkit.Result.YES; } }); - Log out and back in, then launch Wireshark as your regular user—scaling should work, and you'll still have full capture permissions.
For GNS3/Packet Tracer:
Similar logic applies: look for official documentation on granting non-root permissions via Polkit or dedicated user groups. For GNS3, you can add your user to the uucp and dialout groups (common for serial/network access) and check GNS3's settings to avoid running as root.
Final Notes
The Polkit/group-based method is the best long-term fix because it avoids the environment variable mismatches that come with sudo. If none of these work, double-check that your Ubuntu 16.04 has all the latest display-related updates (run sudo apt update && sudo apt upgrade), as older versions sometimes had scaling bugs with small-form-factor 1080p screens like the XPS 13's.
内容的提问来源于stack exchange,提问作者Julscoob

