is-admin-user
Check whether the current Python process is running as an administrator.
is-admin-user is a tiny, dependency-free Python package that works across
Windows, Linux, and macOS. It exposes a programmable function interface for
checking whether the current process has administrative privileges.
Installation
pip install is-admin-user
For local development:
pip install -e .
Usage
Python
from is_admin_user import is_admin_user
if is_admin_user():
print("Running as administrator/root")
else:
print("Running as a standard user")
You can also use the shorter alias:
from is_admin_user import is_admin
if is_admin():
print("Administrative privileges are available")
Command line
is-admin-user
The command prints true and exits with status code 0 when the current
process has administrator/root privileges. It prints false and exits with
status code 1 otherwise.
For scripts that only need the exit code:
is-admin-user --quiet
Platform behavior
- Windows: returns
Truewhen the current process token is running with administrator privileges. - Linux: returns
Truewhen the effective user ID is0(root). - macOS: returns
Truewhen the effective user ID is0(root).
On Windows, an account that belongs to the Administrators group may still return
False if the Python process was not started with elevated privileges.
API
is_admin_user() -> bool
Returns True when the current Python process has administrator/root
privileges, otherwise returns False.
is_admin() -> bool
Alias for is_admin_user().
Development
Run the test suite with:
python -m pytest
Metadata
Release files for is-admin-user 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| is_admin_user-0.1.1.tar.gz | 4.7 kB | Without provenance | Details for is_admin_user-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| is_admin_user-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for is_admin_user-0.1.1-py3-none-any.whl |
Total release size: 9.7 kB
Release files / is_admin_user-0.1.1.tar.gz
| Download URL | is_admin_user-0.1.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
caf7b0288d8bff05aac164b621941968a095c47a3ccc1e032cdeb3d9fa4ef7b7
|
|
BLAKE2b-256 checksum How to use checksums |
5bd28460fc3f667f7fa87c297cbadf6127935a50f93c62f6dad1ddce2f9c1365
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Release files / is_admin_user-0.1.1-py3-none-any.whl
| Download URL | is_admin_user-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad77912508ae750b68790afbf43cf92886cef0c66f3e20b54c67112679a41cde
|
|
BLAKE2b-256 checksum How to use checksums |
3a694a94e2b00db1c3d9cd0f3af4779015a260538544ce7875f336f1f52f29e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Security for is-admin-user 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.