Write a pipeline of commands, which displays on the monitor as well as saves the information about the number of users using the system at present
w command
Shows information about the users currently on the machine, and their processes.w command in Linux is used to show who is logged on and what they are doing. This command shows the information about the users currently on the machine and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
Syntax:w [options] user [...]
Options |
Description |
w -h |
This option don’t print the header. |
w -u |
This option will ignore the username while figuring out the current process and cpu times. |
w -s |
This option uses the short format. It will not print the login time, JCPU or PCPU times. |
w -f |
This option will toggle printing the from (remote hostname) field. The default as released is from field which not be printed. Although your system administrator or your distribution maintainer may have compiled a version in which the from field is shown by default. |
w -help |
This option will display help message and exit. |
w -i |
This option will display IP address instead of hostname for from field. |
w -V |
This option will display version information. |
w -o |
This option will print blank space for idle times less than one minute. |
w user |
This option will show information about the specified user only.
|
Example
who command
who command is used to find out the following information :
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
The who command is used to get information about currently logged in user on to system.
Syntax : who [options] [filename]
Options |
Description |
who |
The who command displays the following information for each user currently logged in to the system if no option is provided :
- Login name of the users
- Terminal line numbers
- Login time of the users in to system
- Remote host name of the user
|
who -m -H |
To display host name and user associated with standard input such as keyboard |
who -p -H |
To show all active processes which are spawned by INIT process |
who -T -H |
To show status of the users message as +, – or ? |
who -u |
To show list of users logged in to system |
who -b -H |
To show time of the system when it booted last time |
who -d -H |
To show details of all dead processes |
who -l -H |
To show system login process details |
who -q -H |
To count number of users logged on to system |
who -r |
To display current run level of the system |
who -a |
To display all details of current logged in user |
whoami |
To display system’s username |
w |
To display list of users and their activities |
id |
To display user identification information |
Example
For more RGPV/UTMP CSE-V Sem Linux LAB Experiments Click Here