This is just me wanting to understand 'sudo' better.
I am logged in to my Ubuntu 18.04LTS machine as 'alan' which is a normal user, and is a member of the 'sudo' group:
$ groups
alan adm cdrom sudo dip plugdev lpadmin sambashare
First I did this (I have correctly entered my password):
sudo touch /lost+found/test.file
I get these:
$ ls /lost+found/
ls: cannot open directory '/lost+found/': Permission denied
and
$ sudo ls /lost+found/
test.file
That is completely what I would expect. However, I don't understand why I get this:
$ sudo -u alan ls /lost+found/
ls: cannot open directory '/lost+found/': Permission denied
Why can't I run an 'admin' command, as myself, if I am a member of the sudo group, and I have entered my password?
Clearly I don't understand how 'sudo', or more specifically, 'sudo -u' works :-)
0 Answers