第一步

首先登录系统,创建root用户的密码

在终端输入命令:

sudo passwd root

然后输入设置的密码,这样就完成了设置root用户密码的步骤

第二步

修改文件

sudo nano /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf   #管理员nano命令编辑'50-ubuntu.conf'

在文件末尾增加如下两行:

greeter-show-manual-login=true'
all-guest=false

如下:

[Seat:*]
user-session=ubuntu
greeter-show-manual-login=true
all-guest=false

第三步

修改 /etc/pam.d/gdm-autologin和 /etc/pam.d/gdm-password文件

sudo nano /etc/pam.d/gdm-autologin #管理员nano编辑'gdm-autologin'文件

注释掉auth required pam_succeed_if.so user != root quiet_success这一行(第三行左右)

文件配置可参考以下:

#%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 cl$
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.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so op$
session optional pam_keyinit.so force revoke
session required pam_limits.so
session required pam_env.so readenv=1
session required pam_env.so readenv=1 user_readenv=1 envfile=/etc/default/locale
@include common-session
session optional pam_gnome_keyring.so auto_start
@include common-password

sudo nano /etc/pam.d/gdm-password #管理员nano编辑'gdm-password'文件

注释掉 auth required pam_succeed_if.so user != root quiet_success这一行(第三行左右)

文件配置可参考以下:

#%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 cl$
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.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so op$
session optional pam_keyinit.so force revoke
session required pam_limits.so
session required pam_env.so readenv=1
session required pam_env.so readenv=1 user_readenv=1 envfile=/etc/default/locale
@include common-session
session optional pam_gnome_keyring.so auto_start
@include common-password

第四步

修改/root/.profile文件

sudo nano /root/.profile #管理员nano编辑'.profile'文件

将文件末尾的mesg n || true这一行修改成

tty -s&&mesg n || true

文件配置可参考以下:

# ~/.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

第五步

sudo gedit /etc/ssh/sshd_config #管理员nano编辑'sshd_config'文件

#PermitRootLogin prohibit-password

下添加:PermitRootLogin yes

文件配置可参考以下:

#       $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin # The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value. #Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress :: #HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key # Ciphers and keying
#RekeyLimit default none # Logging
#SyslogFacility AUTH
#LogLevel INFO # Authentication: #LoginGraceTime 2m
#PermitRootLogin prohibit-password

最后重启系统

Linux实战(14):Ubuntu修改root默认登陆的更多相关文章

  1. Ubuntu无法使用root用户登陆的解决办法

    对于一个新安装的Ubuntu操作系统,经常会遇到无法使用root用户ssh连接操作系统,比如说root用户的密码被拒绝等原因. 面对这种问题,介绍一下Ubuntu无法使用root登陆解决 1. 修改 ...

  2. mysql5.7.11修改root默认密码

    知道 MySQL 出了5.7了,并且网上说性能提高了一两倍,于是在虚拟机上安装了个 CentOS 7,在上面安装 MySQL 5.7 我使用的是 yum安装方式,要求虚拟机能够上网,因为它会在线下载安 ...

  3. mysql5.7系列修改root默认密码

    操作系统为centos7 64 1.修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1 这一行配置让 mysqld 启动时不对密码进行验证 2. ...

  4. linux 登录失败,修改root密码

      开机按下 esc  重启系统后出现GRUB界面在引导装载程序菜单上,用上下方向键选择你忘记密码的那个系统键入“e” 来进入编辑模式.   接下来你可以看到如下图所示的画面,然后你再用上下键选择最新 ...

  5. 【Linux】Ubuntu修改root用户密码

    使用vmware安装ubuntu的时候,安装完之后发现没有root用户密码,只有新建用户,这个时候需要重新设置root用户密码 在新建用户下面运行 sudo passwd root

  6. linux修改root用户登陆密码

    如果不是以root用户登录的,请先切换到root用户下, 执行命令:su root 然后按提示输入root用户的密码. 英文系统: [root@localhost ~]# passwd Changin ...

  7. (转)Linux SSH配置和禁止Root远程登陆设置

    原文 一.修改vi /etc/ssh/sshd_config 文件 1.修改默认端口:默认Port为22,并且已经注释掉了:修改是把注释去掉,并修改成其它的端口. 2.禁止root用户远程登陆:修改P ...

  8. Ubuntu修改mysql默认编码的方法

    ubuntu使用apt-get安装mysql后,server的默认编码是latin1,下面把server的编码修改成utf8. 编码相关信息: 1 2 3 4 5 6 7 8 9 10 11 12 1 ...

  9. ubuntu 修改root密码

    重新安装过ubuntu 14.04后,切换到root权限,需要输入密码,输入n次都不对. 也没有记得设置过密码. 百度一下,得到方法如下,已经验证测试成功. 命令为: sudo passwd 提示输入 ...

随机推荐

  1. 遍历数组,对象和JSON

    遍历数组 var arr2 = [3,4,5,6,7,8]; //第一种方法 for(var i =0;i<arr.length;i++){ console.log(arr2[i]); } // ...

  2. windows服务器下,mysql运行一段时间之后忽然无法连接,但是mysql服务启动正常

    出现这种情况以前都是重启服务器可以解决,但是治标不治本,一段时间之后仍然会出现此问题. 此问题不是mysql应用程序的问题而是windows server system 的配置问题.因此需要修改win ...

  3. 洛谷P1057 传球游戏 完美错觉(完美错解)

    //作者:pb2 博客:https://www.luogu.com.cn/blog/pb2/ 或 http://www.cnblogs.com/p2blog //博客新闻1:"WPS开机自启 ...

  4. C++判断是回文串还是镜像串

    #include <iostream> #include <string> #include <cstdio> #include <cctype> #p ...

  5. linux驱动之模块化驱动Makefile

    本文摘自http://blog.csdn.net/lufeiop02/article/details/6446343 Linux驱动一般以模块module的形式来加载,首先需要把驱动编译成模块的形式. ...

  6. springSecurity初识-练气初期

    1.写在前面 Spring Security是一个框架,提供针对常见攻击的身份验证,授权和保护.通过对命令式和反应式应用程序的一流支持,它是保护基于Spring的应用程序的事实标准. Spring S ...

  7. 算法-图(2)Bellman-Ford算法求最短路径

    template <class T,class E> void Bellman-Ford(Graph<T,E>&G, int v, E dist[], int path ...

  8. 第1篇 Scrum 冲刺博客

    每个成员在Alpha阶段认领的任务 钟智锋 内容 工时 客户端请求对局 1h 客户端请求移动/使用锦囊/技能/进化 1h 把对局信息转换成可传播的信息 2h 客户端通信 3h 编写博客和文档 1h 岑 ...

  9. Kernel methods on spike train space for neuroscience: a tutorial

    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! 时序点过程:http://www.tensorinfinity.com/paper_154.html Abstract 在过去的十年中,人 ...

  10. [PyTorch 学习笔记] 2.1 DataLoader 与 DataSet

    thumbnail: https://image.zhangxiann.com/jeison-higuita-W19AQY42rUk-unsplash.jpg toc: true date: 2020 ...