{"id":7222,"date":"2017-10-11T11:51:53","date_gmt":"2017-10-11T11:51:53","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=7222"},"modified":"2017-10-11T11:56:01","modified_gmt":"2017-10-11T11:56:01","slug":"ubuntu-17-10-tip-graphical-apps-doesnt-launch-via-root-sudo-gksu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2017\/10\/ubuntu-17-10-tip-graphical-apps-doesnt-launch-via-root-sudo-gksu\/","title":{"rendered":"Ubuntu 17.10 Tip: Graphical Apps Doesn&#8217;t Launch via Root, Sudo, Gksu"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/wayland-icon245.png\" alt=\"\" width=\"245\" height=\"250\" class=\"alignleft size-full wp-image-7223\" \/><\/p>\n<p>Ubuntu 17.10 uses <b>Wayland<\/b> in the default session and Xorg for optional. However, many graphical applications need to run as root so far does not launch in Wayland.<\/p>\n<p>You&#8217;ll get following similar errors while running graphical applications via root:<\/p>\n<ol>\n<li>For some applications, e.g., Synaptic Package Manager, Grub Customizer, Gparted, and Ubuntu Tweak, they does not launch in Wayland.\n<p>Or you may get following error when trying to launch them via <code>gksu<\/code> command:<\/p>\n<p><b>Failed to run *** as user root. Unable to copy the user&#8217;s Xauthorization file.<\/b><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/fail-run-grub-customizer.jpg\" alt=\"\" width=\"431\" height=\"193\" class=\"aligncenter size-full wp-image-7229\" \/><\/p>\n<li>Starting graphical application via <code>sudo<\/code> in terminal window will get error:\n<p><b>No protocol specified. Gtk-WARNING **: Cannot open display: :0<\/b><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/cannot-opendisplay-600x128.jpg\" alt=\"\" width=\"600\" height=\"128\" class=\"aligncenter size-large wp-image-7225\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/cannot-opendisplay-600x128.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/cannot-opendisplay-450x96.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/cannot-opendisplay.jpg 748w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/li>\n<\/ol>\n<p>The most straightforward workaround is to use xhost to temporarily allow the root user to access the local user&#8217;s X session.<\/p>\n<p>To do so, run command:<\/p>\n<pre style=\"border:none;\">xhost si:localuser:root<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-allow-root-600x97.jpg\" alt=\"\" width=\"600\" height=\"97\" class=\"aligncenter size-large wp-image-7227\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-allow-root-600x97.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-allow-root-450x73.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-allow-root.jpg 749w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>After running the command, these graphical applications can be launched from app launcher or via <code>sudo<\/code>, <code>gksu<\/code>, <code>pkexec<\/code> commands until you log out.<\/p>\n<p>To make this work automatically at login, search for and launch <b>Startup Applications<\/b> utility, click the &#8220;Add&#8221; button to run the command at startup:<\/p>\n<ul>\n<li>name: whatever<\/li>\n<li>command: <code>xhost si:localuser:root<\/code><\/li>\n<li>comment: whatever<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-startup-600x502.jpg\" alt=\"\" width=\"600\" height=\"502\" class=\"aligncenter size-large wp-image-7228\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-startup-600x502.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-startup-450x376.jpg 450w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2017\/10\/xhost-startup.jpg 679w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>","protected":false},"excerpt":{"rendered":"<p>Ubuntu 17.10 uses Wayland in the default session and Xorg for optional. However, many graphical applications need to run as root so far does not launch in Wayland. You&#8217;ll get following similar errors while running graphical applications via root: For some applications, e.g., Synaptic Package Manager, Grub Customizer, Gparted, and Ubuntu Tweak, they does not [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[693],"class_list":["post-7222","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-wayland"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/7222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=7222"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/7222\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=7222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=7222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=7222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}