每次添加新用户时执行命令的最简单方法是什么?
我检查过了,/etc/adduser.conf但里面没有任何东西看起来会这样做?
我考虑将它添加给用户.bashrc,以便在他们登录时执行它,但我宁愿在他们登录之前设置它。
任何帮助,将不胜感激。
来自man adduser:
If the file /usr/local/sbin/adduser.local exists, it will be exe‐
cuted after the user account has been set up in order to do any
local setup. The arguments passed to adduser.local are:
username uid gid home-directory
看起来您可以在此处添加用户创建操作。
我不知道直接的方法...但是,您可以检查/etc/passwd文件或/home directrory使用例如inotifywait或使用某些 cron 作业的更改。
几年前我这样做了,编写了一个自定义脚本,它可以完成我需要的所有操作,并adduser在脚本内部调用以将用户添加到系统中。