next up previous contents index
Next: Backups Up: Managing user accounts Previous: Removing a user

临时禁止一个用户

有时需要临时禁止一个用户,而不删除它。例如用户没有付费,或系统管理员怀疑黑客得到了某个帐户的口令。

禁止一个用户的最好方法是将它的shell变到一个特定的只打印出一条信息的程序, 用这种方法,任何想登录此帐户的人将无法登录,并得知原因。 该信息可以告诉用户与系统管理员联系,以处理任何问题。

也可以改变用户名或口令,但这样用户不知道怎么回事。 Confused users mean more work. gif

产生上述特定程序的一个简单方法是写"tail scripts":

#!/usr/bin/tail +2
This account has been closed due to a security breach.
Please call 555-1234 and wait for the men in black to arrive.
前2个字符("#!")告诉核心本行的其他部分是解释本文件要运行的命令。 这样tail 命令将输出处理第一行外的所有东西到标准输出。

如果怀疑billg是个安全缺口,系统管理员可以这样做:

# chsh -s /usr/local/lib/no-login/security billg
# su - tester
This account has been closed due to a security breach.
Please call 555-1234 and wait for the men in black to arrive.
#
su 的目的是此时改变是否工作。

Tail scripts应该放在一个分离的目录中,这样它们的名字不会干扰普通用户的命令。



Linux学院
RedhatCentOSSuse LinuxDebianUbuntu
Sun Jun 29 13:31:22 EEST 1997
《Linux命令大全》 | 《Linux函数调用大全》 | 《Linux系统管理员手册》 | 中国存储网