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
相关推荐
SmartRadio8 分钟前
在CH585M代码中如何精细化配置PMU(电源管理单元)和RAM保留
linux·c语言·开发语言·人工智能·单片机·嵌入式硬件·lora
济61718 分钟前
linux(第十四期)--Uboot移植(2)-- 在U-Boot 中添加自己的开发板-- Ubuntu20.04
linux·运维·服务器
ben9518chen22 分钟前
嵌入式linux操作系统简介
linux·运维·服务器
菜鸟笔记本23 分钟前
linux设置定时备份mysql数据
linux·mysql·oracle
majingming12327 分钟前
ubuntu下的交叉编译
linux·运维·ubuntu
shchojj29 分钟前
ubuntu 因为写错pam.d文件引起的sudo权限丢失
linux·运维·ubuntu
funfan05171 小时前
【运维】Linux/Debian系统时间校准方法简记
linux·运维·debian
Florence231 小时前
cuFuncSetCacheConfig
linux·运维·服务器
一尘之中2 小时前
Ubuntu 22.04 上 FastAPI 的完整安装与问题解决指南
ubuntu·fastapi·ai写作
Petal9909122 小时前
内核调试:Linux编译内核源码为deb并更新内核
linux·运维·服务器