Ubuntu – How to prevent users using kill in bash

bashkillUbuntu

I've tried

chmod 700 /bin/kill
chown root /bin/kill

but a normal user can still do:

kill blah

… and successfully kill the app 'blah' running under the user's account.

I'm using Ubuntu (8.10). The bash shell apparently has the kill command built-in and so attempting the above will not work.

Using .bashrc the enable command could be used to disable the built-in kill command each time a terminal is launched, but the .bashrc could then simply be edited by the user using a text editor launched via the GUI to re-enable the kill command. Can I somehow disable a built-in bash command permanently without using .bashrc (which is user-editable)?

Anyone any ideas how I can disable the built-in kill?

Best Answer

The answer is that short of compiling your own version of bash, you can't. Furthermore, even if you succeeded, if your users can compile programs or move binaries onto the system, they can always bring in a kill binary of their own, and be able to issue kills anyway.

Now, the question is: What do you really want to do? Because disabling the kill command isn't, I suspect, your actual goal. You're trying to prevent the users from doing something (presumably kill something they shouldn't), and there's probably a better way to do what you want.