5

I ran sudo ls as user1 and I got this message.

Sorry, user user1 is not allowed to execute '/bin/ls' as root on hostname.

And this is my user1 group info and sudoers file.

user1@hostname:$ id
uid=1000(user1) gid=1000(user1) groups=1000(user1),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lpadmin),111(sambashare)

user1@hostname:$ cat /etc/sudoers
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# 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

I don't know what changes I made before this problem occurred. My system is Ubuntu 14.04.5 (DigitalOcean).

2
  • 4
    Add the output of sudo -l, please.
    – muru
    Aug 28, 2017 at 16:49
  • 1
    @muru Matching Defaults entries for user1 on hostname: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr‌​/bin\:/sbin\:/bin\:/‌​snap/bin User user1 may run the following commands on hostname: (ALL : ALL) ALL (root) NOPASSWD: !ALL, /bin/bash
    – PoundXI
    Aug 29, 2017 at 3:52

2 Answers 2

1

I found the problem in the file /etc/sudoers.d/user1.

I had set user1 to execute only sudo bash command and forgotten about it.

Thanks muru for suggesting the sudo -l command.

user1   ALL=NOPASSWD: !ALL, /bin/bash
1

Usually it is a problem with your additions to /etc/sudoers or /etc/sudoers.d If you use a command outside of files in secure_path you need to add the path (for example, /my/special/path/bin

You must log in to answer this question.

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