Operating System - Tru64 Unix
1752767 Members
5407 Online
108789 Solutions
New Discussion юеВ

How to revoke 'rm -rf' permissions

 
nish_1
Frequent Advisor

How to revoke 'rm -rf' permissions

Hi,
I would like to know how to remove 'rm -rf' permission for a file.

With the same user who has ownership of a file,we can delete the file.I would like to know even with the same user who has ownership,file should not get deleted.
4 REPLIES 4
Martin Moore
HPE Pro

Re: How to revoke 'rm -rf' permissions

Hmm, I don't think there's an easy way to do this. If you try using the standard permission bits or ACL's to prevent a user from removing his own file, the owner can simply use setacl or chmod on the file to make it removable. You may be able to circumvent this by having the parent directory set up such that (1) the user doesn't have write permission to it, and (2) the user doesn't own it; I believe this would prevent the owner from unlinking (i.e. deleting) the file from the directory. However, this might be too cumbersome, as it would also prevent the user from creating or modifying any files in that directory.

Another possibility is to have the files owned by a different user, but with full access permissions for the user in question, and put them in a directory (owned by a different user) with the "sticky bit" (1000 octal in numeric form) added to the directory permissions. The sticky bit prevents removal of files from directories by anyone other than their owners, even if the permissions would otherwise allow it. This also might be cumbersome.

Martin
I work for HPE
A quick resolution to technical issues for your HPE products is just a click away HPE Support Center
See Self Help Post for more details

Accept or Kudo

nish_1
Frequent Advisor

Re: How to revoke 'rm -rf' permissions

So is there no way to revoke 'remove' permissions for thr same user who owns the file?
Kapil Jha
Honored Contributor

Re: How to revoke 'rm -rf' permissions

>>>So is there no way to revoke 'remove' permissions for thr same user who owns the file?

I think no because a user owns it...so I suppose he should be able to do anything with that file.

For other files may be use can use other stuffs.

but why cant u trust a user for his own file :)
You may use restricted shell, but it would allow only very few operations.

do a google for restricted shell.


BR,
Kapil+
I am in this small bowl, I wane see the real world......
Pieter 't Hart
Honored Contributor

Re: How to revoke 'rm -rf' permissions

You may think of setting rights to the unix built-in "rm" so only limited users can access this directly.
For other users modify the path, or define an alias, to point to a special rm-script with limited options.