Open In App
Related Articles

How to Monitor Linux Commands Executed by System Users in Real-time?

Improve Article
Improve
Save Article
Save
Like Article
Like

If you are a Linux system administrator then you would definitely want to monitor the interactive activity of all system users, like monitoring the Linux commands they execute in real-time. In this brief Linux system security article, we will be going to discuss how to monitor all Linux shell commands executed by system users in real-time.

Let’s see how to Monitor Linux Commands Executed by System Users in Real-time:

If your current shell is Bash Shell then all the commands that are executed by normal system users will be stored in the .bash_history hidden file which is found in each user’s home directory. The content of that file can be viewed by users, using the history command.

So if we want to view a user’s (suppose tithi user ).bash_history file we have to type the following command in the terminal:-

cat /home/tithi/.bash_history 

Example:

How to Monitor Linux Commands Executed by System Users in Real-time

All the commands list

And if your current shell is Zsh shell use the following command:-

cat /home/tithi/.zsh_history 

How to Monitor Linux Commands Executed by System Users in Real-time

Note: use exec zsh to switch from bash shell to zsh  and exec bash for vice-versa 

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 05 Mar, 2021
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials