How to delete or lock any terminal command?

like "date" for changing data through mac terminal?


there is a way to change system time through terminal like "sudo date mmddhhmmyy"

or any other command like "ls"

so my question is can we lock the commands so that even the admin cant run them through sudo. In other words no one can run "date" in my terminal

  • 1
    Could you provide a clear example of what you are trying to accomplish here? – ephsmith Nov 18 '17 at 4:20
  • In my opinion this is a XY-problem. Either log-in as standard user or enable parental control or disable the shell (> /bin/false - which may break some things) or lock your Mac (ask for password immediately to unlock screensaver/wake from sleep) or [some more options] ... – klanomath Nov 19 '17 at 18:53

As long as an admin user can use sudo you can't stop them from circumventing any locks etc. as long as the command itself is still in the system. Even deleting the executable will not help as it can easily copied from another system, or compiled from source (deleting something from bin and sbin will break system scripts anyway, so this is really not a valuable approach).

If you are worried about admin users changing the system date you might be better of in restricting the number of admin users, or modifying sudoers to grant access to specific commands only. How you do this depends on your specific needs so it's difficult to recommend any specific solution right now. This page might be a good place to start reading though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .