To list the current logged-in users on a Unix or Linux system, you can use the who
command.
Here is the basic syntax for using the who
command:
who
The who
command does not take any arguments. When you run the who
command, it will display a list of users who are currently logged in to the system, along with their login names, terminal names, and the date and time they logged in.
For example, the output of the who
command might look something like this:
user1 tty1 2021-01-01 12:34 user2 pts/0 2021-01-01 13:56 user3 pts/1 2021-01-01 14:23
The who
command only displays information about users who are logged in to the system using a terminal or a pseudo-terminal (pts). It does not display information about users who are logged in remotely using SSH or other remote access tools.
To list all users who are logged in to the system, including those logged in remotely, you can use the w
command.
For example:
w
This will display a list of all users who are logged in to the system, along with their login names, terminal names, the hostname of the system they are logged in from, and the date and time they logged in.