Linux – User can’t remove symlink which owns

debianfilesystemslinuxrmsymbolic-link

I'm trying to remove symlink, although I have appropriate permission, the operation is denied (the user is called capistrno):

capistrno $ rm -f /var/www/app/current
rm: cannot remove `/var/www/app/current': Permission denied

the user should have all permissions to this file

lrwxrwxrwx 1 capistrano capistrano 42 17. mar 13.09 /var/www/app/current -> /var/www/app/releases/20130317120932/

capistrno $ file /var/www/app/current
/var/www/app/current: symbolic link to `/var/www/app/releases/20130317120932'

Any idea what's wrong?

EDIT:

folder /var/www/app

$ ls -laF /var/www/app/
total 16
drwxr-xr-x 4 www-data   www-data 4096 17. mar 14.15 ./
drwxrwxr-x 4 capistrano www-data 4096 17. mar 00.01 ../
drwxrwxr-x 6 capistrano www-data 4096 17. mar 14.15 releases/
drwxrwxr-x 7 capistrano www-data 4096 17. mar 00.39 shared/

user capistrano belongs to this groups:

$ groups
capistrano www-data rvm

Best Answer

I would suggest you split your operation in 2 parts:

  • 'unlink' the symbolic link
  • 'rm' the unwanted directory

It is cleaner and less prone to errors. You will also get the exact errors, for each of those commands..