{"id":3732,"date":"2024-01-31T13:20:05","date_gmt":"2024-01-31T13:20:05","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=3732"},"modified":"2024-01-31T13:20:06","modified_gmt":"2024-01-31T13:20:06","slug":"auto-running-the-gui-as-root","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/pi-operating-systems\/raspbian\/gui\/auto-running-the-gui-as-root","title":{"rendered":"Auto Running The GUI as root"},"content":{"rendered":"\n<p>You can use the raspbian preferences via the GUI to cause the pi user to be auto logged in at boot up and the GUI automatically run. &nbsp;However&nbsp;if you need to run with root privileges&nbsp;due to needing IO pin&nbsp;control (yes yes its not advised to run as root, but for many uses its fine where the security issues aren\u2019t a concern) then set the raspbian preferences to boot to the command line. &nbsp;Now open this file (the \u201csudo nano\u201d assumes you are editing it from the command line):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/rc.local<\/code><\/pre>\n\n\n\n<p>Before the \u201cexit 0\u201d line in it add the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Auto run the GUI as root\nsudo startx<\/code><\/pre>\n\n\n\n<p>Save it by pressing Ctrl+X, \u201d Y\u201d, ENTER<\/p>\n\n\n\n<p>Re-boot your RPi and it should automatically run the GUI as the root user. &nbsp;<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u201cNo session for pid 696\u201d<\/h5>\n\n\n\n<p>We get this message when using this method, the number will be random based on system. &nbsp;It may well be because of using sudo startx.<\/p>\n\n\n\n<p>You can use command \u201cps 696\u201d &nbsp;to&nbsp;see the process there is no session for, for us it was:<\/p>\n\n\n\n<p>&nbsp; PID TTY &nbsp; &nbsp; &nbsp;STAT &nbsp; TIME COMMAND<br>&nbsp; 902 ? &nbsp; &nbsp; &nbsp; &nbsp;Sl &nbsp; &nbsp; 0:00 lxpolkit<\/p>\n\n\n\n<p>lxpolkit is a \u201cPolicy authentication agent\u201d. &nbsp;There\u2019s lots of google resources on no session for PID with lxpolkit but after a few hours of trying we didn\u2019t manage to resolve. &nbsp;Instead we started our application using a script with a delay before it runs so that it simply appears on top of the error message. &nbsp;Bodge, but it works for us\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can use the raspbian preferences via the GUI to cause the pi user to be auto logged in at boot up and the GUI automatically run. &nbsp;However&nbsp;if you need to run with root privileges&nbsp;due to needing IO pin&nbsp;control (yes yes its not advised to run as root, but for many uses its fine where [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-3732","post","type-post","status-publish","format-standard","hentry","category-gui"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=3732"}],"version-history":[{"count":1,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3732\/revisions"}],"predecessor-version":[{"id":3733,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/3732\/revisions\/3733"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=3732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=3732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=3732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}