Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to see how many users are logged in by linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how to check how many users log in in linux". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to check how many users log in in linux" can help you solve your doubts.

View method: 1, using the w command, the command is used to display the current login system user information, the syntax is "w [- fhlsuV] [user name]"; 2, using the who command, the command is used to show which users are on the system, the syntax is "who [parameter]".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How does linux see how many users are logged in?

1. Use the w command to view the process information that the logged-in user is using

The Linux w command is used to display user information that is currently logged into the system.

Execute this instruction to know who are currently logged in to the system and the programs they are executing.

Executing the w instruction alone displays all users, or you can specify a user name to display only information about a user.

Grammar

W [- fhlsuV] [user name]

Parameter description:

-f turns on or off showing where the user logs in to the system.

-h does not display the title information column of each field.

-l uses a detailed format list, which is the default value.

-s uses a concise format list and does not show the login time of the user, the CPU time spent by the terminal phase jobs and programs.

-u ignores the name of the executing program and the information that the program takes CPU time.

-V displays version information.

The w command is used to display the names of users who have logged in to the system and what they are doing. The information used by this command comes from the / var/run/utmp file. The information output from the w command includes:

User name

User's machine name or tty number

Remote host address

Time for the user to log in to the system

Idle time (not very useful)

Time taken by the process attached to the tty (terminal) (JCPU time)

Time spent by the current process (PCPU time)

The command that the user is currently using

Examples are as follows:

# w / / displays the login information of the current user and the command executed 19:50:14 up 9:27, 4 users, load average: 0.31,0.26 0.18USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot tty7: 0 Thu12 310.18USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot tty7 39m 10:10 0.60s gnome-sessionroot pts/0: .0.0 17:09 2V 18m 15.26s 0.15s bashroot pts/1 192.168.1.17 18:51 1.00s 1.24s 0.14s-bashroot pts/2 192.168.1.17 19:48 60.00s 0.05s 0.05s-bash

2. Use the who command to view (log in) the user name and the process started

The who command is used to enumerate the user names that are currently logged into the system. The output is: user name, tty number, time and date, host address.

The who command in Linux is used to show which users are on the system. The data displayed include the user ID, the terminal used, which side is connected, the online time, the sluggish time, the CPU usage, the action, and so on.

Syntax:

Who [parameters]

You can know which users are currently logged in to the system, and executing the who command alone will list the login account, the terminal used, the login time, and where you are logged in or which X monitor you are using.

Parameters:

-H or-- heading displays the header information column of each field.

-I or-u or-- idle shows idle time, and if the user takes any action within the previous minute, it will be marked "." If the user has not taken any action for more than 24 hours, the string "old" is marked.

-m this parameter has the same effect as the specified "am I" string.

-Q or-- count displays only the account name and total number of people logged in to the system.

-s this parameter will be ignored and will not be processed, and will only be responsible for solving the compatibility problem of other versions of the who directive.

-w or-T or-- mesg or-- message or-- writable displays the user's information status bar.

-l lists any login processes.

-T or-w displays the user's information status bar.

An example is as follows: show the user who is currently logged in to the system

[root@localhost ~] # whoroot tty2 2021-05-20 09:20 (tty2) read here, this "linux how to check how many users have logged in" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report