zoukankan      html  css  js  c++  java
  • Ubuntu 20.04.2如何root登录

    Ubuntu 20.04.2默认不能进行root登录

    1、查看系统版本

    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ whoami
    liujiaxin01
    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ cat /proc/version
    Linux version 5.8.0-59-generic (buildd@lcy01-amd64-022) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #66~20.04.1-Ubuntu SMP Thu Jun 17 11:14:10 UTC 2021

    2、测试使用root登录

    3、修改50-ubuntu.conf配置文件

    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ sudo vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
    [sudo] password for liujiaxin01: ## 输入密码, 以下是修改后的内容,新增了3、4行
    [Seat:*]                           
    user-session=ubuntu
    greeter-show-manual-login= true ## now line
    all-guest=false # new line, not necessary

    4、修改gdm-autologin配置文件

    执行sudo vim /etc/pam.d/gdm-autologin 注释掉auth required pam_succeed_if.so user != root quiet_success这一行(第三行左右)

    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ sudo vim /etc/pam.d/gdm-autologin
    #%PAM-1.0
    auth    requisite       pam_nologin.so
    #auth   required        pam_succeed_if.so user != root quiet_success  // 注释掉这一行
    auth    optional        pam_gdm.so
    auth    optional        pam_gnome_keyring.so
    auth    required        pam_permit.so
    @include common-account
    # SELinux needs to be the first session rule. This ensures that any 
    # lingering context has been cleared. Without this it is possible 
    # that a module could execute code in the wrong domain.
    session [success=ok ignore=ignore module_unknown=ignore default=bad]        pam_selinux.so close
    session required        pam_loginuid.so
    # SELinux needs to intervene at login time to ensure that the process
    # starts in the proper default security context. Only sessions which are
    …………

    5、修改gdm-password配置文件

    执行sudo vim /etc/pam.d/gdm-password注释掉 auth required pam_succeed_if.so user != root quiet_success这一行(第三行左右)

    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ sudo vim /etc/pam.d/gdm-password
    #%PAM-1.0
    auth    requisite       pam_nologin.so
    #auth   required        pam_succeed_if.so user != root quiet_success  ## 注释掉这一行
    @include common-auth
    auth    optional        pam_gnome_keyring.so
    @include common-account
    # SELinux needs to be the first session rule. This ensures that any 
    # lingering context has been cleared. Without this it is possible 
    # that a module could execute code in the wrong domain.
    session [success=ok ignore=ignore module_unknown=ignore default=bad]        pam_selinux.so close
    session required        pam_loginuid.so
    # SELinux needs to intervene at login time to ensure that the process
    # starts in the proper default security context. Only sessions which are
    # intended to run in the user's context should be run after this.
    # pam_selinux.so changes the SELinux context of the used TTY and configures
    # SELinux in order to transition to the user context with the next execve()
    # call.
    …………

    6、修改/root/.profile文件

    执行sudo vim /root/.profile修改配置文件如下:

    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ sudo vim /root/.profile
    # ~/.profile: executed by Bourne-compatible login shells.
    
    if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
        . ~/.bashrc
      fi
    fi
    tty -s && mesg n || true
    mesg n || true
    #mesg n 2> /dev/null || true

    7、重启系统

    liujiaxin01@liujiaxin01-virtual-machine:~/Desktop$ reboot

    8、测试root直接登录

     

    root@liujiaxin01-virtual-machine:~/Desktop# whoami   ##直接登录成功
    root

    来源:https://blog.csdn.net/ht1032279753/article/details/107672004

  • 相关阅读:
    HDU3336 Count the string —— KMP next数组
    CodeForces
    51Nod 1627 瞬间移动 —— 组合数学
    51Nod 1158 全是1的最大子矩阵 —— 预处理 + 暴力枚举 or 单调栈
    51Nod 1225 余数之和 —— 分区枚举
    51Nod 1084 矩阵取数问题 V2 —— 最小费用最大流 or 多线程DP
    51Nod 机器人走方格 V3 —— 卡特兰数、Lucas定理
    51Nod XOR key —— 区间最大异或值 可持久化字典树
    HDU4825 Xor Sum —— Trie树
    51Nod 1515 明辨是非 —— 并查集 + 启发式合并
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14940308.html
Copyright © 2011-2022 走看看