简体   繁体   中英

How do I blacklist a command in Linux?

I would like to blacklist a command in Linux or add it to sudo to avoid typing it by accident.

I was trying to fix my RVM and for some reason typed:

rvm reset

And lost all my gemsets.

I would like to change this behavior to sudo rvm reset and perhaps add a comment that says what this command will do.

I would wrap a shell function around rvm:

rvm () {
    case $1 in
        reset)
            echo "danger Will Robinson" >&2
            echo "run 'command rvm reset' if you really want it" >&2
            ;;
        *) command rvm "$@" ;;
    esac
}
chown root `which rvm` 
chmod 0700 `which rvm`

to restrict gemset delete command use something like this:

chown -R root `rvm gemdir`
sudo chmod -R 0755 `rvm gemdir`

even chmod maybe unnecessary. But you'll need sudo for new gemset installations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM