I want to restrict the user to view the command line history of bash. I'm able to do this through the steps mentioned in this StackOverflow question.

Now, as an admin, I need to know the list of commands/scripts a user executed. Is there any way I can achieve this task?


1 Answer 1


You will have to re-enable the history file, undoing what you did in the other article, then it will start logging again, you won't be able to "get back" ones that weren't saved.

By default permission users can only view their own history, but as root you could read them all.

If you want to ban a user from viewing their own history you could change the permission of the /home/username/.bash_history file, but I am not sure why you would want this,.

  • I bet rahuls36 he has a system with shared accounts. One user account, several people with the shared password.
    – Stewart
    Oct 4, 2019 at 10:44
  • yes, we have shared accounts. I thought of using lshell for this. Interesting part is lshell is unable to limit history command.
    – rahuls36
    Oct 7, 2019 at 5:54

You must log in to answer this question.

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