在 Unix 中添加用户和组 [英] Adding User and Group in Unix

查看:29
本文介绍了在 Unix 中添加用户和组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道在unix中添加用户和组并删除它们的api?我想以编程方式执行此操作.

Does anyone know the api for adding users and groups in unix and removing them ? I want to do this programatically.

谢谢,弗兰克

推荐答案

我在寻找一种在 Unix 上列出所有组的方法时发现了这个问题.但是要创建和删除用户,您可以以编程方式调用实用程序 useradd、userdel、groupadd、groupdel,因为您会知道发送的用户名.但我想你需要超级用户权限才能调用它们.无论如何,您可以检查进程退出代码的命令状态.

I found this question while looking for a way to list all groups on a Unix. But to create and delete users you can programatically call the utility programs useradd, userdel, groupadd, groupdel since you would know the user name been sent. But I guess you will need superuser rights to invoke them. Anyway you can check the process exit code for command status.

 useradd xxx // status zero operation completed
 useradd xxx // status nine user already exists

希望有帮助.

这篇关于在 Unix 中添加用户和组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆