4-查询账号信息
2016.6.7
查询账号信息
id命令:查询用户身份标识
- id [用户名]
groups命令:查询用户所属的组
- groups [用户名]
finger命令:查询用户账号的详细信息
- finger [用户名]
w命令
- 查询已登录主机的用户信息
[root@test1 home]# id --help
Usage: id [OPTION]... [USERNAME]
Print user and group information for the specified USERNAME,
or (when USERNAME omitted) for the current user.
-a ignore, for compatibility with other versions
-Z, --context print only the security context of the current user
-g, --group print only the effective group ID
-G, --groups print all group IDs
-n, --name print a name instead of a number, for -ugG
-r, --real print the real ID instead of the effective ID, with -ugG
-u, --user print only the effective user ID
--help display this help and exit
--version output version information and exit
Without any OPTION, print some useful set of identified information.
Report id bugs to [email protected]
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'id invocation'
[root@test1 home]#
实例:
[root@test1 home]# id
uid=0(root) gid=0(root) groups=0(root)
[root@test1 home]#
[root@test1 home]# groups
root
[root@test1 home]#
实例——安装finger:
[root@test1 home]# cd /media
[root@test1 media]# ls
CentOS_6.5_Final
[root@test1 media]# cd CentOS_6.5_Final/
[root@test1 CentOS_6.5_Final]# ls
CentOS_BuildTag images repodata RPM-GPG-KEY-CentOS-Testing-6
EFI isolinux RPM-GPG-KEY-CentOS-6 TRANS.TBL
EULA Packages RPM-GPG-KEY-CentOS-Debug-6
GPL RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Security-6
[root@test1 CentOS_6.5_Final]# cd Packages/
[root@test1 Packages]# ll | grep finger
-r--r--r-- 2 root root 22000 Jul 3 2011 finger-0.17-39.el6.x86_64.rpm
-r--r--r-- 2 root root 15908 Jul 3 2011 finger-server-0.17-39.el6.x86_64.rpm
-r--r--r-- 2 root root 102252 Nov 25 2013 gdm-plugin-fingerprint-2.30.4-52.el6.x86_64.rpm
[root@test1 Packages]# rpm -ivh finger-0.17-39.el6.x86_64.rpm
warning: finger-0.17-39.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:finger ########################################### [100%]
[root@test1 Packages]#
实例——使用finger:
[root@test1 Packages]# finger a
Login: a Name:
Directory: /ftphome/a Shell: /sbin/nologin
Never logged in.
No mail.
No Plan.
[root@test1 Packages]# finger root
Login: root Name: root
Directory: /root Shell: /bin/bash
On since Mon Jun 6 16:49 (CST) on tty1 23 hours 37 minutes idle
On since Mon Jun 6 16:49 (CST) on tty7 from :0
1 day 6 hours idle
On since Mon Jun 6 16:50 (CST) on pts/1 from :0.0
18 hours 10 minutes idle
On since Mon Jun 6 20:45 (CST) on pts/3 from :0.0
19 hours 40 minutes idle
New mail received Fri Jun 3 08:20 2016 (CST)
Unread since Tue May 24 13:36 2016 (CST)
No Plan.
[root@test1 Packages]#
实例——finger不加任何对象,w不加任何对象,who不加任何对象:
[root@test1 Packages]# finger
Login Name Tty Idle Login Time Office Office Phone
jason pts/2 Jun 7 14:14 (192.168.0.1)
root root tty1 23:40 Jun 6 16:49
root root tty7 1d Jun 6 16:49 (:0)
root root pts/1 18:13 Jun 6 16:50 (:0.0)
root root pts/3 19:43 Jun 6 20:45 (:0.0)
[root@test1 Packages]# w
16:29:29 up 10:14, 5 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Mon16 23:40m 0.01s 0.01s -bash
jason pts/2 192.168.0.1 14:14 0.00s 0.78s 0.00s login -- jason
root tty7 :0 Mon16 30:34m 43.12s 43.12s /usr/bin/Xorg :0 -br -verbose -audit 4 -a
root pts/1 :0.0 Mon16 18:14m 0.15s 0.15s /bin/bash
root pts/3 :0.0 Mon20 19:43m 0.00s 0.00s /bin/bash
[root@test1 Packages]#
[root@test1 Packages]# who
root tty1 2016-06-06 16:49
jason pts/2 2016-06-07 14:14 (192.168.0.1)
root tty7 2016-06-06 16:49 (:0)
root pts/1 2016-06-06 16:50 (:0.0)
root pts/3 2016-06-06 20:45 (:0.0)
[root@test1 Packages]#