0

why am I being denid my rights to delete directories even I created in sudo now I cannot rid myself of it -- yes it is empty

did this to insure I have sudo in the accounts:

userz@bw:~$ sudo adduser userx sudo
[sudo] password for userz: 
The user `userx' is already a member of `sudo'.
userz@bw:~$ sudo adduser userz sudo
The user `userz' is already a member of `sudo'.
userz@bw:~$ cd /usr/local/share

so then I tried to delete the directory:

userz@bw:/usr/local/share$ rmdir themes
rmdir: failed to remove ‘themes’: Permission denied

checked to be sure it is empty:

userz@bw:/usr/local/share$ cd themes
userz@bw:/usr/local/share/themes$ ls
userz@bw:/usr/local/share/themes$ ls -la
total 8
drwxr-xr-x 2 root root 4096 Oct  2 14:20 .
drwxr-xr-x 8 root root 4096 Oct  2 14:20 ..
userz@bw:/usr/local/share/themes$ 

if I am in sudo then why it not let me be super user dude to do what I will?

3 Answers3

3

Being a member of the sudo group just means that you are allowed to sudo into the root role. To actually perform an action as root, specify it as an argument to the sudo command:

sudo rmdir themes

The sudo command will elevate you to root and then execute rmdir themes.

zwets
  • 12,770
  • 2
  • 37
  • 46
2

Beeing a member of the group sudo just allows an user to use the program sudo to get superuser privileges. But you still have to actually use sudo to get superuser privileges, for example

userz@bw:/usr/local/share$ sudo rmdir themes
2

Of course it will not allow you to remove the directory because you are not root!

$ whoami
braiam
$ sudo whoami
[sudo] password for braiam: 
root
$

Before doing any operand that requires sudo privileges you should use sudo, not just being part of the sudo group.

Here is how you delete a directory with sudo:

$ ls -al somedir/
total 8
drwxr-xr-x  2 root   root   4096 oct  2 18:02 .

^ Here I have a directory owned by root.

$ sudo rmdir -v somedir
rmdir: removing directory, ‘somedir’

Here I'm telling to super user to do rmdir (remove directory) with -v (verbose) parameters called somedir.

$ ls -l somedir/
ls: cannot access somedir/: No such file or directory

Now, somedir do not exist anymore, it went KAPUT!

Braiam
  • 69,112