In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This post is about how linux can view currently logged in users. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
Linux is a free-to-use and freely distributed UNIX-like operating system, is a POSIX-based multi-user, multitasking, multi-threaded and multi-CPU operating system, using Linux to run major Unix tools, applications and network protocols.
View method: 1. Use the "w" command to display the user information currently logged in to the system;2. Use the "who" command to display the user information currently logged in, output the user name, login terminal and login time;3. Use the "last" command;4. Use the "lastlog" command;5. Use the "ac" command.
This tutorial will operate on Red Hat Enterprise Linux 6.1, Dell G3 computers.
1,w
w, displays the user information currently logged into the system
-f Turns on or off to show where users log in to the system.
-h Do not display header information columns for each field.
-l Use the detailed format list, which is the default.
-s uses a concise list format that does not show user login time, CPU time spent on terminal phase jobs, and programs.
-u Ignore the name of the program being executed and information about how much CPU time the program consumes.
-V Displays version information.
[root@card-web03 ~]# w 17:28:45 up 84 days, 23:32, 1 user, load average: 0.01, 0.03, 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATroot pts/1 123.115.76.110 17:06 5.00s 0.03s 0.00s w
Meaning of output result:
USER User name of login
TTY login terminal
From which IP address do you log in?
LOGIN@ Login time
IDLE User Idle Time
JCPU refers to the time taken by all processes connected to the terminal, excluding the background in the past.
Job time, but includes time taken by background jobs currently running
PCPU Time taken by current process
WHATCommand currently running
2.who
Display information about currently logged in users
The output results are: user name, login terminal, login time
[root@card-web03 ~]# whoroot pts/1 2019-03-12 17:06 (12.3.1.15) #Output results include: user name, login terminal, login time
3. last
Lists information about current and past users who logged into the system.
- R: Omit hostname field
-n: Specifies the number of output records.
-f file: Specify file as log file for query.
-t tty: Displays logins only on specified virtual consoles.
-h Node: Displays only logins on specified nodes.
-i IP: Displays only logins on the specified IP.
-1: Use IP to display remote addresses.
-y: Displays the year, month, and day of the record.
ID: User name that knows the query.
-x: Displays the history of system shutdowns, user logins, and logouts.
[root@card-web03 ~]# lastroot pts/1 12.3.11.5 Tue Mar 12 17:06 still logged in root pts/1 12.3.11.5 Tue Mar 12 16:03 - 16:06 (00:02) root pts/2 12.3.11.5 Tue Mar 12 15:46 - 15:46 (00:00) root pts/2 12.3.11.5 Tue Mar 12 15:44 - 15:44 (00:00) root pts/3 12.3.11.5 Tue Mar 12 15:42 - 15:42 (00:00) root pts/2 12.3.11.5 Tue Mar 12 15:41 - 15:42 (00:01) #The output of the command contains: username, login terminal, login IP, login time, exit time (online time)
4.lastlog
The lastlog command checks when a particular user last logged in
-b, --before DAYS Print only recent logins older than DAYS
-h, --help Display this help message and launch
-R, --root CHROOT_DIR chroot to directory
-t, --time DAYS prints only recent logins older than DAYS
-u, --user LOGIN Print LOGIN user's recent logins
Note: The lastlog command reads the data from/var/log/wtmp by default. Be sure to note that this file cannot be viewed with vi.
Command output includes: username, login terminal, login IP, last login time
5. ac
The default output reports the total time (in hours) the user is connected based on the login and exit times in the/var/log/wtmp file
(1)-p: Display connection time for each user
(2)-d: Display daily connection time
(3)-y: Display year, used with-d
Thank you for reading! About "linux how to view the current login user" this article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.