This question already has an answer here:

I am trying to gain root user access to another user so that I can run a command with adding sudo in front of any command.

Example: fdisk -l

Getting the error message as:

fdisk: cannot open /dev/loop0: Permission denied
fdisk: cannot open /dev/loop1: Permission denied
fdisk: cannot open /dev/loop2: Permission denied
fdisk: cannot open /dev/loop3: Permission denied

I tried to give the root user access to the user with the name sudhir.

switched to root user with su -


Added the user as

root    ALL=(ALL:ALL) ALL
sudhir  ALL=(ALL:ALL) ALL

screenshot of the sudoers file

Saved with ctrl+o, switched to user & executed the command fdisk -l, still getting the same error.

Any idea?

marked as duplicate by Eliah Kagan, mook765, karel, Fabby, Kulfy Jul 12 at 7:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    Did you remember to logout/login after changes to user permissions? – user535733 Jul 10 at 0:52
  • 1
    You must still type sudo fdisk -l as user sudhir. – PerlDuck Jul 10 at 8:48
  • 1
    Is your goal that all commands run by sudhir, even without sudo, run as if by root? This is inadvisable; e.g., users shouldn't run firefox or libreoffice as root (nor with abilities equivalent to root's). Even if you're not concerned about security, this would make some strange and unexpected mistakes easier to make. If you still want that, I recommend you edit to make that clear. Otherwise, I recommend you edit about what you do need. Did @PerlDuck's comment answer your question? Do you want sudo not to require a password? Does sudhir want a root shell (as with sudo -i)? – Eliah Kagan Jul 11 at 1:17
  • I have updated sudoers file saved (ctrl+) & exited (ctrl+x). – user497091 Jul 11 at 2:40
  • @PerlDuck Im trying run command fdisk -l with user "sudhir" without sudo command infront. Just like the root user. – user497091 Jul 11 at 2:43