ÔõÑù¼ìË÷LinuxϵͳÖеÄËùÓÐÓû§
LinuxϵͳÏÂÔõÑùÉó²éËùÓÐÓû§
ÔÚLinuxϵͳÖУ¬ÒªÉó²éËùÓÐÓû§¿ÉÒÔͨ¹ýÏÂÁîÐÐÀ´ÊµÏÖ¡£ÏÂÃ潫ÏÈÈݼ¸ÖÖ³£ÓõÄÒªÁìÀ´Éó²éϵͳÖеÄËùÓÐÓû§£¬°üÀ¨Í¨Ë×Óû§ºÍϵͳÓû§¡£
ʹÓÃcat /etc/passwdÏÂÁî
ÔÚLinuxϵͳÖУ¬ËùÓÐÓû§ÐÅÏ¢¶¼ÉúÑÄÔÚ/etc/passwdÎļþÖС£ÎÒÃÇ¿ÉÒÔʹÓÃcatÏÂÁîÀ´Éó²éÕâ¸öÎļþ£¬´Ó¶ø»ñÈ¡ËùÓÐÓû§µÄÐÅÏ¢¡£
cat /etc/passwd
µÇ¼ºó¸´ÖÆ
ÉÏÊöÏÂÁî»áÏÔʾһ¸ö°üÀ¨ËùÓÐÓû§ÐÅÏ¢µÄÁÐ±í£¬Ã¿Ðдú±íÒ»¸öÓû§£¬¿ÉÒÔ¿´µ½Óû§µÄÓû§Ãû¡¢UID£¨Óû§ID£©¡¢GID£¨×éID£©¡¢Óû§ÐÎò¡¢Ö÷Ŀ¼¡¢µÇ¼shellµÈÐÅÏ¢¡£Í¨¹ýÕâÖÖ·½·¨¿ÉÒÔÉó²éËùÓÐÓû§µÄ»ù±¾ÐÅÏ¢¡£
ʹÓÃgetent passwdÏÂÁî
getentÏÂÁî¿ÉÒÔÓÃÀ´»ñȡϵͳÓû§ºÍ×éµÄÐÅÏ¢£¬Ò²¿ÉÒÔͨ¹ýgetent passwdÀ´Éó²éËùÓÐÓû§µÄÐÅÏ¢¡£
getent passwd
µÇ¼ºó¸´ÖÆ
Õâ¸öÏÂÁîÊä³öµÄÐÅÏ¢Óëcat /etc/passwdÏÂÁîÀàËÆ£¬Ò²ÊÇÁгöÁËϵͳÖеÄËùÓÐÓû§ÐÅÏ¢¡£
ʹÓÃcutºÍawkÏÂÁî
ÈôÊÇÎÒÃÇֻϣÍûÉó²éÓû§Ãû£¬¿ÉÒÔʹÓÃcutºÍawkÀ´ÌáÈ¡/etc/passwdÎļþÖеÄÓû§ÃûÐÅÏ¢¡£
cat /etc/passwd | cut -d: -f 1
µÇ¼ºó¸´ÖÆ
ÉÏÃæµÄÏÂÁî»áÁгöϵͳÖÐËùÓÐÓû§µÄÓû§Ãû¡£
ʹÓÃawkÏÂÁî
ÁíÍâÒ»ÖÖÒªÁìÊÇÖ±½ÓʹÓÃawkÏÂÁîÀ´´Ó/etc/passwdÎļþÖÐÌáÈ¡Óû§Ãû¡£
awk -F: '{print $1}' /etc/passwd
µÇ¼ºó¸´ÖÆ
Õâ¸öÏÂÁîÒ²¿ÉÒÔÖ±½ÓÊä³öϵͳÖÐËùÓÐÓû§µÄÓû§Ãû¡£
×ÛÉÏËùÊö£¬ÒÔÉÏÊÇÔÚLinuxϵͳÏÂÉó²éËùÓÐÓû§µÄ¼¸ÖÖ³£ÓÃÒªÁ죬ÿÖÖÒªÁ춼Óвî±ðµÄÓÃ;ºÍʵÏÖ·½·¨£¬¿ÉÒÔƾ֤ÏêϸµÄÐèÇóÑ¡ÔñºÏÊʵÄÒªÁìÀ´Éó²éϵͳÖеÄÓû§ÐÅÏ¢¡£
ÒÔÉϾÍÊÇÔõÑù¼ìË÷LinuxϵͳÖеÄËùÓÐÓû§µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡