第一步

首先登录系统,创建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. 漏洞重温之文件上传(FUZZ)

    文件上传FUZZ思路通关upload-labs Pass-16 黑盒阶段 进入第十六关,首先我们能看到,该页面的上传点为图片上传. 首先,先把对方想的简单一点,这里虽然是上传图片,但是可能只是前端js ...

  2. 使用folderLeft函数统计字母出现的次数

    实例:统计字符串中字母出现的次数 import scala.collection.mutable object Demo_018{ def main(args: Array[String]): Uni ...

  3. <抽奖奇遇>

     时间如同指间沙一般,转眼间一个月就过去了,今天是出去抽奖的日子,这种事情本来性格就淡漠的我不想去参和,怎奈老爸非让我去,我也感到很是无奈.我的运气一直都不好,所以就没抱什么希望,就当是出门去看看热闹 ...

  4. Jmeter 常用函数(7)- 详解 __time

    如果你想查看更多 Jmeter 常用函数可以在这篇文章找找哦 https://www.cnblogs.com/poloyy/p/13291704.html 作用 返回各种格式的当前时间 语法格式 ${ ...

  5. @SuppressWarnings注解用法详解(转)

    原文连接https://blog.csdn.net/sysware_carol/article/details/52100580 今天来谈谈@SuppressWarnings注解的作用. J2SE 提 ...

  6. 畅购商城(九):Spring Security Oauth2

    好好学习,天天向上 本文已收录至我的Github仓库DayDayUP:github.com/RobodLee/DayDayUP,欢迎Star,更多文章请前往:目录导航 畅购商城(一):环境搭建 畅购商 ...

  7. psutil 简单使用!

    psutil.cpu_percent() cpu 百分比 mem = psutil.virtual_memory()mem.total,mem.used mem.free psutil.cpu_cou ...

  8. Linux环境下如何生成core文件

    Linux环境下进程发生异常而挂掉,通常很难查找原因,但是一般Linux内核给我们提供的核心文件,记录了进程在崩溃时候的信息.但是生成core文件需要设置开关,具体步骤如下: 1.查看生成core文件 ...

  9. 操作系统-I/O(3)SPOOLing技术

    为了缓和CPU的高速性与I/O设备低速性间的矛盾而引入了脱机输入.输出技术.该技术是利用专门的外围控制机,将低速I/O设备上的数据传送到高速磁盘上:或者相反. 事实上,当系统中引入了多道程序技术后,完 ...

  10. 牛客网PAT练习场-有几个PAT

    题目地址:https://www.nowcoder.com/pat/6/problem/4066 题意:求pat->求pa->求p /** * *作者:YCute *时间:2019-12- ...