I am trying to silence or supress rm -rf option for a particular user(venkat).
for that am going to write a function in a script test_fun_ls.sh like below
and reading it in .bash_profile
like below
above is working fine but if i use ls with /bin/rm -rf it will have no effect for the function above.
please help.
Also Someone please advice me above process is ok or not
You can either remove the execute permission from the rm command but that will restrict other users also from executing the rmcommand. So, you can make bin folder under user's home folder containing softlinks to executable in /bin folder and just remove rm softlinkfrom user's ~/bin folder and set user's default path under ~/.bashrc file to use ~/bin for search for executable. Note: As mentioned on link user can overcome this approach by resetting $PATH, also would suggest you to try it at dev environment first please.
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
No way unless you recompile the sources. Anything you do on shell level can be circumvented. (I'm not sure if sudo would offer an option to implement this)
What would happen if another flag was in argument 1, then -rf was argument 2? I feel you would never catch it.
If you are concerned that people may delete files by mistake, you would be better to remove their access to do so, else there are many other ways to destroy things, e.g. renaming the files, overwriting etc.
In addition to what has already been said by others, the lack of quoting with your expansions of $1 and $@ make it impossible to remove any file with a pathname containing any whitespace characters. And, expanding on what rbatte1 said, your entire scheme is defeated by simply using any of the following:
and billions of others.
This User Gave Thanks to Don Cragun For This Post:
Hello all,
Solaris 11.
Branch: 0.175.3.35.0.6.0
Asking for some assistance in trying to understand how Apache24 works with svcadm.
I used:
svccfg -s network/http:apache24
listprop
setprop start/user=<rabbit>
setprop start/group=<pod>
This is also set in... (1 Reply)
Here's a snippit from a script I'm working on
srvctl config database | \
awk -F\" '{print "srvctl config database -d " $1 " -a" \
RS "echo =================================================="}' \
> /tmp/x$$.sh
chmod 777 /tmp/x$$.sh
/tmp/x$$.sh
As you can see, I'm piping the... (12 Replies)
Hi,
I have a script that copies a file from one directory to another and compiles it.
What I have now is a menu that calls functions and each function compiles the file.
I want to have a function that compiles the file at the end of the script if the user selects options 1-3 in the menu, but... (0 Replies)
Hello all,
I have created a script that will remove the first two lines of one text file (body.txt) and then add the text from a different text file (header.txt) directly to the beginning of the freshly modified body.txt file. It is as follows:
#!/bin/bash
## This script will add a header... (2 Replies)
To find all the files in your home directory that have been edited in some way since the last tar file, use this command:
find . -newer backup.tar.gz
Is anyone familiar with an older solution?
looking to identify files older then 15mins across several directories.
thanks,
manny (2 Replies)
Hello,
I need to call a function which reside in some package moudle (.pm)
as another user by using su -.
Are anyone know how can I do it?
Thanks (1 Reply)
Dear Friends,
I need a help regarding User defined function in shell script.
My problem is as follows:
my_func.sh
my_funcI(){
grep 'mystring' I.dat
}
my_funcQ(){
grep 'mystring' Q.dat
}
myfuncI
myfuncQ
But As both the function has same function only the... (11 Replies)