linux中who命令程序

不及物动词 其他 31

回复

共3条回复 我来回复
  • worktile的头像
    worktile
    Worktile官方账号
    评论

    The “who” command in Linux is a program that allows users to view information about the currently logged-in users on the system. By executing the “who” command, you can obtain details such as the username, login time, terminal (tty), and the IP address or hostname of the connected device for each user.

    To use the “who” command, open the terminal on your Linux system and simply type “who” followed by pressing the Enter key. The output will display a list of logged-in users with their respective information. Here is an example of the output:

    “`
    user1 tty1 2021-03-25 09:00 (:0)
    user2 pts/0 2021-03-25 09:15 (192.168.1.100)
    user3 pts/1 2021-03-25 09:20 (hostname.domain)
    “`

    In the example output above, there are three logged-in users. The first column represents the username, followed by the terminal or device they are logged in from. The third column displays the login time, and the last column shows the IP address or hostname of the connected device.

    The “who” command also has various options that you can use to customize the output. Some commonly used options include:

    – `-a` or `–all`: Displays all logged-in users, including system users.
    – `-b` or `–boot`: Shows the time of the last system boot.
    – `-r` or `–runlevel`: Displays the current run level of the system.
    – `-H` or `–heading`: Adds a header line to the output.
    – `-u` or `–users`: Shows the number of logged-in users.

    For example, if you want to see all logged-in users with the headers displayed, you can execute the command “who -aH”.

    The “who” command is a useful tool for system administrators to monitor user activities and manage system resources. It provides valuable information about the current state of user sessions on a Linux system.

    2年前 0条评论
  • 不及物动词的头像
    不及物动词
    这个人很懒,什么都没有留下~
    评论

    Linux中的who命令是一个系统管理工具,用于显示当前登录到系统的用户信息。该命令可用于显示用户的登录名、登录时间和登录终端等信息。

    以下是关于Linux中who命令的一些详细信息:

    1. 命令语法:who [-a] [-b] [-d] [-H] [-l] [-m] [-p] [-q] [-r] [-s] [-t] [-u] [-w] [-R] [-L] [–lookup] [–heading] [–help] [–version] [文件或终端]

    2. 常用选项:
    -a 或 –all:显示全部信息,包括系统重启时间、空闲时间和运行级别等;
    -b 或 –boot:显示系统重启时间;
    -d 或 –dead:显示当前尚未销毁的进程;
    -H 或 –heading:显示每个结果的标题行;
    -l 或 –login:显示登录名;
    -m 或 –mesg:显示用户的消息设置(接收/拒绝显示消息);
    -p 或 –process:显示当前运行的进程;
    -q 或 –count:仅显示登录用户数量;
    -r 或 –runlevel:显示当前的运行级别;
    -s 或 –short:显示简短输出;
    -t 或 –time:显示最近系统启动时间;
    -u 或 –users:显示当前登录用户的信息;
    -w 或 –ip-addr:显示登录用户的IP地址。

    3. 如果没有提供文件或终端,who命令将默认显示当前登录用户的信息。

    4. who命令主要用于跟踪和监控登录到系统中的用户,特别是在多用户环境中非常有用。可以通过查看谁登录到系统、他们的登录时间、登录终端和IP地址等信息,来监控和管理系统的访问情况。

    5. 除了who命令外,还有一些类似的命令可以用于监控用户登录信息,如w命令和users命令。这些命令提供了更多的选项和功能,可以根据需要选择使用。

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

    # Linux中who命令程序

    ## 1. 简介
    `who`命令是Linux系统中的一个基本命令,用于显示当前登录到系统的用户信息,包括用户名、终端设备、登录时间等。该命令通常与其他命令(如`tty`、`ps`等)结合使用,以获取更详细的用户信息。

    ## 2. 命令格式
    `who`命令的基本格式为:
    “`
    who [选项] [文件…]
    “`

    ## 3. 命令选项
    `who`命令支持以下选项:

    – `-a`:显示所有的登录会话,包括系统登录与非系统(例如附加的X11显示)登录的会话。
    – `-b`:显示系统启动时间。
    – `-d`:显示从系统启动到现在所经历过的时间。
    – `-H`:显示用户登录的主机信息。
    – `-l`:显示系统中的登录记录。
    – `-p`:显示程序的PID信息。
    – `-q`:只显示用户数量,不显示用户详细信息。
    – `-r`:显示运行等级。
    – `-s`:显示用户登录的会话状态。
    – `-T`:显示用户登录的终端设备信息。
    – `-u`:显示用户登录的用户名。

    ## 4. 使用示例

    ### 示例1:显示当前登录用户信息
    “`
    $ who
    “`
    该命令将显示当前登录到系统的用户信息,包括用户名、终端设备、登录时间。

    ### 示例2:显示登录用户数量
    “`
    $ who -q
    “`
    该命令将只显示当前登录用户数量,而不显示用户的详细信息。

    ### 示例3:显示登录用户及其主机信息
    “`
    $ who -H
    “`
    该命令将显示用户登录的主机信息,包括用户名、终端设备、登录时间、主机名。

    ### 示例4:显示登录用户的终端设备信息
    “`
    $ who -T
    “`
    该命令将显示用户登录的终端设备信息,包括用户名、终端设备、登录时间。

    ### 示例5:显示用户登录和注销记录
    “`
    $ who -l
    “`
    该命令将显示系统中的登录记录,包括用户名、终端设备、登录时间、注销时间。

    ### 示例6:显示系统启动时间
    “`
    $ who -b
    “`
    该命令将显示系统的启动时间。

    ## 5. 注意事项
    – `who`命令默认显示当前登录到系统的用户信息。
    – 选项`-w`现在已被弃用,不再支持。
    – `who`命令通常需要root权限才能访问某些系统文件和记录,因此需要以管理员身份运行。

    ## 6. 总结
    通过`who`命令,我们可以方便地查看当前登录到系统的用户信息。该命令可以显示用户名、终端设备、登录时间等信息,还可以显示主机信息、终端设备信息、登录和注销记录等。结合不同的选项,我们可以得到不同粒度的用户信息展示。

    > 注意:本文所述内容适用于大多数基于Linux内核的操作系统,如Ubuntu、Debian、CentOS等。不同的发行版可能会有一些细微差别,具体请根据实际情况参考相关文档或执行`man who`命令查看详细说明。

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

400-800-1024

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

分享本页
返回顶部