rm -f


 
Thread Tools Search this Thread
Operating Systems Solaris rm -f
# 1  
Old 07-06-2011
Prevent remove file owned by root

Hi all,
I need to configure file permission in order to prevent any user to delete a file.

Details:
Code:
$ more /etc/release
                      Solaris 10 10/09 s10s_u8wos_08a SPARC
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                           Assembled 16 September 2009
$ su - root
$ cd /MYFILE
$ ls -ld /MYFILE/
drwx------   2 myuser  myuser        512 Jul  6 13:11 /myuserFILE/proc/bin/

$ echo xyz > xyz.txt
$ chmod 600 xyz.txt

$ ls -la
drwx------   2 myuser  myuser        512 Jul  6 13:10 .
drwx------   5 myuser  myuser        512 Jun 28 11:14 ..
-rw-------   1 root      root          4 Jul  6 13:10 xyz.txt

Code:
$ su - myuser
$ cd /MYFILE

$ cat xyz.txt
cat: cannot open xyz.txt

$ rm -f xyz.txt
$ ls -la
drwx------   2 myuser  myuser        512 Jul  6 13:11 .
drwx------   5 myuser  myuser        512 Jun 28 11:14 ..

Is there a way to prevent myuser from deleting a file? Maybe permission on file or directory...

Thanks to all
Ric

Last edited by ric79; 07-06-2011 at 08:24 AM..
# 2  
Old 07-06-2011
To prevent file deletion, revoke write-access from the directory.

If this is not possible, set the sticky-bit on the directory. In this case, the user may not delete files he cannot write to.
# 3  
Old 07-06-2011
thanks,
could you write the list of commands I should run for the /MYFILE directory ?

R
# 4  
Old 07-06-2011
Code:
chmod 1777 /MYFILE

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question