52

Possible Duplicate:
How do I grant sudo privileges to an existing user?

I've been searching for the answer to this but all I find is "It's not a good idea" or "We don't recommend it" and some work around solution is given...

I am a new, yes. There is a good chance I could break stuff, I know. I am happy to break my OS and format it many times if it comes to that but restrictions of ANY kind on my OS enrage me. I want to be able to break stuff if I want, then learn how I broke it and how to fix it.

I want the safety locks off.

Please tell me how to grant a user absolute authorisation.

5

6 Answers 6

49

To give the user "foo" unlimited passwordless access to root privileges via the sudo command, edit /etc/sudoers and add the line:

foo   ALL = NOPASSWD: ALL

See sudo(8) and sudoers(5) for more information.

As was suggested elsewhere, if you know how to use vi then it's a good idea to use visudo to edit /etc/sudoers.

3
28

It is not you who is being restricted (as long as you can sudo or login as root on the command-line), but it is rather every single application you run that is being restricted.

If you give yourself root privileges, every application you run also gains complete power over your computer. That is the restriction, and saying you don't want any restrictions placed over you is like saying you do not want to lock your bike or your door, for it places a restriction upon yourself.

I am amazed no one as of yet has tried to offer you that insight.

10
  • 4
    This is exactly what I was trying to go for with my comment on another answer. The reason for the restriction by the Ubuntu devs is not because they think all users are inept; if that were the case, sudo would be disabled too. It's about giving the user the power to selectively give applications more privileges... and keeping the "bad ones" (be they buggy or malicious) from messing everything up à la Windows XP.
    – Reid
    Jan 22, 2013 at 18:05
  • 3
    @IchimitchHamono You have root access? Sudo access? You have unrestricted access then. If that isn't what you EXPECT it to be, that's your lack of understanding and inability to learn. I bet money, that just like Android/iOS, you'll have to "Root" or "Jailbreak" before you'll get unfettered access on a Steam Box - Linux OR Windows. If typing "sudo", or learning how to edit /etc/sudoers, is too much restriction for you... You won't enjoy your future. Don't like it? Build your own OS - or find a Distro that doesn't have Sudo (or similar) installed.
    – WernerCD
    Jan 22, 2013 at 18:40
  • 2
    @IchimitchHamono: by your own admission, you are new to this. That's completely fine. I even think your question is valid, and interesting. However, your sheer disinterest in finding out why it's not a good idea to actually do this, finding out why you only find posts saying "we don't recommend" it, astonishes me.
    – ilias
    Jan 22, 2013 at 18:50
  • 2
    Linux, and by extension, UNIX, was designed from the get-go as a multi-user operating system, fit for use in networks. Restricting user access is a logical implication of that design. As such, it is deeply embedded in the whole OS and applications that use it. Out of interest, what did you end up doing? Somehow allowing root to log in in a graphical environment?
    – ilias
    Jan 22, 2013 at 19:35
  • 2
    does not answer the question
    – Damnum
    Sep 10, 2019 at 9:03
13

Being a noob, you should better use visudo instead of editting /etc/sudoers on your own, at least because:

  1. It checks that no one is using the /etc/sudoers file at the same time.
  2. When you have finished, it checks the file for making sure it's fine.
0
13

ok, this comes from my hacker days of trying everything in the system to see what it did.

There is a file /etc/passwd that famously holds passwords (or a marker to signify shadow passwords).

In that file, you will see something like this:

root:!:0:0::/:/usr/bin/ksh
daemon:!:1:1::/etc:
bin:!:2:2::/bin:
sys:!:3:3::/usr/sys: 
adm:!:4:4::/var/adm:
uucp:!:5:5::/usr/lib/uucp: 
guest:!:100:100::/home/guest:
nobody:!:4294967294:4294967294::/:
lpd:!:9:4294967294::/:
lp:*:11:11::/var/spool/lp:/bin/false 
invscout:*:200:1::/var/adm/invscout:/usr/bin/ksh
nuucp:*:6:5:uucp login user:/var/spool/uucppublic:/usr/sbin/uucp/uucico
paul:!:201:1::/home/paul:/usr/bin/ksh
jdoe:*:202:1:John Doe:/home/jdoe:/usr/bin/ksh 

[example taken from here]

the two sections that are interest to us are the numbers in position 3 and 4. the first one is the user ID, the second is the group. Notice that in this installation (and most installations) the values for root are both 0

If you use su or sudo to edit this file, and change the numbers on your user ID to be the same as root, then you will become root. (also, you will not be able to use rmuser on your ID, as it is now considered essential to the system)

7
  • add another user and change that one to :0:0: - that way, you can choose to log in as root depending on which name you use on login
    – SeanC
    Jan 22, 2013 at 18:02
  • 3
    @IchimitchHamono: You have the power to 'fully access your system' with the default install. It's just that this power requires you to use the appropriate commands, namely sudo and the like, and enter your password when doing so. The existing setup, and the conventional wisdom of trying to keep things out of root, are there for very good reasons, one of which keeping buggy/malicious software from borking your system without your consent.
    – Reid
    Jan 22, 2013 at 18:02
  • 1
    if something requires root, and you are annoyed at having to type in that command again, sudo !! is your friend, and UAC is microsoft's attempt to be more *nix like - same as the prompt for passwords.
    – SeanC
    Jan 22, 2013 at 18:15
  • 4
    Changing the uid and gid of a user name to 0 and 0 is very likely to lead to problems down the road.
    – jdthood
    Jan 22, 2013 at 18:42
  • 2
    @jdthood Yup, I just did a sudo vi /etc/passwd and changed my uid to 0. After saving passwd, system doesn't know who I am and won't let me run any sudo commands. Yes, immediately creates problem.
    – Sun
    Oct 3, 2017 at 15:14
10

Wouldn't it be better to add the user to the correct group?

sudo usermod -a -G sudo hduser

see also this duplicate question: How do I grant sudo privileges to an existing user?

3
  • 3
    This allows hduser to sudo. hduser will of course have to enter a password when using sudo.
    – jdthood
    Jan 22, 2013 at 18:45
  • Nope. That absolutely would not be better. Jan 15, 2018 at 3:40
  • If you do this, your user has the option to become root, using sudo -i. Then you have the user you want without restriction, without trying to get that same state for you normal user. Basically: if you want root powers, you should be root. And this gives you the way to do just that.
    – Nanne
    Jan 15, 2018 at 11:16
2

For anyone also wanting to liberate their system, this is the solution that worked for me:

  1. load the Terminal
  2. type: sudo passwd root
  3. input your user's password when prompted
  4. create UNIX password when prompted
  5. type: sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'
  6. reboot the system
  7. at the login screen there is now an option to login manually. login with username 'root' and the password you created at step 4

Alternatively:

  1. Throw your hard drive in the bin because it's been tainted by Ubuntu and you'll never be able to get that stink off it no matter how many times you format.
  2. Install a new hard drive
  3. Download a Puppy Linux distro from: http://puppylinux.com/
11
  • 2
    Will Chrome run at all when you do this?
    – Bobson
    Jan 22, 2013 at 20:25
  • No. I had to keep the other user account open for normal usage Jan 23, 2013 at 3:14
  • Then how is this answer any better than sudo?
    – Bobson
    Jan 23, 2013 at 14:10
  • 1
    Yep, you can enable the root account and use that, although that isn't a solution to the original problem. I didn't know that Chrome would refuse to run as root, but now I do. :)
    – jdthood
    Jan 23, 2013 at 15:56
  • @Bobson I didn't say it was better than Sudo. I said I wanted the safety locks off in order to learn, And hey would you look at that, I just learned that some programs will not operate when run as Root. Learning stuff already. No thanks to the stuck up Linux community and their obsession with everyone having to subscribe to the almighty Sudo methodology Jan 15, 2018 at 3:32

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