系统用户管理脚本详解
1. 节省空间小技巧
为了节省空间,可以将 .slocatedb 文件进行压缩,在使用 slocate 搜索时再动态解压。可以参考相关命令实现这一操作。
2. 添加用户到系统
在管理 Unix 或 Linux 系统网络时,不同操作系统间用户账户管理存在兼容性问题。为解决这一问题,可使用自定义的 adduser 、 suspenduser 和 deleteuser 脚本。
2.1 代码实现
#!/bin/bash
# adduser--Adds a new user to the system, including building their
# home directory, copying in default config data, etc.
# For a standard Unix/Linux system, not OS X.
pwfile="/etc/passwd"
shadowfile="/etc/shadow"
gfile="/etc/group"
hdir="/home"
if [ "$(id -un)" != "root" ] ; then
echo "Error: You must be root to run this command." >&2
exit 1
fi
echo "Add new user account to $(hostna
超级会员免费看
订阅专栏 解锁全文
33万+

被折叠的 条评论
为什么被折叠?



