- Basic Linux tutorials for beginner
- Linux basic concepts, installation and troubleshooting
- Linux administration
- Linux commands
- Linux network tutorials
- Linux security tutorials
- Linux software configuration
- Linux desktop tutorials for beginner
- Collection of Linux tips
Linux who command tutorial
Submitted by jinlusuh on Mon, 07/06/2009 - 07:09
Linux who command shows who is logged on to the system. This is a useful command for a Linux system administrator because they can check how many users currently logged in the system and who they are. The Linux who command offers some options that user can use to see more details about users such as login time, terminal used and process id. However that is not the only things the who command can do. We can also use Linux who command to check when was the Linux system last booted and the current system's run level.
Linux who command examples
We already know what Linux who command can do, now it's time to see some examples. Below are the Linux who command examples run with options regularly used by system administrator.
Probably the well known Linux who command's option is the am i. When invoke who am i from a Linux command line terminal (and unix as well), the who command prints only the information about user who runs the command.
When we run who with no option in Linux command line terminal, we'll get the result similar to the example below:
The example above shows two users logged in the Linux system. We can see current users in the system's username are root who logged in tty1 and luzar who's using terminal 7 (tty7), which we know it's the x-window system. The other terminal is pts/0 also by a user named luzar, which means he opened a terminal from x-window. We also see the complete date and time they logged into the Linux system in tty1, tty7 and even when they opened a command line terminal from x-window. So, when we invoke Linux who command without any option, it prints login name, terminal line, login time, and remote hostname or X display information.
Linux who -l command example:
Linux who command print system login processes. Don't get confuse with this option. When running who -l, 'who' list only the entries that correspond to processes via which the system is waiting for a user to login. The user name is always LOGIN.
Linux who -m command example:
The Linux who -m command prints only hostname and user associated with stdin. It the same as running who am i command.
Linux who -q command example:
The Linux who -q command prints all login names and the number of users logged on. Using -q option will overrides all other options.
Linux who -r command example:
The Linux who -r command prints system's current runlevel.
Linux who -T command example:
After each login name, Linux who -T command prints a character indicating the user's message status, which:
- + means allowing `write' messages.
- - means disallowing `write' messages.
- ? means cannot find terminal device.
Linux who -u command example:
The Linux who -u command lists users logged in. After the login time, the who command prints the number of hours and minutes that the user has been idle.
- . means the user was active in the last minute.
- old means the user has been idle for more than 24 hours.
Linux who -b command example:
The Linux who -b command prints the date and time of last system boot.
Linux who -a command example:
The Linux who -a command is the same as invoke who -b -d --login -p -r -t -T -u.
Back to Linux basic commands main page.