New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

How can I delete directories?

Got problems with your B2 or B3? Share and get helped!
Post Reply
saudadegostosa
Posts: 12
Joined: 07 Jan 2011, 04:24

How can I delete directories?

Post by saudadegostosa »

Hi,

I have the problem that I cannot delete the folders that have been created during the installation of Joomla and Dokuwiki - since I don't have the permissions to delete them.

Is there any tool or script to delete those directories on the B3? (As fas as my hoster is concerned, I had the same problem on their server, but they offered a tool in the user administration area to change the permissions.)
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: How can I delete directories?

Post by Ubi »

if the folders you mention are in your home dir you should be able to delete them. If not, you may require root access (it really depends on the actual permission settings which you did not provide). Easiest is to log into the ssh console, su to root and delete the files. Excito was wise not to allow root access in the web console.
Gordon
Posts: 1462
Joined: 10 Aug 2011, 03:18

Re: How can I delete directories?

Post by Gordon »

Regretfully Unix style rights are rather simplistic and there's no such thing as inherited or superimposed rights. Yes the 'sticky' bit adds some additional control, but it's not full-proof (or is it fool-proof?). Samba has the force user/force group configuration option, but that only works if you add files through Samba (i.e. the windows networking shares).

Best way to make sure you will always have control over every file that is placed within your home folder, is to make use of Access Control Lists. You'll need to enable this first though.

The kernel already supports it, so to activate it just do:

Code: Select all

mount -o remount,acl /home
You need the ACL tools to be able to change and view the rights

Code: Select all

apt-get install acl
To give a user full control over everything that is created in his homedir, regardless of owner/group and create mask, issue the command:

Code: Select all

setfacl -d -m u:<username>:rwx /home/<username>
Note that this will not change rights to files and folders that already exist, but only applies to newly created files and folders (the '-d' ACL's are inherited). Also note that to make this permanent you need to change the mount parameters in fstab so that /home will support ACL's from start-up
ryz
Posts: 183
Joined: 12 Feb 2009, 06:03

Re: How can I delete directories?

Post by ryz »

Does not the default ACL properties have the same problem as the sticky properties? If you copy files from other places they will not use the default ACL. So the only way to be certain to always be able to access files is to have a cron job run periodically that sets the permission to what you want. Preferably by using ACL since it is much easier to get what you want with ACL. That I what I needed to do to make sure that me and my wife always could access and edit our common files
saudadegostosa
Posts: 12
Joined: 07 Jan 2011, 04:24

Re: How can I delete directories?

Post by saudadegostosa »

Thanks, but isn't there any simple way to regain ownership of directories? As I said, my hoster All-inkl offers a small tool, I simply choose the directories that I want to delete (such as Joomla or Dokuwiki) and then get assigned the rights. Afterwards, I can simply delete them using Filezilla...
Gordon
Posts: 1462
Joined: 10 Aug 2011, 03:18

Re: How can I delete directories?

Post by Gordon »

ryz wrote:Does not the default ACL properties have the same problem as the sticky properties? If you copy files from other places they will not use the default ACL. So the only way to be certain to always be able to access files is to have a cron job run periodically that sets the permission to what you want. Preferably by using ACL since it is much easier to get what you want with ACL. That I what I needed to do to make sure that me and my wife always could access and edit our common files
Actually no. ACL defaults will be enforced with every newly created file, regardless of what method or service does the creating. Note that this statement includes a dependency: the file or folder must be newly created. If you move a file or do a 'cp -al' (to duplicate the inode for a file) the ACL enforcement will only be effective on the inode - not on the file itself.

Also note that the trick in ACL is not about faking the user- or group name, but adding additional rights on top of the regular Unix style rights. So rather than just being able to assign rights to 'user' and 'group', which can be anyone and anygroup if you permitted writing to 'other', ACL's allow you to give full rights to a particular user or group.

Example:

Code: Select all

root@b3:/home# getfacl *
# file: admin
# owner: admin
# group: admin
user::rwx
group::r-x
other::r-x

# file: gordon
# owner: gordon
# group: users
user::rwx
group::--x
other::--x
default:user::rwx
default:user:gordon:rwx
default:group::---
default:mask::rwx
default:other::---

# file: lost+found
# owner: root
# group: root
user::rwx
group::---
other::---

# file: storage
# owner: root
# group: users
# flags: -s-
user::rwx
group::rwx
other::rwx
default:user::rwx
default:group::rwx
default:group:users:rwx
default:mask::rwx
default:other::rwx

# file: web
# owner: root
# group: users
user::rwx
group::rwx
other::r-x
default:user::rwx
default:user:gordon:rwx
default:user:www-data:rwx
default:group::rwx
default:mask::rwx
default:other::---

root@b3:/home#
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: How can I delete directories?

Post by Ubi »

If the issue here is that you want to be able to share write access over some files, would editing the umask settings (in smb.conf or at system level) not solve this problem?
Gordon
Posts: 1462
Joined: 10 Aug 2011, 03:18

Re: How can I delete directories?

Post by Gordon »

saudadegostosa wrote:Thanks, but isn't there any simple way to regain ownership of directories? As I said, my hoster All-inkl offers a small tool, I simply choose the directories that I want to delete (such as Joomla or Dokuwiki) and then get assigned the rights. Afterwards, I can simply delete them using Filezilla...
As hinted by ryz, you can create a cron job to run one or more chmod/chown commands at regular intervals. Can be tricky though, because some services require very specific file rights which are easily destroyed this way.
Gordon
Posts: 1462
Joined: 10 Aug 2011, 03:18

Re: How can I delete directories?

Post by Gordon »

Ubi wrote:If the issue here is that you want to be able to share write access over some files, would editing the umask settings (in smb.conf or at system level) not solve this problem?
umm, no. Umask is a limit on what rights can be assigned. If a process decides to impose much stricter rights, umask will not add what is missing.
Post Reply