<div dir="ltr"><div><div><div><div><div><div>I usually do it as follows:<br><br></div><div>$ vi config_file<br></div><div>[File wold not save]<br></div>:w /tmp/k<br></div>:q!<br><br></div>$ sudo vi config_file<br></div>:1,$d<br>
</div>:r /tmp/k<br><br></div>A bit too long compared to Tim's shortcut ...<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 21, 2014 at 11:26 AM, L.D. Paniak <span dir="ltr"><<a href="mailto:ldpaniak@fourpisolutions.com" target="_blank">ldpaniak@fourpisolutions.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Thanks Tim!  <br>
    A solution to one of the great unsolved (for me at least) problems
    of the universe: how to cleanly save that file you have no right to
    save after you have made several dozen changes.<br>
    <br>
    I challenge the emacs crowd to come up with an equivalent.<div><div class="h5"><br>
    <br>
    <div>On 05/21/2014 10:53 AM, Tim Laurence
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>I have found <br>
            </div>
               "sudo bash"<br>
          </div>
          gives me odd results because it uses a mix of the login and
          root environmental configurations.<br>
          <br>
        </div>
        <div>It find it is better to do<br>
        </div>
        <div>  sudo su -<br>
        </div>
        <div>because that reinitializes the environment to be a pure
          root one. A shortcut for this is<br>
        </div>
        <div>  sudo -i<br>
        </div>
        <div>which does the reinitialization within sudo. This can even
          be combined with -u<br>
        </div>
        <div>   sudo -u database_user -i<br>
        </div>
        <div>to gain access to user accounts that may have highly
          customized environments such as I have found with several
          database servers.<br>
          <br>
        </div>
        <div>One last tip for sudo. If you have ever found yourself
          editing  a config file in vi and find out, when you go to
          write, that you forgot to edit as root and the file is read
          only to you. Try this vi command<br>
        </div>
        <div>    :w !sudo tee %<br>
        </div>
        <div>That translates to write to pipe connected to sudo which in
          turn pipes to tee which is passed the original file-name as a
          output target.<br>
        </div>
      </div>
      <div class="gmail_extra">
        <br clear="all">
        <div>--Tim</div>
        <br>
        <br>
        <div class="gmail_quote">On Wed, May 21, 2014 at 10:35 AM,
          Khalid Baheyeldin <span dir="ltr"><<a href="mailto:kb@2bits.com" target="_blank">kb@2bits.com</a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div>
                <div>
                  <div>
                    <div>
                      <div>I use screen to open many shells, and in one
                        "window", I do:<br>
                        <br>
                      </div>
                      $ su -<br>
                      <br>
                    </div>
                    Then enter the password<br>
                  </div>
                  <br>
                  I am in a root shell in that "window" forever.<br>
                  <br>
                  Or, if it is a machine that you are not logged into
                  all the time, just do:<br>
                  <br>
                </div>
                $ sudo bash<br>
              </div>
              Then enter the password<br>
              <br>
              <div><br>
              </div>
            </div>
            <div class="gmail_extra">
              <div>
                <div><br>
                  <br>
                  <div class="gmail_quote">
                    On Wed, May 21, 2014 at 10:20 AM, John Johnson <span dir="ltr"><<a href="mailto:jvj@golden.net" target="_blank">jvj@golden.net</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div>On 2014-05-21 10:13, Khalid Baheyeldin wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                          Is it just me or what? The su has always been
                          in Linux since forever.<br>
                        </blockquote>
                        <br>
                      </div>
                      It is me. Not you.<br>
                      <br>
                      Many years ago I looked for SU and was advised to
                      do all 'root' stuff with $ sudo.<br>
                      I did not know about $ sudo su<ENTER> until
                      recently.
                      <div>
                        <div><br>
                          <br>
                          JohnJ<br>
                          <br>
                          <br>
                          <br>
                          <br>
                          <br>
                          _______________________________________________<br>
                          kwlug-disc mailing list<br>
                          <a href="mailto:kwlug-disc@kwlug.org" target="_blank">kwlug-disc@kwlug.org</a><br>
                          <a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                  <br clear="all">
                  <br>
                </div>
              </div>
              <div>-- <br>
                Khalid M. Baheyeldin<br>
                <a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br>
                Fast Reliable Drupal<br>
                Drupal optimization, development, customization and
                consulting.<br>
                Simplicity is prerequisite for reliability. --  Edsger
                W.Dijkstra<br>
                Simplicity is the ultimate sophistication. --   Leonardo
                da Vinci<br>
                For every complex problem, there is an answer that is
                clear, simple, and wrong." -- H.L. Mencken<br>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            kwlug-disc mailing list<br>
            <a href="mailto:kwlug-disc@kwlug.org" target="_blank">kwlug-disc@kwlug.org</a><br>
            <a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
kwlug-disc mailing list
<a href="mailto:kwlug-disc@kwlug.org" target="_blank">kwlug-disc@kwlug.org</a>
<a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
kwlug-disc mailing list<br>
<a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a><br>
<a href="http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org" target="_blank">http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com" target="_blank">2bits.com</a>, Inc.<br>Fast Reliable Drupal<br>Drupal optimization, development, customization and consulting.<br>
Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. --   Leonardo da Vinci<br>For every complex problem, there is an answer that is clear, simple, and wrong." -- H.L. Mencken<br>

</div>