If you are looking for ways to check user activity log in Linux, you can use the who command to see the list of users who are currently logged in Linux Ubuntu.
How To Check User Activity Log In Linux
There are various commands to get the list of users who are currently logged in Linux system. Some of the most popular commands to see the list of logged in users are:
- who
- w
- users
1. who command
The who command prints information about users who are currently logged on. When you run the command without any argument, ‘who’ prints the following information for each user currently logged on (see screenshot below):
- login name
- terminal line
- login time
- remote hostname or X display
If given two non-option arguments, the ‘who’ command prints only the entry for the user running it which is preceded by the hostname.
The most command argument for the who command is ‘am i’, as in ‘who am i’.
If you want to print only the login names and the number of users logged on you can use the ‘-q’ or ‘–count’ argument with the who command. It will override all other options.
2. W command
The w command is used to show who is logged on and what they are doing. The w command displays information about the users currently on the machine, and their processes.
It must be noted that the information displayed – header shows – in this order:
- the current time
- how long the system has been running
- how many users are currently logged on
- the system load averages for the past 1, 5, and 15 minutes.
For each user the following entries are displayed:
- login name
- the tty name
- the remote host
- login time
- idle time,
- JCPU, PCPU
- the command line of their current process
If you don’t want to print the login time, JCPU or PCPU times, run the W command with -s or –short argument. This is used to display the information in the short format. Don’t print the login time, JCPU or PCPU times.
3. users command
The users command is used to print login names of users currently logged in. When you execute the command the ‘users’ prints on a single line a blank-separated list of user names of users currently logged in to the current host.
Note that each user name corresponds to a login session, so if a user has more than one login session, that user’s name will appear the same number of times in the output.
I hope this quick tutorial will be useful for you in finding the users currently logged on.