Operating System - HP-UX
1833777 Members
2279 Online
110063 Solutions
New Discussion

Re: System Administration

 
Wallace C. Chappell
Occasional Contributor

System Administration

Any recommendations to on how to increase protection from the rm -rf command, other than creating an alias for rm?

Thanks
Not every situation requires the same reaction.
6 REPLIES 6
steven Burgess_2
Honored Contributor

Re: System Administration

Hi

1. Sounds to me like an education issue
2. Be careful who you give root access to ?

Steve
take your time and think things through
A. Clay Stephenson
Acclaimed Contributor

Re: System Administration

Yes, discipline and user training. UNIX is designed to do what it is told and not ask confirmation. It assumes that the user knows what he is doing. You can, of course, create an alias that asserts the -i flag. Some of the other UNIX flavors (especially on that is popular on PC's) reverse the logic and asks before doing the rm.
If it ain't broke, I can fix that.
Wallace C. Chappell
Occasional Contributor

Re: System Administration

Thanks for the input.
Not every situation requires the same reaction.
Rick Garland
Honored Contributor

Re: System Administration

A user who has the access to their own directories/files will have the ability to rm their stuff. All you can do is educate and/or provide them with ample warnings.

For all other situations, you will want the education/knowledge of who has the ability to do the rm command. This is a big part of knowing who has the root access, or who has UID=0 (equal to root access).

There is no sure way to prevent. You can provide additional warnings via aliasing and you can educate.

roger_122
Occasional Advisor

Re: System Administration

Its also helpful to have the PS1 variable set in the .profile so the current directory will always be displayed

(PS1=`hostname`'$PWD # ' ; export PS1)

and get in the habit of always specifying the entire path when using the rm command.
vinod_25
Valued Contributor

Re: System Administration

hi wallace

There are safeguards that can be taken by the user to prevent an
accidental removal of files by the rm command.

1. If running ksh (Korn Shell), you can set an alias in your
.kshrc file to default rm to rm -i. This will cause rm
to prompt you for verification before removing your files
whenever rm is executed.
Enter the following file in the .kshrc file:

alias rm='rm -i'

2. Creating a file named "-i" in a directory will expand the
rm * command to rm -i, thus prompting for verification.
You must put this file in each subdirectory to safeguard it.
Create the "-i" file as follows:

echo "" > -i

regards

Vinod K