sudo
ing adds a little bit of a roadblock to doing potentially stupid and dangerous things in the Linux shell, but it is a meager deterrent to newer Linux users. Still, many users login as root
or have become desensitized to sudo
, and may sometimes do bad things like:
chmod 777 /
rm -rf /
doh_oops > /dev/sda
It seems like there are few cases in which a user would really want to do these - their use is probably about 1% intentional and 99% accidental. Granted, it would be best to back up your systems and not do such dangeorus things - but newbies make mistakes, and Linux is unforgiving.
I'm not asking for UAC, but is there some sort of utility that can monitor console/SSH/other interactive sessions for command input and run it through some sort of validator before execution? A few regex rules could prevent a lot of pain, especially for newer Linux admins, and since most of the time you are not running a large number of commands from an interactive session, it would not be too much a hinderance. Ideally, the utility would generate an additional confirmation message - "are you SURE you want to go through with this, because it looks really stupid" - and require the admin to type in something acknowledging the danger beyond the standard "yes" so that he is forced to read it.
Does this type of utility exist? If so, I'd like to know where to get it.
If it doesn't, and it's a bad idea, please explain why.
sudo
does protect against your third example. That command will fail withPermission denied.
The root privileges only apply to the process itself and not the shell you ransudo
from.alias rm='rm -i'
:D