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 ..

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

  • possible duplicate of How to enable root login? – Richard Oct 2 '13 at 23:55
  • 2
    It's not a duplicate the OP does not want to enable root; They want to know why sudo isn't working. Have you set a password for your main user account. Sudo doesn't work if you have a blank password. If not see How do I reset a lost administrative password?. If you have a password then edit the question to give us the output of id and then use instructions to reset the password to log in to a recovery shell don't change your password but provide the output of cat /etc/sudoers – Warren Hill Oct 3 '13 at 6:03
  • @WarrenHill There is no point in doing all this. OP's sudo is working just fine, as the sudo adduser in the first line of his post shows. – zwets Oct 4 '13 at 9:26

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.


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
  • Wow Florian, we wrote almost literally the same at the same time! :-) – zwets Oct 2 '13 at 21:38
  • @zwets and made me write another answer that is not in the sightless the same to you both :P – Braiam Oct 2 '13 at 21:41
  • therefore every time I need to use su right I have to type sudo first then the command ? then what is the sudo [enter] the put password in then [enter] again good for? and thanks – user198193 Oct 2 '13 at 21:57
  • @user198193 what? Please check my answer. – Braiam Oct 2 '13 at 22:02
  • @user198193 the only thing that is good for is to see its usage instructions; that's all you get when you do sudo [enter]. Or do you get something different? – zwets Oct 2 '13 at 22:15

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

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

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!

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.