-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.

Jack
  • 71

1 Answers1

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.

muru
  • 207,228