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 | |
|---|---|---|---|
| is_admin_user-0.1.1.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| is_admin_user-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
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
|