How to block command, let say mkdir for specific user ?
What I did just created read-only function and store in users profile ~/.bashrc
/bin/mkdir() {
echo "mkdir command not allow for you"
}
mkdir() {
echo "mkdir command not allow for you"
}
./mkdir() {
echo "mkdir command not allow for you"
}
readonly -f /bin/mkdir
readonly -f mkdir
readonly -f ./mkdir
Test:
rahul@ubuntu:~$ cd /bin/
rahul@ubuntu:/bin$ ./mkdir /home/rahul/ggg
mkdir command not allow for you
rahul@ubuntu:/bin$ cd
rahul@ubuntu:~$ mkdir testing
mkdir command not allow for you
rahul@ubuntu:~$ /bin/mkdir testing
mkdir command not allow for you
So my question is What should be the way of achieving this ? is there any tool for this ?
Update 1 # But if user is smart , he could copy mkdir binary and rename it and use it . So how to achieve this ?