Ubuntu取消开机用户自动登录

注:配置前请先设置登录密码,不同显示管理器配置方法不同,可用命令查看:cat /etc/X11/default-display-manager

一、LightDM 显示管理器,关闭 Ubuntu 系统用户自动登录

  1. 查找自动登录配置文件,可以看到类似 autologin.conf 的文件
sh 复制代码
find / -iname "*autologin.conf*"

/etc/lightdm/lightdm.conf.d/20-autologin.conf
  1. 找到文件中以下几行,将 autologin-user=teamhd 改为 autologin-user= 然后重启验证
sh 复制代码
[Seat:*]
user-session=Lubuntu
autologin-user=
  1. 可用 sed 命令一键配置,然后重启验证
sh 复制代码
关闭:sudo sed -i 's/^autologin-user=teamhd/autologin-user=/' /etc/lightdm/lightdm.conf.d/20-autologin.conf

开启:sudo sed -i 's/^autologin-user=/autologin-user=teamhd/' /etc/lightdm/lightdm.conf.d/20-autologin.conf

sudo systemctl restart lightdm

二、GDM 显示管理器,关闭 Ubuntu 系统用户自动登录

  1. 查找自动登录配置文件,可以看到类似于以下名称的文件
sh 复制代码
find / -iname "*custom.conf*"

/etc/gdm3/custom.conf
  1. 找到文件中以下几行,将 AutomaticLoginEnable = true 改为 false 然后重启验证
sh 复制代码
[daemon]
AutomaticLoginEnable = false
AutomaticLogin = teamhd
  1. 可用 sed 命令一键配置,然后重启验证
sh 复制代码
关闭:sudo sed -i 's/^AutomaticLoginEnable *= *true/AutomaticLoginEnable=false/' /etc/gdm3/custom.conf

开启:sudo sed -i 's/^AutomaticLoginEnable *= *false/AutomaticLoginEnable=true/' /etc/gdm3/custom.conf

sudo systemctl restart gdm

三、特殊情况(没有自动登录配置文件)

  1. 如果没找到类似文件名的配置文件,则手动创建并添加内容,例如 20-autologin.conf
sh 复制代码
sudo vim /etc/lightdm/lightdm.conf.d/20-autologin.conf
  1. 在文件中添加以下内容来关闭自动登录,然后重启验证
sh 复制代码
[Seat:*]
autologin-user=
  1. 在文件中添加以下内容来开启自动登录,然后重启验证
sh 复制代码
[Seat:*]
autologin-user=teamhd
相关推荐
IMPYLH12 分钟前
Linux 的 tac 命令
linux·运维·服务器·bash
计算机安禾15 分钟前
【Linux从入门到精通】第50篇:专栏总结与Linux学习之路的未来展望
linux·运维·学习
zhouwy11317 分钟前
Linux 内核学习笔记:从零搭建内核开发与调试环境
linux
GottdesKrieges23 分钟前
OceanBase备份常见问题
linux·网络·oceanbase
白菜欣37 分钟前
Linux —进程概念
linux·运维·服务器
iuu_star40 分钟前
Vue+FastAPI 项目宝塔Linux部署指南
linux·运维·fastapi
楼田莉子43 分钟前
仿Muduo的高并发服务器:Channel模块与Poller模块
linux·服务器·c++·学习·设计模式
zhouwy1131 小时前
Linux网络编程从入门到精通
linux·c++
zhangrelay1 小时前
ROS Kinetic-信号与系统-趣味案例
linux·笔记·学习·ubuntu
IMPYLH1 小时前
Linux 的 tail 命令
linux·运维·服务器·bash