用户不会出现在 Mac OS X 上的 /etc/passwd 中

pos*_*eid 38 unix macos

通过检查/etc/passwd文件,我应该得到系统中所有用户的列表。然而,当倾倒passwd在 Mac OS XI 上文件时,看不到我当前的用户名,但有很多类似这样的条目:

  _xgridagent:*:86:86:Xgrid 代理:/var/xgrid/agent:/usr/bin/false
  _appowner:*:87:87:Application Owner:/var/empty:/usr/bin/false
  _windowserver:*:88:88:WindowServer:/var/empty:/usr/bin/false
  _spotlight:*:89:89:Spotlight:/var/empty:/usr/bin/false
  _tokend:*:91:91:Token Daemon:/var/empty:/usr/bin/false

为什么我可以使用我的用户名登录 shell 并在我这样做时看到该用户名who

Ste*_*eet 30

/etc/passwd仅当操作系统处于单用户模式时才查阅该文件。OS X 上帐户信息的“标准”位置是 DirectoryService。

尝试man DirectoryService获取更多信息。

以下注释块出现在我的密码文件的顶部:

##
# User Database
# 
# Note that this file is consulted directly only when the system is running
# in single-user mode.  At other times this information is provided by
# Open Directory.
#
# This file will not be consulted for authentication unless the BSD local node
# is enabled via /Applications/Utilities/Directory Utility.app
# 
# See the DirectoryService(8) man page for additional information about
# Open Directory.
##
Run Code Online (Sandbox Code Playgroud)

在最新版本的 OS X 目录实用程序中,已移至/System/Library/CoreServices/Directory Utility.

  • 添加了目录实用程序的新位置。 (2认同)

Jon*_*ler 11

有一组保存信息的目录服务。有一系列命令行工具(dscl一个)来操作它们(硬),或者您可以使用系统偏好设置来处理其中的一些。