方法1:使用usermod命令:
鎖定:$ usermod -l 用戶名 (鎖定用戶賬號(hào),重新登陸生效)
解鎖:$ usermod -u 用戶名
查詢狀態(tài): $ usermod -S 用戶名
方法2:使用passwd命令:
鎖定:$ passwd -l 用戶名 (鎖定用戶密碼,重新登陸生效)
解鎖:$ passwd -u 用戶名
查詢狀態(tài): $ passwd -S 用戶名
方法3:使用usermod命令禁用SSH訪問Linux中的給定用戶帳戶
鎖定:$ usermod -s /sbin/nologin 用戶名
解鎖:$ usermod -s /bin/bash 用戶名
查詢狀態(tài):可以 vim /etc/passwd查看每個(gè)用戶的狀態(tài)文章來源:http://www.zghlxwxcb.cn/news/detail-451379.html
方法4:禁用所有用戶登錄(除root用戶)
鎖定:$ touch /etc/nologin
解鎖:$rm -f /etc/nologin(刪除掉文件即可)文章來源地址http://www.zghlxwxcb.cn/news/detail-451379.html
到了這里,關(guān)于Linux鎖定用戶的幾種方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!