Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've searched for this, and the answer is probably in a million places on the 'net, but I can't find it...

How do you give your account root privileges in Linux so that you don't need to sudo every single command that requires privileges? It's even more annoying than Windows's User Accounts Control.

(Please... I don't need a lecture on how I would be living a dangerous life. Thank you.)

share|improve this question
add comment

5 Answers

You don't. Two things you can do are:

1) Run sudo -s to stay root when you plan on entering multiple commands and don't want to keep prefixing them with sudo.

2) You can configure your sudoers file to allow you to run sudo without having to enter your password.

share|improve this answer
    
Well, what I don't understand is, if I can just log in as "root" so easily and never have to even think about the word "sudo", then why can't I do the same thing in a different account? –  Mehrdad Jan 11 '11 at 2:43
    
@Lambert: Because those other accounts are not UID 0. –  JanC Jan 11 '11 at 3:47
    
Huh... so even adding myself to the group sudo or even something like that isn't enough? :( –  Mehrdad Jan 11 '11 at 5:34
add comment

Does this work for you?

sudo EDITOR=gedit visudo

Change this line:

%admin ALL=(ALL) ALL

to this line:

%admin ALL=(ALL) NOPASSWD: ALL

No lectures. :)

share|improve this answer
1  
+1, but the trouble is, it still requires me to type sudo. –  Mehrdad Jan 11 '11 at 19:19
    
@Lambert Ok, well, I don't want to do this to test it out, but I think you can just give root a password 'sudo passwd root '. Logout as your user; login as root. Now does GDM let root login? –  user8290 Jan 11 '11 at 19:25
1  
Well, I've already done that to set the root password and log in as root, and of course I don't need to sudo anymore. The trouble is finding out how to do the same thing for a different account. –  Mehrdad Jan 11 '11 at 19:33
add comment

You could install/activate the 'su' command and configure the shell to run it on startup.

share|improve this answer
    
Is there any more "direct" way? Such as using sudoers or by adding myself to some special group? –  Mehrdad Jan 11 '11 at 1:19
    
sudo -s does the same thing. –  psusi Jan 11 '11 at 2:37
    
@psusi: But isn't the point of the question precisely to not have to do that every single time I start the computer? –  Mehrdad Jan 11 '11 at 2:41
    
Is there any way to make it not ask for the password every single time? –  Mehrdad Jan 11 '11 at 10:39
add comment

I don't see how hard it is to run sudo -i once in a terminal, and then just use this one terminal (or you could open more than one, but then you would have to type your password again) to do all your sudo stuff.

(And no, I can't really see the big problem in typing your password once in a while. It's really not that time consuming, and unless you close your terminal after each command, sudo will not ask for your pass for a while after you have authenticated).

share|improve this answer
1  
It's not that it's time-consuming, it's just that it's very irritating. If I say I want to change my login screen's wallpaper, I don't need an "Are you out of you mind?! I can't trust you." message asking me if I'm in fact sane for even thinking about performing such a High Privilege action, telling me that, if I put in my password wrong, this event will Be Reported. It's like my own computer doesn't trust me, and when you're working for a while, it gets God-darn annoying that other people's silly actions with the computer makes your own computer question you. –  Mehrdad Jan 11 '11 at 10:23
    
Not meaning to take out my anger at this on you, but sometimes, "safety" features in software that are designed to protect inexperienced users just drive me nuts. If I want to make my computer explode, there's no need for anything more than an "Are you sure?!" message with a "Don't ask this again." box... any more, and it just defeats the purpose of having a confirmation at all. If I have to enter a confirmation for everything, there might as well not be one -- it's not going to change my determination, but at least I'll get the same things done five times as fast with none of the irritation. –  Mehrdad Jan 11 '11 at 10:32
    
Ubuntu's security design is for a home environment with multiple users. System-wide changes should only be done by a trusted individual, not just someone who happens to have a user account or happens to be borrowing your account. –  Jeremy Bicha Jul 31 '11 at 11:31
add comment
up vote 0 down vote accepted

The correct answer to my question:

You can change your user ID (UID) and group ID (GID) to zero in /etc/passwd, to gain root privileges.

However:

If you do, you will not be able to log back in!

You can, nevertheless, create a new user, and change his group/user ID to 0. Essentially, that user will be another root, but with a different profile folder, etc.

Then you can use that profile as if you were root Himself! :D

Another "solution":

(if you like blank passwords)

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

Note:

You may also need to enable passwordless login; I'm not sure if that's necessary, though.

share|improve this answer
    
I have read somewhere that using "sudo bash" do the job. Have you tried this ? –  Curious Apprentice May 4 '12 at 3:09
    
@CuriousApprentice: The whole point was to avoid sudo. –  Mehrdad May 4 '12 at 4:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.