帮助代表系统中的所有用户执行命令的实用程序

with-each-user的Python项目详细描述


每个用户的命令基本上只是一个快捷方式/替换 对于以下结构:

root:~# ls /home | xargs -i su - {} -c "whoami"

也就是说,它的目标是对系统中的所有用户执行相同的命令 在一行。上面的行可以重写为:

root:~# with_each_user whoami

此外,您还可以通过用户的登录名、外壳和 uid、同时以交互方式运行命令并存储脚本输出 在单独目录中的日志文件中。

有关详细信息,请参见用法。

用法

这是with_each_user --help输出:

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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用从PreparedStatement返回的RowId。getGeneratedKeys()?   selenium chrome驱动程序中下一个网站url的java空白页   java如何将参数化匿名类转换为lambda?   java JUnit在AfterClass上获取测试结果   java将动态XML/JSON内容与静态标记化负载进行比较,并检索标记值   java共享一个需要数据持久性的项目[数据库]   java在调用方法时获取意外的参数类型。getParameterTypes()   java如何用jdbc在swing中用另一个字段替换外键?   需要java Jersey Tomcat CDI依赖项解释   java如何生成UML图   java如何编写Jersey rest服务可以通过给定的spring代码访问   SpringMaven存储库管理器Nexus与Java依赖项的Artifactory   java将包从另一个项目导入eclipse中的当前项目   加密Java使用密码加密文件