Skip to main content

python-sudo

Modular Python to execute any subprocess commands as another user (not necessarily superuser/root)

calling sudo -u

Usage:

This module does not take a user password for security and efficiency reasons (aiming for no user interaction to run).

Configure the sudoers file to allow running commands as another user (not necessarily the superuser):

sudo visudo:
  • parent_user ALL=(run_user) NOPASSWD: ALL
from sudo import run_as_sudo

# run `whoami` from user 'user'
cmd = "whoami"
sudo_user = "user"

run_as_sudo(sudo_user, cmd)

# optional shell, timeout (secs)
run_as_sudo(sudo_user, cmd, shell=True, timeout=20)

Metadata

Release files for sudo 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for sudo 1.0.0
File Interpreter ABI Platform
sudo-1.0.0-py3-none-any.whl Python 3 none any Details

Release files / sudo-1.0.0-py3-none-any.whl

Download URL sudo-1.0.0-py3-none-any.whl
Size 2.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65ace059d4173d2d7ffb0f0697ee64faeaef833ae2a1328b3124a39aea00a19c
BLAKE2b-256 checksum
How to use checksums
bb67d6f3d7cca5de7525bd75e1743fbc278bf3f995015c4c16848f2084da4b6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page