How to prevent user from removing and editing .bashrc file


#1

Hello,

I would like to prevent all my users from editing or removing .bashrc within their user directory. Is there any simple method to accomplish this?

thanks


#2

Hello,

I would like to prevent all my users from editing or removing .bashrc within their user directory. Is there any simple method to accomplish this?

thanks

One way to deal with this problem is to make your .bashrc files immutable. Check the following example:

$echo TEST > fileA
 $cat fileA
TEST
 $su
Password: 
# chattr +i fileA
# exit
 $cat fileA
TEST
 $ls -l fileA
-rw-r--r-- 1 lubos lubos 5 Dec  3 07:40 fileA
 $rm fileA
rm: remove write-protected regular file `fileA'? y
rm: cannot remove `fileA': Operation not permitted
 $lsattr fileA 
----i--------e-- fileA

As you can see from the above example, to make your file immutable change to root and use:

chattr +i myfile

to remove immutable file attribute simple execute:

chattr -i myfile

#3

#4