ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linux Óû§£¨User£©²éѯƪ

·¢²¼Ê±¼ä:2006-01-06 09:01:44À´Ô´:ºìÁª×÷Õß:linux
Ò»¡¢Óû§²éѯ¹¤¾ßµÄÔ­Àí£»

ÔÚÓû§¹ÜÀíÖУ¬Óû§²éѯÊÇͨ¹ý¼¸¸ö³£ÓõŤ¾ßÀ´Íê³ÉµÄ£¬±ÈÈçid ¡¢finger¡¢groups¡¢users ... ... £¬ÎÒÃǶ¼ÖªµÀÓû§µÄÅäÖÃÎļþÊÇ/etc/passwd£¬Óû§×éµÄÅäÖÃÎļþÊÇ/etc/groups Îļþ£¬ÎÒÃǶÔÓû§µÄ²éѯ³ýÁËͨ¹ý²éѯ¹¤¾ßÒÔÍ⣬ÎÒÃÇ»¹ÄÜÖ±½Ó²é¿´Óû§ºÍÓû§×éµÄÅäÖÃÎļþÀ´´ïµ½²éѯµÄÄ¿µÄ£»

Óû§²éѯ¹¤¾ßµÄÔ­ÀíÒ²ÊǶÁÈ¡ÓëÓû§ºÍÓû§×éÓйصÄÅäÖÃÎļþ£¬È»ºó°´Ò»¶¨µÄ¹æÔòºÍÌõ¼þÊä³ö£¬Óû§ºÍÓû§×éÅäÖÃÎļþºÜÖØÒª£¬ËùÒÔÄúÓбØÒªÏȶÁһϹØÓÐÓû§¹ÜÀíµÄÎĵµ

¶þ¡¢Óû§£¨User£©ºÍÓû§×飨Group£©²éѯ¹¤¾ß£»

1¡¢id ¹¤¾ß: ²éѯÓû§Ëù¶ÔÓ¦µÄUID ºÍGID ¼°GIDËù¶ÔÓ¦µÄÓû§×飻

id ¹¤¾ßÊÇÓÃÀ´²éѯÓû§ÐÅÏ¢£¬±ÈÈçÓû§Ëù¹éÊôµÄÓû§×飬UID ºÍGIDµÈ£»id Ó÷¨¼«Îª¼òµ¥£»ÎÒÃǾٸöÀý×Ó˵Ã÷һϣ»

Óï·¨¸ñʽ£º id [²ÎÊý] [Óû§Ãû]

ÖÁÓÚÓÐÄÄЩ²ÎÊý£¬×Ô¼º²éһϠid --help »òman id £»Èç¹ûidºóÃæ²»½ÓÈκβÎÊýºÍÈκÎÓû§£¬Ä¬ÈÏÏÔʾµ±Ç°²Ù×÷Óû§µÄÓû§Ãû¡¢Ëù¹éÊôµÄÓû§×é¡¢UIDºÍGIDµÈ£»

ʵÀýÒ»£º²»¼ÓÈκβÎÊýºÍÓû§Ãû£»

[beinan@localhost ~]$ id
uid=500(beinan) gid=500(beinan) groups=500(beinan)

×¢½â£ºÔÚûÓмÓÈκβÎÊýµÄÇé¿öÏ£¬²éѯµÄÊǵ±Ç°²Ù×÷Óû§µÄÓû§Ãû¡¢UID ¡¢GID ºÍËù´¦µÄÖ÷Óû§×éºÍ¸½ÊôÓû§×飻ÔÚ±¾ÀýÖУ¬Óû§ÃûÊÇbeinan£¬UIDÊÇ500,Ëù¹éÊôµÄÖ÷Óû§×éÊÇbeinan£¬GIDÊÇ500 £»

ʵÀý¶þ£º id ºóÃæ½ÓÓû§Ãû£»

Èç¹ûÎÒÃÇÏë²éѯϵͳÖÐÓû§µÄUIDºÍGID ÏàÓ¦µÄÄÚÈÝ£¬¿ÉÒÔÖ±½Ó½ÓÓû§Ãû£¬µ«Óû§Ãû±ØÐëÊÇÕæʵµÄ £¬ÄÜÔÚ/etc/passwdÖв鵽µÄ£»

[beinan@localhost ~]$ id linuxsir
uid=505(linuxsir) gid=502(linuxsir) groups=502(linuxsir),0(root),500(beinan)

×¢½â£º²éѯÓû§linuxsir µÄÐÅÏ¢£¬Óû§linuxsir £¬UID Ϊ505£¬Ëù¹éÊôµÄÖ÷Óû§×éÊÇlinuxsir£¬Ö÷Óû§×éµÄGIDÊÇ502£»Í¬Ê±linuxsirÓû§Ò²ÊÇGIDΪ0µÄrootÓû§×é³ÉÔ±£¬Ò²ÊÇGIDΪ500Óû§×ébeinanµÄ³ÉÔ±£»

Õâ¸öÀý×ÓºÍʵÀýÒ»ÔÚÓû§×é·½ÃæÓÐËù²»Í¬£¬ÎÒÃÇÔÚ ¡¶Linux Óû§£¨user£©ºÍÓû§×飨group£©¹ÜÀí¸ÅÊö¡· ÖÐÓÐÌáµ½£»Óû§ºÍÓû§×éµÄ¶ÔÓ¦¹Øϵ£¬¿ÉÒÔÊÇÒ»¶ÔÒ»¡¢Ò»¶Ô¶à¡¢¶à¶ÔÒ»¡¢»ò¶à¶Ô¶àµÄ½»²æ¹Øϵ£¬Çë²Î¿¼Ö®£»ÁíÍâÄú»¹ÐèÒªÕÆÎÕ¡¶Óû§£¨user£©ºÍÓû§×飨group£©ÅäÖÃÎļþÏê½â¡·Ò»ÎÄ£»

2¡¢finger ¹¤¾ß£ºÓÃÀ´²éѯÓû§ÐÅÏ¢£¬²àÖØÓû§¼ÒĿ¼¡¢µÇ¼SHELLµÈ£»

finger ¹¤¾ß²àÖØÓÚÓû§ÐÅÏ¢µÄ²éѯ£»²éѯµÄÄÚÈÝ°üÀ¨Óû§Ãû£¨Ò²±»³ÆΪµÇ¼ÃûLogin£©£¬¼ÒĿ¼£¬Óû§ÕæʵµÄÃû×Ö£¨Name£©... ... °ì¹«µØÖ·¡¢°ì¹«µç»°£»Ò²°üÀ¨µÇ¼Öնˡ¢Ð´×´Ì¬¡¢¿Õ±Õʱ¼äµÈ£»

ÎÒÃÇ×î³£ÓÃfinger À´²éѯÓû§¼ÒĿ¼¡¢Óû§ÕæʵÃû¡¢ËùÓÃSHELL ÀàÐÍ¡¢ÒÔ¼°°ì¹«µØÖ·ºÍµç»°£¬ÕâÊÇÒÔ²ÎÊý -l ³¤¸ñʽÊä³öµÄ£»¶øÐÞ¸ÄÓû§µÄ¼ÒĿ¼¡¢ÕæʵÃû×Ö¡¢°ì¹«µØÖ·¼°°ì¹«µç»°£¬ÎÒÃÇÒ»°ãÒªÄܹýchfnÃüÁî½øÐУ»

Óï·¨¸ñʽ£º

finger [²ÎÊýÑ¡Ïî] [Óû§Ãû£Ý

-l ²ÉÓó¤¸ñʽ£¨Ä¬ÈÏ£©£¬ÏÔʾÓÉ-sÑ¡ÏîËù°üº¬µÄËùÓÐÐÅÏ¢£¬ÒÔ¼°Ö÷Ŀ¼¡¢°ì¹«µØÖ·¡¢°ì¹«µç»°¡¢µÇ¼SHELL¡¢Óʼþ״̬¡¢.plan¡¢.projectºÍ.forward£»
-m ½ûÖ¹¶ÔÓû§ÕæʵÃû×Ö½øÐÐÆ¥Å䣻
-p °Ñ.planºÍ.projectÎļþÖеÄÄÚÈÝÊ¡ÂÔ£»
-s ÏÔʾ¶Ì¸ñʽ£¬Óû§Ãû£¨Ò²±»³ÆΪµÇ¼ÃûLogin£©¡¢ÕæʵÃû×Ö£¨NAME£©¡¢ÔÚÄĸöÖն˵Ǽ£¨Tty£©¡¢Ð´×´Ì¬¡¢¿ÕÏÐʱ¼ä£¨Idle£©¡¢µÇ¼ʱ¼ä£¨Login Time£©¡¢°ì¹«µØµã¡¢°ì¹«µç»°µÈ£»

ÖÁÓÚfinger ÓÐÄÄЩ²ÎÊý£¬Äú¿ÉÒÔͨ¹ý finger --help »òman finger À´»ñÈ¡£¬ÎÒÃÇÔÚ±¾ÎÄÖÐÒÔʵÀý½²Êö×î³£ÓõIJÎÊý£»

ʵÀýÒ»£º²»½ÓÈκβÎÊý£¬Ò²²»Ö¸¶¨²éѯÓû§Ãû£»Ä¬ÈÏΪ¼ÓÁË-s²ÎÊý£»

[beinan@localhost ~]$ finger
Login Name Tty Idle Login Time Office Office Phone
beinan beinan sun tty1 1:39 Nov 2 08:27
linuxsir linuxsir open tty2 2 Nov 2 10:03 linuxsir o +1-389-866-771

µÈ¼ÛÃüÁî

[beinan@localhost ~]$ finger -s

×¢½â£º²»¼ÓÈκβÎÊý£¬Ò²Ã»ÓÐÖ¸¶¨²éѯÄĸöÓû§£¬finger »áÒÔĬÈÏÒԶ̸ñ-s À´Êä³öµÇ¼±¾»úµÄËùÓÐÓû§µÄÓû§Ãû£¨Ò²±»³ÆΪµÇ¼ÃûLogin£©¡¢ÕæʵÃû×Ö£¨NAME£©¡¢ÔÚÄĸöÖն˵Ǽ£¨Tty£©¡¢Ð´×´Ì¬¡¢¿ÕÏÐʱ¼ä£¨Idle£©¡¢µÇ¼ʱ¼ä£¨Login Time£©¡¢°ì¹«µØµã¡¢°ì¹«µç»°µÈ£»

ÔÚÕâ¸öÀý×ÓÖУ¬ÓÐbeinanÓû§µÇ¼£¬ÕæʵÃû×ÖÊÇbeinan sun £¨Õâ¸öÃû×ÖÊÇÓû§µÄÕæʵÃû×Ö£¬Èç¹ûÔÚÌí¼ÓÓû§Ê±Ã»ÓÐÉèÖã¬ÊDz»»áÏÔʾµÄ£©£¬ÔÚtty1Öն˵Ǽ£¬¿Õ±Õʱ¼äÊÇ1·Ö39Ã룬µÇ¼ʱ¼äÊÇNov /2/08:27 £¬Ã»Óа칫ÊÒÃû³Æ£¬Ã»Óа칫µç»°£»

Çë¶ÔÕÕ±¾ÀýÖÐbeinanÓû§¼Ç¼µÄ½â˵£¬ÎÒÃÇÀ´¿´¿´±¾ÀýÖÐµÄ linuxsirÓû§ÐÅÏ¢£»Ó¦¸Ã²»ÄÑ¡£

¹ØÓÚд״̬£¬Èç¹ûÔÚTty ºóÃæ ûÓÐÈκÎÊä³ö£¬±íʾÕýÔÚдÈ룬Èç¹ûÓÐ*³öÏÖ£¬±íʾûÓÐдÈë»ò±»½ûÖ¹£¬±ÈÈçÏÂÃæµÄÀý×Ó£¬ftpÓû§Ã»ÓÐͨ¹ýÖն˵Ǽϵͳ£¬ÒòΪTtyÊÇ*£¬Í¬Ê±TtyºóÃ滹ÓÐÒ»¸ö* £¬±íʾ½ûֹдÈë»òûÓÐдÈë״̬(µ±Óû§Ã»ÓеǼʱ£©£»

[beinan@localhost ~]$ finger -s ftp
Login Name Tty Idle Login Time Office Office Phone
ftp FTP User * * No logins

ÎÒÃÇ¿ÉÒÔÒԶ̸ñʽµÄÀ´²éѯij¸öÓû§ÐÅÏ¢ÒԶ̸ñʽÊä³ö£¬±ÈÈçÏÂÃæµÄÀý×Ó£»

[beinan@localhost ~]$ finger -s beinan

ʵÀý¶þ£º¹ØÓÚ³¤¸ñʽµÄÓû§ÐÅÏ¢µÄÊä³ö -l ²ÎÊýµÄʵÀý£»

finger -l Èç¹û²»¼ÓÓû§ÃûµÄÇé¿öÏ£¬¿ÉÒÔÁгöËùÓÐͨ¹ýttyµÇ¼µÄÓû§ÐÅÏ¢£»Èç¹ûÄúÏë²éѯij¸öÓû§£¬¾ÍÖ±½ÓÖ¸¶¨Óû§£¬¿ÉÒÔÖ¸¶¨Ò»¸ö»ò¶à¸ö£»Ê²Ã´ÊÇttyµÇ¼£¿Èç¹ûÄúÔÚÈ«ÆÁÎı¾½çÃæ²Ù×÷µÄ»°£¬Äú¿ÉÒÔͨ¹ý°´CTRL+F2»òCTRL+F3 »òCTRL+F4µÈ£¬ ÒÔ¼¸¸ö²»Í¬µÄÓû§µÇ¼µ½Ö÷»úÉÏ£¬Äú¾Í»á¿´µ½£¬Ã¿¸öÓû§¶¼Óв»Í¬µÄtty£»

[beinan@localhost ~]$ finger -l
[beinan@localhost ~]$ finger -l beinan linuxsir ×¢£º¿ÉÒÔͬʱ²éѯ¼¸¸öÓû§ÐÅÏ¢£¬ÒÔ³¤¸ñʽÊä³ö£»

[beinan@localhost ~]$ finger beinan
Login: beinan Name: beinan sun
Directory: /home/beinan Shell: /bin/bash
On since Wed Nov 2 08:27 (CST) on tty1 2 hours 29 minutes idle
On since Wed Nov 2 10:50 (CST) on pts/0 from :0.0
No mail.
No Plan.

ÔÚ±¾ÀýÖУ¬Ëù²éѯµÄÓû§ÊÇbeinan£¬ÕæʵÃû×ÖÊÇbeinan sun £¬¼ÒĿ¼λÓÚ /home/beinan £¬ËùÓÃSHELLÀàÐÍÊÇbash £»È»ºó¾ÍÊÇͨ¹ýÄĸöÖն˵ǼµÄ£¬µÇ¼ʱ¼ä£¬ÊDz»ÊÇÓÐmail £¬ÓÐPlan µÈ£»

ʵÀýÈý£º²ÎÊý×éºÏµÄÀý×Ó£»

[beinan@localhost ~]$ finger -lp beinan
Login: beinan Name: beinan sun
Directory: /home/beinan Shell: /bin/bash
On since Wed Nov 2 08:27 (CST) on tty1 2 hours 36 minutes idle
On since Wed Nov 2 10:50 (CST) on pts/0 from :0.0
No mail.

×¢½â£º²éѯbeinanÓû§ÐÅÏ¢£¬ÒÔ³¤¸ñʽÊä³ö£¬²¢ÇÒ²»Êä³ö.PlanºÍ.ProjectµÄÄÚÈÝ£»

ʵÀýËÄ£º finger -s ºÍw ¼°whoµÄ±È½Ï£»

¶ÔÓÚfinger ¾Í˵Õâô¶à°É£¬¼«Îª¼òµ¥µÄ¹¤¾ß£¬µ±Óõ½-s ²ÎÊýʱ£¬Äú×îºÃºÍwºÍwho¹¤¾ß¶ÔÕÕ£¬¿´¿´finger -s ºÍw ¼°whoµÄÊä³öÓÐʲôÒìͬ£¬wºÍwhoÊDzéѯÄÄЩÓû§µÇ¼Ö÷»úµÄ£»¶øfinger -s ÄØ£¬ÎÞÂÛÊǵǼ»¹ÊDz»µÇ¼µÄÓû§¶¼¿ÉÒԲ飻µ«Ëù²éµ½µÄÄÚÈݲàÖØÓÐËù²»Í¬£»×Ô¼º¿´¿´Àý×Ó£»

[beinan@localhost ~]$ finger -s
Login Name Tty Idle Login Time Office Office Phone
beinan beinan sun tty1 3:03 Nov 2 08:27
beinan beinan sun pts/0 Nov 2 10:50 (:0.0)
linuxsir linuxsir open tty2 1:26 Nov 2 10:03 linuxsir o +1-389-866-771
[beinan@localhost ~]$ w
11:30:36 up 3:04, 3 users, load average: 0.30, 0.15, 0.10
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
beinan tty1 - 08:27 3:03m 2:52 0.00s /bin/sh /usr/X11R6/bin/startx
linuxsir tty2 - 10:03 1:26m 0.01s 0.01s -bash
beinan pts/0 :0.0 10:50 0.00s 0.16s 0.00s w
[beinan@localhost ~]$ who
beinan tty1 Nov 2 08:27
linuxsir tty2 Nov 2 10:03
beinan pts/0 Nov 2 10:50 (:0.0)

3¡¢²éѯµÇ¼Ö÷»úµÄÓû§¹¤¾ß£ºw ¡¢who ¡¢users

w¡¢whoºÍusers¹¤¾ß£¬ÊDzéѯÒѵǼµ±Ç°Ö÷»úµÄÓû§£»ÁíÍâfinger -s ҲͬÑùÄܲéѯ£»²àÖص㲻һÑù£»Çë×Ô¼º¶Ô±È×Å¿´£»±Ï¾¹¼òµ¥£¬ÕâÀïÖ»ÊǽéÉÜ £»

[beinan@localhost ~]$ w
12:09:56 up 3:43, 7 users, load average: 0.16, 0.10, 0.04
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
beinan tty1 - 08:27 3:42m 3:09 0.00s /bin/sh /usr/X11R6/bin/startx
linuxsir tty2 - 10:03 2:06m 0.01s 0.01s -bash
beinan pts/0 :0.0 11:36 1:09 0.15s 0.15s bash
beinan pts/1 :0.0 11:37 1:12 0.21s 0.21s bash
beinan pts/2 :0.0 12:02 6:52 0.09s 0.09s bash
beinan pts/3 :0.0 12:05 12.00s 0.11s 0.06s ssh xmbnnbdl@linuxsir.org -p 17007
beinan pts/4 :0.0 12:06 0.00s 0.21s 0.00s w
[beinan@localhost ~]$ who
beinan tty1 Nov 2 08:27
linuxsir tty2 Nov 2 10:03
beinan pts/0 Nov 2 11:36 (:0.0)
beinan pts/1 Nov 2 11:37 (:0.0)
beinan pts/2 Nov 2 12:02 (:0.0)
beinan pts/3 Nov 2 12:05 (:0.0)
beinan pts/4 Nov 2 12:06 (:0.0)
[beinan@localhost ~]$ users
beinan beinan beinan beinan beinan beinan linuxsir

4¡¢groups Óû§Ëù¹éÊôµÄÓû§×é²éѯ£»

groups Ó÷¨ºÜ¼òµ¥£¬¾ÍÊDzéѯÓû§Ëù¹éÊôÄĸö»òÄÄЩÓû§×飻

Óï·¨¸ñʽ£º groups Óû§Ãû

ʵÀý£º

[beinan@localhost ~]$ groups beinan ×¢£º²éѯbeinanËù¹éÊôµÄÓû§×飻
beinan : beinan ×¢£ºbeinan ÊÇbeinanÓû§×éϵijÉÔ±£»
[beinan@localhost ~]$ groups linuxsir ×¢£º²éѯlinuxsirÓû§Ëù¹éÊôµÄÓû§×飻
linuxsir : linuxsir root beinan ×¢£ºlinuxsirÓû§ÊÇlinuxsirÓû§×é¡¢beinanÓû§×é¡¢rootÓû§×é³ÉÔ±£»

groups Ö÷ÒªÊDzéѯÓû§Ëù¹éÊôµÄÓû§×éÃû£¬×îºÃºÍidÃüÁîÏà¶Ô±È£»ÕâÑù¶ÔÕâÁ½¸ö¹¤¾ß¶¼ÓÐËùÁ˽⣻

Èý¡¢ºó¼Ç£»

±¾ÎÄÊǺܼòµ¥µÄÎĵµ£¬»¨Ê®·ÖÖÓ¾ÍÄÜ¿´µÃÍ꣬µ«¶ÔÎÒÀ´Ëµ¼ÈÈ»ÏëдÈëÃż¶ÏµÁÐÎĵµÁË£¬ÔÙ¼òµ¥Ò²µÃ¸æËß³õѧÕߣ¬²»ÊÇÂð£¿Ð´±¾ÎĵÄʱºò£¬ÎÒÒѾ­°Ñ²éѯÓû§µÄ¹¤¾ßÁÐΪ¡¶Linux Óû§¼°Óû§×é¹ÜÀí¹¤¾ß½éÉÜ¡·µÄÎĵµÖУ¬µ«Ð´×Åд×Å·¢ÏÖÎĵµÌ«³¤ÁË£¬ËùÒÔÖ»ºÃ°ÑÓû§µÄ²éѯ×öΪ¶ÀÁ¢µÄһƪÏÈ·¢³öÀ´£»
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 2 ÌõÆÀÂÛ

  1. djdior0622 ÓÚ 2007-11-21 09:40:07·¢±í:

    (6)m:b

  2. cwb2264 ÓÚ 2007-06-04 17:53:44·¢±í:

    лл¥Ö÷£¡Ñ§Ï°ÁË£¡