• 【Linux operation 49】实现ubuntu-22.04.1允许root用户登录图形化桌面


    Ubuntu系统中,默认root不能登录图形界面,普通用户需要使用root权限时,只能通过sudo [命令] [参数] 临时使用root权限,或是使用su root切换到root用户权限下进行操作。

    1、 设置 root 密码

    sudo passwd root
    
    • 1

    输入两遍密码;
    返回如下信息,即表示 root 密码设置成功;

    passwd: password updated successfully
    
    • 1

    在这里插入图片描述

    2、 修改50-ubuntu.conf文件

    命令:

    vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
    
    • 1

    在文件尾加入两行:

    greeter-show-manual-login=true
    all-guest=false
    
    • 1
    • 2

    在这里插入图片描述

    3、修改gdm-autologin和gdm-passwd文件

    3.1、修改gdm-autologin文件

    路径:

    /etc/pam.d/gdm-autologin
    
    • 1

    命令:

    vim /etc/pam.d/gdm-autologin
    
    • 1

    操作:
    注释掉auth required pam_success_if.so user!=root quiet_success 这一行

    #auth   required        pam_succeed_if.so user != root quiet_success 
    
    • 1

    在这里插入图片描述

    3.2、修改gdm-password文件

    路径:

    /etc/pam.d/gdm-password
    
    • 1

    命令:

    vim /etc/pam.d/gdm-password
    
    • 1

    操作:注释掉#auth required pam_succeed_if.so user != root quiet_success 这一行

    #auth   required        pam_succeed_if.so user != root quiet_success
    
    • 1

    在这里插入图片描述

    4、修改/root/.profile文件

    将 mesg n 改为 tty -s && mesg n

    vim /root/.profile
    
    • 1

    未修改前:

    root@test-virtual-machine:/# cat /root/.profile
    # ~/.profile: executed by Bourne-compatible login shells.
    
    if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
        . ~/.bashrc
      fi
    fi
    
    mesg n 2> /dev/null || true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    修改后

    root@test-virtual-machine:/# cat /root/.profile
    # ~/.profile: executed by Bourne-compatible login shells.
    
    if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
        . ~/.bashrc
      fi
    fi
    
    tty -s && mesg n 2> /dev/null || true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    5、重启系统,使用root用户登录系统

    重启系统后,登录选择Not Listed?
    在这里插入图片描述

    输入root用户名与密码进行登录

    在这里插入图片描述

    在这里插入图片描述

  • 相关阅读:
    求余数联系和赋值运算
    【云原生 | Kubernetes 系列】--Gitops持续交付 ArgoCD 部署与概念
    前端开发:JS的解构
    DAP-seq在植物转录因子的应用案例助你打通研究思路
    redis
    Spring的创建和使用
    机器学习笔记 十八:基于3种方法的随机森林模型分析房屋参数重要性
    电脑重装系统后如何删除微软商店下载记录
    设计模式初版讲解
    Elasticsearch-使用Logstash同步Mysql
  • 原文地址:https://blog.csdn.net/qq_22938603/article/details/126908328