-3

I want to enable root privileges permanently so that, for example, I never need to type sudo. I also want a blank password.

I found a thread addressing this with link Always Sudo Privileges. Exactly what I want to do is summarized as follows.

  1. Run the commands below, and compare the outputs

    sudo cat /etc/shadow
    sudo sed "s/\(^$(whoami):\)[^:]*/\1/" /etc/shadow
    

    You should see that the latter has removed the gibberish in front of your username (which is read using $(whoami)). (If you don't, don't continue!)

  2. When you're ready, run the command to overwrite /etc/shadow (at your own risk!)

    sudo sed "s/\(^$(whoami):\)[^:]*/\1/" /etc/shadow > /etc/shadow
    
  3. Your account now has a blank password, and you should no longer be prompted for sudo permissions. (At least, that's what happened to me.)

The problem is that I get a permission denied on the command that actually changes /etc/shadow. Changing ownership of the file first allows the command to execute, but then I do not seem to have a blank password. If I log out, I can't get back in, neither blank nor my original password are accepted.

Please help me understand why these directions are not working for me.

I have seen several questions like this in trying to resolve my issue, and they often devolve into a lecture on why some feel this is a bad idea. Please just help me figure this out without this thread going there. Without knowing my specific situation, no one on this thread can know that this is a bad idea.

3
  • 1
    Well, it's like "presumed innocent until proven guilty": passwordless, always root - bad idea until proven otherwise for each individual case.
    – muru
    Sep 9, 2014 at 10:01
  • 2
    I am going to add myself to that long list of users that seem to annoy you in trying to help you and to anyone reading this: do NOT do this. "Without knowing my specific situation, no one on this thread can know that this is a bad idea." There is no situation where this is not a bad idea so yes we can.
    – Rinzwind
    Sep 9, 2014 at 10:01
  • Is it not sufficient to promote yourself to root or log in directly as root for some reason?
    – MGodby
    Sep 9, 2014 at 12:37

1 Answer 1

1

This command:

sudo sed "s/\(^$(whoami):\)[^:]*/\1/" /etc/shadow > /etc/shadow

won't work, since the redirection isn't part of the sudo. Instead, do:

sudo sed -i.bak "s/\(^$(whoami):\)[^:]*/\1/" /etc/shadow

I have made this edit on the original post as well.

3
  • Thank you for your quick response. I did this and it successfully modified /etc/shadow. However, the result was the same as when I modified it with the changing ownership method; a password was still required for sudo activities, but neither my original password nor blank were accepted. It sounded like this worked for you, was that with a different version of Ubuntu (I am trying this with 14.04 LTS)? Or perhaps there is an obvious step I am missing?
    – Jack
    Sep 9, 2014 at 10:57
  • @KyleStewart no, I didn't try it out. I'm merely pointing out a syntax error. Is the second field of your shadow entry empty?
    – muru
    Sep 9, 2014 at 13:24
  • Yes, but I am new to Linux and so maybe I should show you everything I did in the terminal starting from a fresh install. I will do it in an edit to my original post, there is not enough room here.
    – Jack
    Sep 9, 2014 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .