Bash 更改用户信息(如 usermod)但没有 root 权限

use*_*483 2 linux bash

我正在为用户编写一个小的 GUI 程序来编辑他们自己的帐户。您不能以普通用户身份运行 usermod,我正在寻找这种功能。

更改用户全名是最重要的。任何其他帮助或信息也会很棒。

Gab*_*abe 7

chfnchsh公用事业应可在系统上,而应该做你想要的东西-他们将改变gecos字段(真名等)和登录shell,分别基于可配置的规则,而无需编写代码,以root运行给自己特权(这并不,只是错误的代价非常非常高)。

从 chfn 手册页:

   The chfn command changes user fullname, office room number,
   office phone number, and home phone number information for a
   user's account. 
Run Code Online (Sandbox Code Playgroud)

从 chsh 手册页:

   The chsh command changes the user login shell. This determines the name of the
   user's initial login command. A normal user may only change the login shell
   for her own account; the superuser may change the login shell for any account.
Run Code Online (Sandbox Code Playgroud)