1

i have a user named "tony" which do not have permission to use command fdisk, so i do like this:

vim /etc/sudoers

# add the following line
tony ALL=(root) /sbin/fdisk

after that, I convert back to tony, and run command fdisk -l, but i still get the following errors: do not have enough permission,

but when i run command sudo -l, i can get this:

(root) /sbin/fdisk

I am a little confued why user tony still haven't permission to run fdisk?

2
  • What command did you run with sudo? The entry in sudoers has to match the command you actually use. – Stephen Kitt Mar 29 at 7:30
  • Don't ever use vim /etc/sudoers - always use visudo as it does syntax checking for you too – roaima Mar 29 at 8:53
2

When /etc/sudoers is used to grant permission to run some command as a particular user (often as root), the user will still need to prefix that command with sudo. In other words you should run sudo fdisk -l instead of just fdisk -l.

Because sudo is a security-critical tool, it may even require you to specify the actual path of the permitted command and not a path that includes symbolic links. In a fresh install of RHEL 8, the classic /bin and /sbin directories have been replaced with symlinks to /usr/bin and /usr/sbin respectively.

You might want to run realpath /sbin/fdisk and see what it reports: if it says /usr/sbin/fdisk, then you should specify the sudoers line as:

tony ALL=(root) /usr/sbin/fdisk
2
  • FWIW it's /sbin/fdisk on my Pi – roaima Mar 29 at 8:55
  • 1
    @roaima on Ubuntu it is under /usr/sbin/. – GAD3R Mar 29 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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