With each user
The with_each_user command is basically nothing but a shortcut/replacement for constructs like:
root:~# ls /home | xargs -i su - {} -c "whoami"
That is, its goal is to execute the same command for all users in the system in a row. The line above can be rewritten with:
root:~# with_each_user whoami
Additionally, you can filter out unneeded users by their logins, shells and uid, run commands simultaneously, interactively, and store script outputs in log files in a separate directory.
See usage for details.
Usage
This is the with_each_user --help output:
usage: with_each_user [-h] [-m MASK] [-s SHELL] [-u MIN_UID] [-U MAX_UID]
[-c CONCURRENCY] [-d CURRENT_DIRECTORY] [-i]
[-L LOG_DIRECTORY]
command [command ...]
Execute a command for a number users in the server
positional arguments:
command Shell command to execute
optional arguments:
-h, --help show this help message and exit
-m MASK, --mask MASK Filter users by their logins. Globbing is here
allowed, you can type, for example, "user*"
-s SHELL, --shell SHELL
Filter users by their shells. For example, you can
exclude the majority of system users by issuing
"/bin/bash" here
-u MIN_UID, --min-uid MIN_UID
Filter users by their minimal uid.
-U MAX_UID, --max-uid MAX_UID
Filter users by their max uid (to filter out "nobody",
for example
-c CONCURRENCY, --concurrency CONCURRENCY
Number of processes to run simultaneously
-d CURRENT_DIRECTORY, --current-directory CURRENT_DIRECTORY
Script working directory (relative to user's home)
-p, --preserve-environment
Preserve root environment. Arguments match the same of
"su" command
-f, --format Format command line with variables custom for every
user. Supported variables: {user}, {uid}, {gid},
{home}, {shell}, {gecos}.
-r, --root Run command with root privileges (do not "su" to
selected user). Option "--format" is helpful there
-i, --interactive Interactive execution. Set this flag to run processes
interactively
-L LOG_DIRECTORY, --log-directory LOG_DIRECTORY
Directory to store log for all executions. Omit this
argument if you want just to print everything to
stdout/stderr
Metadata
Release files for with-each-user 0.9.2
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 |
|---|---|---|---|---|
| with-each-user-0.9.2.tar.gz | 4.2 kB | Without provenance | Details for with-each-user-0.9.2.tar.gz |
Release files / with-each-user-0.9.2.tar.gz
| Download URL | with-each-user-0.9.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0252648503c511edeaf58e5efbaffbcb0fc574ab2811f7184392bf298240c828
|
|
BLAKE2b-256 checksum How to use checksums |
4a88ae60c0c354cd875bf707f00fcfcf21f76487b227ac9d525db1da44a03cc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for with-each-user 0.9.2
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.