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
相关推荐
hweiyu0019 小时前
Linux 命令:split
linux·运维·服务器
lihe75819 小时前
每天凌晨3点自动同步UBUNTU源
linux·运维·ubuntu·本地源
添砖java‘’20 小时前
线程的互斥与同步
linux·c++·操作系统·线程·信息与通信
tod11320 小时前
Makefile进阶(上)
linux·运维·服务器·windows·makefile·进程
阳光九叶草LXGZXJ20 小时前
达梦数据库-学习-50-分区表指定分区清理空洞率(交换分区方式)
linux·运维·数据库·sql·学习
zbliquan20 小时前
SS928v100远程ubuntu交叉编译开发环境搭建
linux·运维·ubuntu
我爱加班、、21 小时前
new Map()+Array.from()整理elementPlus的级联器数据
linux·前端·javascript
豆是浪个21 小时前
Linux(Centos 7.6)命令详解:top
linux·运维·服务器
历程里程碑21 小时前
Linxu14 进程一
linux·c语言·开发语言·数据结构·c++·笔记·算法
baidu_huihui21 小时前
`sudo DNF` 是 Linux 系统中以管理员权限执行 DNF 包管理命令的标准方式
linux·dnf