Ubuntu 20.04.2如何root登录

摘要:
=rootquiet_成功//注释这行authoptionalpam_gdm.soauthoptionalpam_gnome_keyring.soauthrequiredpam_permit.so@includecommon-account#SELinux必须是第一个会话规则。这确保清除任何#遗留上下文。如果没有此规则,#模块可以在整个域中执行。会话[success=okignore=ignoremodule_unknown=ignorefault=bad]pam_selinux。soclosse会话需要pam_lognuid。因此#SELinux需要干预登录,以确保进程#在操作默认安全上下文中启动。只有共享的会话…………

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登录

Ubuntu 20.04.2如何root登录第1张

Ubuntu 20.04.2如何root登录第2张

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直接登录

Ubuntu 20.04.2如何root登录第3张

 Ubuntu 20.04.2如何root登录第4张

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

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

免责声明:文章转载自《Ubuntu 20.04.2如何root登录》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Linux| |对于UDP的学习Bootstrap-table实现动态合并相同行(表格同名合并)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Linux之Samba的配置

Samba的配置   对于linux与windows共享,和平共处,我们可以用Samba软件 Samba是一套免费的开源软件,可以在linux或其他类unix操作系统上实现windows域控制器,文件服务,打印服务等。 Samba实现了windows系统所使用的核心网络协议:SMB(Server Message Block)   Samba可以提供如下功能...

Linux 和Windows之间命令行实现目录或文件互传

Linux 和Windows之间命令行实现目录或文件互传 在linux中,我们常用scp命令传输文件: 如以下实例,我们想把当前服务器文件abc.sql传输到192.168.1.1服务器上 我们可以执行以下命令: scp /home/person/hww/abc.sql root@192.168.1.1:/home/person/hww  回车后输入...

如何使用Xmanager及VNC登录远程桌面

如何调用远程桌面,比较常见的有两种方式:Xmanager及VNC 正好今天鼓捣了一下,特整理如下: Xmanager Xmanager的调用也有两种方式: 一、直接在Xshell中调用       这时需设置会话属性,如下图所示,需在“隧道”选项上勾选“转发X11连接到(X):”        二、用Xstart登录远程桌面       如图,主机,用户名...

Linux配置文件的修改

在很多时候,我们需要对Linux的配置文件进行修改。此时就涉及到了不同Linux发行版的修改配置问题。下面就以主流的几个操作系统(Unix:Solaris,Linux:Ubuntu,Redhat)作为说明,添加当前目录到环境变量,来具体阐述Linux的配置文件修改问题。 修改用户配置文件 此修改仅对修改的用户有效,假如修改的用户是user1,那么仅对us...

linux 安装网易云音乐

1.首先去官网下载最新的网易云 网易云音乐曾经推出官方Linux版本,提供的下载安装包有:deepin15(32位):http://s1.music.126.net/download/pc/net ... 0_i386.debdeepin15(64位):http://s1.music.126.net/download/pc/net ... _amd64.d...

C++-如何使用JSONCPP库来读写JSON文件(搭建环境)

以前我从来没有用过JSON这种文件格式,现在工作上和前端的程序员对接的地方越来越多的使用JSON了。 还好有以前小组长留下的JSONCPP项目代码,作为参考。 也是学了好长时间,才学会怎么使用JSONCPP,但也不是很熟悉。遇到需求,边做边学,一点点完善吧。 什么是JSON? 直接去看百度百科和别人博客是怎么介绍的吧,我就不写了。 https://baik...