Linux system: View the current logged in user information, this article describes 3 ways

Source: Internet
Author: User
Tags time and date

As a system administrator, you can often (at some point) need to see which users in your system are active. Sometimes you even need to know what they are doing. This article summarizes 4 ways to view system user information (by number (ID)).

1. Use the W command to view the process information that the logged on user is using

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

    • User name
    • User's machine name or TTY number
    • Remote Host Address
    • Time the user logged on to the system
    • Idle time (little effect)
    • The time taken to attach to the TTY (terminal) process (jcpu time)
    • Time spent by current process (pcpu time)
    • Commands that the user is currently using

The W command can also use the following options

    • -H Ignores header file information
    • -U Displays the load time of the result
    • -S does not show JCPU, PCPU, logon Hours
W 23:04:27 up  (7:51),  3 users,  load average:0.04, 0.06, 0.02USER TTY from              [ Email protected]   IDLE   jcpu   PCPU whatramesh   pts/0    dev-db-server        22:57    8.00s  0.05s  0.01s sshd:ramesh [Priv]jason    pts/1    dev-db-server        23:01    2:53   0.01s  0.01s-bashjohn     pts/2    dev-db-server        23:04    0.00s  0.00s  0.00s W

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

The WHO command is used to enumerate the user names of the currently logged on system. The output is: User name, TTY number, time date, host address.

who ramesh pts/0        2009-03-28 22:57 (dev-db-server) Jason  pts/1        2009-03-28 23:01 ( Dev-db-server) John   pts/2        2009-03-28 23:04 (dev-db-server)
If you only want to list users, you can use the following statement:
Who | cut-d '-f1 | sort | uniqJohnjasonramesh
Supplemental : The Users command, which can be used to print out the user name of the logon server. This command has no options other than the Help and version options. If a user uses more than one terminal, multiple duplicate user names are displayed accordingly.
usersJohn Jason Ramesh

4. Always view the system's historical information (user information that was used by the system)

The last command can be used to display the history of a particular user's login system. If no parameters are specified, the history information for all users is displayed. By default, this information (the information displayed) is derived from the/var/log/wtmp file. The output of this command contains the following columns of information:

    • User name
    • TTY Device number
    • History Login Time Date
    • Log out time and date
    • Total working hours
Last JasonJason   pts/0        dev-db-server   Fri Mar 22:57   still logged Injason   pts/0        Dev-db-server   Fri Mar 22:09-22:54  (00:45) Jason   pts/0        dev-db-server   Wed Mar 25 19:58-22:26< c12/> (02:28) Jason   pts/1        dev-db-server   Mon Mar 20:10-21:44  (01:33) Jason   pts/0        192.168.201.11  Fri Mar 08:35-16:46  (08:11) Jason   pts/1        192.168.201.12  Thu Mar 12 09:03-09 :  (00:15) Jason   pts/0        dev-db-server   Wed Mar 20:11-20:50  (00:39

Linux system: View the current logged in user information, this article describes 3 ways

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.