{"id":4883,"date":"2016-01-14T10:30:00","date_gmt":"2016-01-14T15:30:00","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=4883"},"modified":"2016-01-14T10:30:01","modified_gmt":"2016-01-14T15:30:01","slug":"switch-to-editing-a-file-with-sudo","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=4883","title":{"rendered":"Switch to Editing a File with SUDO"},"content":{"rendered":"<p> Here&#8217;s a very useful tip <\/p>\n<blockquote class=\"twitter-tweet\" lang=\"en\">\n<p lang=\"en\" dir=\"ltr\">super useful when you open a file that needs sudo perms to edit\/save: <a href=\"https:\/\/t.co\/7Kis1RXa1o\">https:\/\/t.co\/7Kis1RXa1o<\/a> i have that bound to C-x C-v <a href=\"https:\/\/twitter.com\/hashtag\/emacs?src=hash\">#emacs<\/a><\/p>\n<p>&mdash; Sriram Thaiyar (@s_thai) <a href=\"https:\/\/twitter.com\/s_thai\/status\/684589549578657792\">January 6, 2016<\/a><\/p><\/blockquote>\n<p> <script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p> especially if you administer your own machine and often need to edit root-owned files. <\/p>\n<p> If you&#8217;re like me, you forget to open the file with SUDO. Fortunately, Emacs protects you from making a lot of changes that you can&#8217;t save by marking the buffer read only but you still have to back out of the file and reopen it with SUDO. With Thaiyar&#8217;s tiny Elisp function, you can just push a button and automatically re-open the file with SUDO. <\/p>\n<p> Even if you don&#8217;t want to install the code in your config file or you find yourself on someone else&#8217;s machine, you can do the same trick manually<sup><a id=\"fnr.1\" class=\"footref\" href=\"#fn.1\">1<\/a><\/sup>. <\/p>\n<div id=\"footnotes\">\n<h2 class=\"footnotes\">Footnotes: <\/h2>\n<div id=\"text-footnotes\">\n<div class=\"footdef\"><sup><a id=\"fn.1\" class=\"footnum\" href=\"#fnr.1\">1<\/a><\/sup> <\/p>\n<div class=\"footpara\">\n<p class=\"footpara\"> Although to be fair, it&#8217;s not clear that that would be much easier than just starting over. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a very useful tip super useful when you open a file that needs sudo perms to edit\/save: https:\/\/t.co\/7Kis1RXa1o i have that bound to C-x C-v #emacs &mdash; Sriram Thaiyar (@s_thai) January 6, 2016 especially if you administer your own &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=4883\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-4883","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4883"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4883\/revisions"}],"predecessor-version":[{"id":4884,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4883\/revisions\/4884"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}