{"id":212,"date":"2013-12-10T14:25:26","date_gmt":"2013-12-10T19:25:26","guid":{"rendered":"http:\/\/thesmokinglounge.net\/?p=212"},"modified":"2013-12-10T15:27:32","modified_gmt":"2013-12-10T20:27:32","slug":"script-for-using-x11-forwarding-and-sudosu-easier","status":"publish","type":"post","link":"https:\/\/thesmokinglounge.net\/?p=212","title":{"rendered":"Script for making X11 forwarding and sudo\/su easier"},"content":{"rendered":"<p>Got tired of trying to explain to users \/cough\/dba&#8217;s\/cough\/ how to use X11 forwarding in conjunction w\/ sudo\/su and finally sat down and created this little script that to generate output that just needs to be copied before using sudo\/su and pasted afterwards. So far it seems to work pretty well.<\/p>\n<p>su-x11.sh<\/p>\n<pre class=\"brush: bash; light: true; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n\r\n## Helper script for X11 forwarding in conjunction w\/ su\/sudo\r\n##\r\n## Written by cybrhippy\r\n##\r\n## 2013.12.10 v1.00 Initial release\r\n\r\n\r\nif &#x5B; &quot;$DISPLAY&quot; = &quot;&quot; ]; then\r\n\techo -e '\\n$DISPLAY is not set and\/or X11 forwarding is not enabled.\\n'\r\n\texit 1\r\nelse\r\n\techo -e 'Copy the below text...\\n'\r\n\techo -e 'export DISPLAY='$DISPLAY\r\n\techo 'xauth add '`xauth list | grep &quot;\\`uname -n\\`\\\/unix\\:\\`echo | awk '{ print substr(&quot;'&quot;${DISPLAY}&quot;'&quot;, index(&quot;'&quot;${DISPLAY}&quot;'&quot;,&quot;:&quot;)+1,2) }'\\`&quot;`\r\n\techo -e '\\n'\r\nfi\r\n\r\nexit 0\r\n\r\n<\/pre>\n<p>This has been tested on RHEL [5,6].x and Solaris 10 [sparc,x86] systems so far.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Got tired of trying to explain to users \/cough\/dba&#8217;s\/cough\/ how to use X11 forwarding in conjunction w\/ sudo\/su and finally sat down and created this little script that to generate output that just needs to be copied before using sudo\/su and pasted afterwards. So far it seems to work pretty well. su-x11.sh #!\/bin\/bash ## Helper [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4,5],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-computer-tiptricks","category-myworld","category-nifty"],"_links":{"self":[{"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":16,"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmokinglounge.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}