首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Linux 下查看系统当前登录用户信息

Linux 下查看系统当前登录用户信息

作者头像
西湖醋鱼
发布2020-12-30 17:06:36
发布2020-12-30 17:06:36
7.9K00
代码可运行
举报
运行总次数:0
代码可运行

当你新登录一个主机,过着管理一个主机,这时候你就需要这些命令来进行查看了:

1. w : Show who is logged on and what they are doing.

    w [options] user [...]

常用命令:

    w -h --no-header

    w -u --no-current

    w -s :   Use the short format.  Don't print the login time, JCPU or PCPU times.

    w -i, --ip-addr : Display IP address instead of hostname for from field.

2. who : Show who is logged on

   who -a, --all 展示所有的; 相当于 使用 -b -d --login -p -r -t -T -u

3. users: Print the user names of users currently logged in to the current host

4. whoami : Print effective userid

    Print the user name associated with the current effective user ID.  Same as id -un.

5. last : last, lastb - show a listing of last logged in users

    last -a 

    last [options] [username...] [tty...]

代码语言:javascript
代码运行次数:0
运行
复制
last  searches  back  through the /var/log/wtmp file (or the file designated by the -f option) and displays a list of all users logged in
       (and out) since that file was created.  One or more usernames and/or ttys can be given, in which case last will  show  only  the  entries
       matching those arguments.  Names of ttys can be abbreviated, thus last 0 is the same as last tty0.

       When  catching  a  SIGINT  signal  (generated by the interrupt key, usually control-C) or a SIGQUIT signal, last will show how far it has
       searched through the file; in the case of the SIGINT signal last will then terminate.

       The pseudo user reboot logs in each time the system is rebooted.  Thus last reboot will show a log of all the reboots since the log  file
       was created.

       lastb is the same as last, except that by default it shows a log of the /var/log/btmp file, which contains all the bad login attempts.

 last reboot 展示所有的机器重新启动的情况。

6. lastb:lastb is the same as last, except that by default it shows a log of the /var/log/btmp file, which contains all the bad login attempts.

    在root 权限下,使用 lastb 命令,将会显示所有尝试登录失败的情况。

保持更新,转载请注明出处。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-08-09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档