如何在Ubuntu 18.04中实现账号锁定
本文目录导读:
- <"http://#id1" title="Allow root to run any commands anywhere" "">Allow root to run any commands anywhere
在Ubuntu 18.04中,可以通过以下几种方法来实现账号锁定:
方法一:使用sudoers文件
1、打开终端,输入以下命令打开sudoers文件:
sudo visudo
2、在打开的文件中,找到以下行:
Allow root to run any commands anywhere
root ALL=(ALL:ALL) ALL
3、在该行的下方添加以下内容
username ALL=NOPASSWD:ALL
username是要锁定的账号的用户名。
4、保存并关闭文件。
5、在终端中输入以下命令,以锁定该账号:
sudo passwd -l username
此时,系统会提示输入当前用户的密码,输入密码后即可锁定该账号。
方法二:使用lightdm
1、打开终端,输入以下命令以编辑lightdm的配置文件:
sudo nano /etc/lightdm/lightdm.conf
2、在打开的文件中,找到以下行:
#greeter-hide-users=true
将其修改为
greeter-hide-users=true
3、保存并关闭文件。
4、重新启动系统,即可实现账号锁定,此时,除了管理员账号外,其他账号都无法登录系统。
方法三:使用ufw和iptables
1、打开终端,输入以下命令以安装ufw和iptables:
sudo apt-get update && sudo apt-get install ufw iptables
2、输入以下命令以配置ufw
sudo ufw enable input deny incoming deny outgoing deny enable logging on; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest $Allowed/Blocked $Bytes > /dev/null; done > /etc/iptables/rules.v4; sudo iptables-save > /etc/iptables/rules.v4; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest $Allowed/Blocked $Bytes > /etc/iptables/rules.v6; done > /etc/iptables/rules.v6; sudo iptables-save > /etc/iptables/rules.v6; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest $Allowed/Blocked $Bytes >> /etc/iptables/rules-save; done >> /etc/iptables/rules-save; sudo iptables-save >> /etc/iptables/rules-save; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest $Allowed/Blocked $Bytes >> /etc/iptables/rules-save-v6; done >> /etc/iptables/rules-save-v6; sudo iptables-save >> /etc/iptables/rules-save-v6; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest $Allowed/Blocked $Bytes >> /etc/iptables/rules-custom; done >> /etc/iptables/rules-custom; sudo iptables-save >> /etc/iptables/rules-custom; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest $Allowed/Blocked $Bytes >> /etc/iptables/rules-custom-v6; done >> /etc/iptables/rules-custom-v6; sudo iptables-save >> /etc/iptables/rules-custom-v6; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allowed/Blocked Bytes Drop; do echo $Chain $Target $Prot $Src $Dest Allowed Bytes >> /var/log/ufw.log; done > /var/log/ufw.log; sudo iptables -L INPUT -v -n | while read Chain Target Prot Src Dest Allow
版权声明
本文仅代表作者观点,不代表米安网络立场。
上一篇:腾达路由器无法访问互联网 下一篇:Windows 7中退出系统时清理最近使用的项目
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。