Skip to main content

Get the macOS console username and/or a list of local non-system users.

Project description

macusers

Get details on macOS user accounts.

>>> import macusers
# get the logged in user details.
>>> user = macusers.primary()
# get the logged in user's username.
>>> user.username
'bryanheinz'
# get logged in user's home folder as a `pathlib` object.
>>> user.home
PosixPath('/Users/bryanh')
# get a list of non-system user accounts.
>>> for user in macusers.users(False): print(user.username)
bryanheinz
morrismoss
# get a list of admin accounts.
>>> for admin in macusers.admins(False): print(admin.username)
bryanheinz
# check if the user has FileVault access. NOTE: requires admin.
>>> macusers.primary().fv_access()
True
# check if the user is an APFS volume owner.
>>> macusers.primary().apfs_owner()
True
# check if the user has a secure token.
>>> macusers.primary().secure_token_status()
True

This module is used to get the current or last (if the system currently doesn't have any logged in users) logged in console user on macOS instead of the user running the script/program.

This module now contains the following User properties:

  • username : The user's username
  • real_name : Full name
  • uid : The user's ID
  • gid : Primary group ID
  • guid : Generated user ID - used by APFS
  • home : Home folder
  • shell : Default shell
  • admin : If the user is an admin
  • ssh_access : If the user has SSH access
  • volume_owner : If the user is an APFS volume owner
  • secure_token : If the user has a secure token
  • created : Epoch time when the user was created
  • password_updated: Epoch time when the user's password was last changed

These properties can be accessed via User.PROPERTY e.g. macusers.primary().admin.

Installing

You can install macusers using pip. macusers has been tested with Python 3.7 and 3.9.

python3 -m pip install macusers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macusers-1.0.0.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

macusers-1.0.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page