After installing DevStack, I was forced to put my user as root and gain access. I did that and now I would like to undo it. I removed the line from visudo but still no success. What want like to reverse is the following: Using Ubuntu and login with my user ("USER") and when i open my terminal i execute the sudo -i command, I was asked to enter the password to have root access. After the changes I made with DevStack, when I execute the sudo -i command, I'm not asked for any password, I just have root access (and I don't like this). Is there any way to change this back so when I execute the sudo -i command I will be asked for a password?

As to add the file of visudo

# This file MUST be edited with the 'visudo' command as root.
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
# See the man page for details on how to write a sudoers file.
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
  • sudo means: Do things as if you were root. So do you get asked for password if you type su? If not, I'd know how to "solve" this. (Besides, the -i option is only for instructing the shell to also read the resource files, e. g. .profile / .login etc. Which is to say that sudo ought to show the same (erroneous) behavior with or without -i.) Nov 23, 2014 at 20:56
  • 1
    Remove the files 50_stack_sh, cinder-rootwrap, neutron-rootwrap, nova-rootwrap from /etc/sudoers.d and it will start asking you for the password again.
    – talonx
    Jul 30, 2015 at 5:31
  • That work ! and i delete this files from other location that appear too but thanks man ! :D Oct 2, 2015 at 10:25

1 Answer 1


If you want to be allowed to run commands as root, but be prompted to enter your own password, then edit the sudo configuration by running the visudo program. This brings up your favorite text editor to edit the sudo configuration file. Look for the line that authorizes you to run commands as root and remove the text NOPASSWD: from that line. Save the file and exit the editor.

If you don't want to be allowed to run commands as root without entering the root password, then follow the same procedure as above, but remove the line instead of just removing NOPASSWD: from it. Then, to run commands as root, use su instead of sudo and type the root password. Make sure that you know the root password before doing this!

You may be allowed to run commands as root via sudo either because some rule allows your user (a line starting with your username) or because some rule allows a group that you're a member of (a line starting with a percent sign and the group name, e.g. %admin …). If you want to remove yourself from that group, run deluser username groupname, e.g. deluser alice admin. Changing group membership has no effect on your current session, it takes effect the next time you log in.

Note that if sudo asked you for a password, it won't ask you again for the next few minutes (IIRC the default is 15 minutes on Ubuntu). Depending on the configuration, sudo may keep a separate password delay per terminal or a single one per user.

  • There is no line where the "NOPASSWD:" is ... above iv change the question as i put the visudo file as a result of what i have. Nov 24, 2014 at 15:20
  • @user3523605 With this configuration, sudo does ask you for a password (but if you used it recently it won't ask you again for the next 15 minutes). Nov 24, 2014 at 16:58
  • 1
    No i have not use recently and that is the problem .. everything is ok ( by the book ) but i think we are missing something that this think wont work. Any other suggestion where can i change this. And in the visduo file i have one line where my user was there like this below the root line: ivan ALL=(ALL:ALL) ALL i have remove this line but still nothing still same problem. When i put sudo -i im going directly without asking for password in root mode. Nov 24, 2014 at 18:40
  • @user3523605 You're probably in the sudo or admin group. Nov 24, 2014 at 18:56
  • Yes i think I am. But it was always in that group. As Administrator always ask me for password when i go to root. This is what i have in /etc/passwd ivan:x:1000:1000:Ivan,,,:/home/ivan:/bin/bash Nov 25, 2014 at 10:45

You must log in to answer this question.

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