linux系统who命令

fiy 其他 64

回复

共3条回复 我来回复
  • 不及物动词的头像
    不及物动词
    这个人很懒,什么都没有留下~
    评论

    The “who” command in Linux is used to display information about currently logged in users. When you run the “who” command, it will show you the usernames, terminal devices, login times, and remote IP addresses of the logged in users. This command is helpful for system administrators to monitor user activity on the system.

    The basic syntax of the “who” command is as follows:
    “`
    who [OPTION]… [FILE]…
    “`
    Some commonly used options with the “who” command are:
    – `-b`: displays the last system boot time.
    – `-q`: shows only the count of logged in users.
    – `-u`: includes the display of the idle time for each logged in user.
    – `-H`: displays the column headers.

    By default, the “who” command reads the file “/var/run/utmp” to get the login records. However, you can specify a different file as an argument to the command if needed.

    The output of the “who” command includes several columns:
    – Username: The username of the logged in user.
    – Terminal: The terminal device or line number the user is logged in from.
    – Date and Time: The date and time when the user logged in.
    – Remote IP Address: If the user is accessing the system remotely, it will display their IP address.

    Here is an example output of the “who” command:
    “`
    username1 tty1 2021-01-01 10:00 192.168.1.100
    username2 pts/0 2021-01-01 11:00 192.168.1.101
    “`

    In summary, the “who” command in Linux is a useful tool for displaying information about currently logged in users on a system. It provides details such as usernames, terminals, login times, and remote IP addresses. Monitoring user activity can assist system administrators in managing and securing the system.

    2年前 0条评论
  • worktile的头像
    worktile
    Worktile官方账号
    评论

    在Linux系统中,`who`命令用于显示当前登录到系统的用户的信息。以下是关于`who`命令的一些重要信息:

    1. 显示登录用户信息:`who`命令会列出登录到系统的用户名、登录时间、登录终端以及登录来源(IP地址或主机名等)。

    “`
    $ who
    username1 pts/0 2021-12-01 10:30 (192.168.0.1)
    username2 pts/2 2021-12-02 13:45 (192.168.0.2)
    “`

    2. 显示详细登录信息:使用`-a`选项,`who`命令可以显示更详细的登录信息,包括用户的登录进程和最后一次活动时间。

    “`
    $ who -a
    system boot 2021-12-01 09:00
    LOGIN tty1 2021-12-01 10:30 2175 id=LOGIN
    username1 + pts/0 2021-12-01 10:30 . 2175 (192.168.0.1)
    |- bash 2224 0 2224 0 11:15 pts/0 00:00:01 -bash
    `- who 11227 0 11227 0 11:20 pts/0 00:00:00 who -a
    username2 + pts/2 2021-12-02 13:45 . 2175 (192.168.0.2)
    |- bash 2421 0 2421 0 14:05 pts/2 00:00:01 -bash
    `- who 11405 0 11405 0 14:10 pts/2 00:00:00 who -a
    “`

    3. 显示登录用户数量:使用`-q`选项,`who`命令可以只显示登录用户的数量。

    “`
    $ who -q
    username1 username2
    # 2 users
    “`

    4. 显示登录用户的时长:使用`-i`选项,`who`命令将显示每个登录用户的登录时长。

    “`
    $ who -i
    username1 pts/0 2021-12-01 10:30 (192.168.0.1) :0 00:22
    username2 pts/2 2021-12-02 13:45 (192.168.0.2) :0 00:14
    “`

    5. 显示各个登录会话的进程ID:使用`-p`选项,`who`命令将显示每个登录会话(终端)对应的进程ID。

    “`
    $ who -p
    username1 pts/0 2021-12-01 10:30 (192.168.0.1) 2175 (:0)
    username2 pts/2 2021-12-02 13:45 (192.168.0.2) 2175 (:0)
    “`

    这些是`who`命令的一些常用选项和用法。通过了解这些信息,您可以更好地管理和监视Linux系统上的登录用户。

    2年前 0条评论
  • fiy的头像
    fiy
    Worktile&PingCode市场小伙伴
    评论

    Linux系统中的`who`命令可以用于显示当前登录系统的用户信息。它是一个简单而实用的命令,可提供有关用户登录信息的详细信息,如用户名、终端、登录时间、IP地址等。

    以下是`who`命令的用法和操作流程:

    ## 语法

    `who`命令的基本语法如下:

    “`
    who [OPTION] [FILE]
    “`

    ## 参数选项

    `who`命令支持以下参数选项:

    – `-b`:显示系统启动时间。
    – `-d`:显示依赖于系统的每天记录。
    – `-H`:打印标题行。
    – `-l`:显示登录系统的用户名和终端。
    – `-p`:显示当前登录用户的进程ID。
    – `-r`:显示当前运行等级。
    – `-s`:显示当前系统的状态。
    – `-t`:显示当前系统的运行时间。
    – `-u`:显示当前登录用户的详细信息。
    – `-w`:显示当前登录系统的用户,终端和时间的详细信息。

    ## 示例

    ### 显示当前登录用户信息

    “`
    who
    “`

    该命令将显示当前登录系统的用户信息,包括用户名、终端、登录时间等。

    ### 显示当前登录用户的详细信息

    “`
    who -u
    “`

    该命令将显示当前登录用户的详细信息,包括用户、终端、登录时间、活动时间、进程ID、IP地址等。

    ### 显示系统状态

    “`
    who -s
    “`

    该命令将显示当前系统的状态,包括运行等级、系统开机时间、系统负载等。

    ### 显示当前登录用户的进程ID

    “`
    who -p
    “`

    该命令将显示当前登录用户的进程ID,用于跟踪用户运行的进程。

    ### 显示当前登录系统的用户、终端和时间的详细信息

    “`
    who -w
    “`

    该命令将显示当前登录系统的用户、终端和时间的详细信息,包括用户、终端、登录时间、活动时间等。

    ## 总结

    `who`命令是Linux系统中一个非常有用的命令,可以列出当前登录系统的用户信息。通过使用不同的参数选项,我们可以获取不同层面的用户信息,如登录用户基本信息、详细信息、进程ID等。此外,`who`命令还可以显示系统的运行状态和开机时间,方便用户了解系统的运行情况。

    2年前 0条评论
注册PingCode 在线客服
站长微信
站长微信
电话联系

400-800-1024

工作日9:30-21:00在线

分享本页
返回顶部