Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing root from deleting files

Status
Not open for further replies.

chrisw669

Technical User
Feb 19, 2002
43
0
0
US
I was wondering if there was a way to prevent even root from deleting certain files with the standard rm command.

I sadly made a rather bad mistake this morning by deleting a couple of very important files. I know if you are not root and try to delete a file it asks if your sure you want to delete. Is it possible to set root user up this way?
 
As far as I know there is no way in AIX to prevent someone with root access from deleting a file if they wanted to. There is however a linux command named chattr that will change the files attributes that even root can't delete the file.

I've seen a lot of Linux/AIX compatibilty stuff at IBM's site, maybe they have a port.

Sorry I couldn't be more helpful.
 
You might also put this line in the system wide profile (/etc/profile) that gets executed prior to your own personal .profile

alias rm="rm -1"

This way you always get the interactive action of the -i option and it'll make it a bit cumbersome when you WANT to do a mass delete but at least it'll save you from a replay of your mistake.

Everyone has been there, everyone has done it.
 
you should export that alias, and use -i instead of -1 i think... but aliases are not exported from /etc/profile. add this to /etc/environment:

alias -x rm='rm -i'

alternatively, you can set up an environment file just for root. to do this, put this line in root's .profile:

export ENV=filename

generally this is done as per my own .profile, in its entirety:

export ENV=~/.kshrc

if [ -s "$MAIL" ] # This is at Shell startup. In normal
then echo "$MAILMSG" # operation, the Shell checks
fi # periodically.

f

all of my other stuff, exported aliases, env vars, function listings and directory, and other such, are in my .kshrc.

IBM Certified -- AIX 4.3 Obfuscation
 
Doh, didn't think about creating an alias.

One problem tho, what would the reason be for root to not read it's own .profile in /home/root?
 
nevermind. moved .profile to / and works fine.
 
sorry about the rm -1, I meant to write rm -i

It's been a crazy morning & I didn't proof read.

My bad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top