Re: Permission to only one directory
Posted by ErmanArslansOracleBlog on Aug 25, 2021; 6:26am
URL: http://erman-arslan-s-oracle-forum.124.s1.nabble.com/Permission-to-only-one-directory-tp10155p10170.html
use chattr +a -R /directory_full_path..
This way, the other user (client user) will be able to create files in that directory, but Linux will not let the user delete the files in that directory.
Demo:
[root@ebsclone /]# mkdir /ermantest
[root@ebsclone /]# chmod 777 ermantest
[root@ebsclone /]# chown oracle:dba ermantest
[root@ebsclone /]# useradd writeonlyuser
[root@ebsclone /]# chattr +a -R /ermantest
[root@ebsclone /]# su - writeonlyuser
[writeonlyuser@ebsclone ~]$ cd /ermantest
[writeonlyuser@ebsclone ermantest]$ touch testfile1
[writeonlyuser@ebsclone ermantest]$ touch testfile2
[writeonlyuser@ebsclone ermantest]$ touch testfile3
[writeonlyuser@ebsclone ermantest]$ rm testfile3
rm: cannot remove âtestfile3â: Operation not permitted
Another test;
[root@ebsclone ermantest]# su - oracle
[oracle@ebsclone ermantest]$ touch createdbyoracle
[oracle@ebsclone ermantest]$ exit
[root@ebsclone ermantest]# su - writeonlyuser
[writeonlyuser@ebsclone ~]$ cd /ermantest/
[writeonlyuser@ebsclone ermantest]$ ls
createdbyoracle testfile1 testfile2 testfile3
[writeonlyuser@ebsclone ermantest]$ rm createdbyoracle
rm: remove write-protected regular empty file createdbyoracle? y
rm: cannot remove âcreatedbyoracleâ: Operation not permitted