Linux普通用户修改root密码和基本操作

Linux系统root密码修改
普通用户给root用户修改密码

**密码
1.Reboot the system.
2.Interrupt the boot loader count down by pressing anykey.
3.Move the cursor to the entry that needs to be booted.
4.Press “e” to edit the select edentry.
5.Move the cursor to the kernel command line(the line that start swith linux16.
6.Append rd.break
7.Press Ctrl+x to start.
8.Remount /sysroot as read-write.
switch_root:/# mount -o remount,rw /sysroot

9.Switch into a chroot jail, where /sysroot is treated as the root of the filesystem tree
switch_root:/# chroot /sysroot
10.Set a new root password:
sh-4.2# passwd [root] (change the root password)
or
sh-4.2# passwd -d root (delete the root password)
11.Make sure that all unlabeled files (including/etc/shadow at this point)get relabeled during boot.
sh-4.2# touch /.autorelabel
12. sh-4.2# exit
13. switch_root:/# exit

**root密码操作步骤:
1、重启虚拟机
2、在linux16末尾加上 rd.break,ctrl+x执行
3、mount -o remount,rw /sysroot
4、chroot /sysroot
5、passwd root
6、输入新密码:
7、确认密码
8、touch /.autorelabel
9、exit
10、exit

重启虚拟机摁键盘(e)键
Linux普通用户修改root密码和基本操作
到此页面
Linux普通用户修改root密码和基本操作

找到红色横线,然后空一格输入 rd.break,ctrl+x执行
Linux普通用户修改root密码和基本操作
Linux普通用户修改root密码和基本操作
用行到此页面,然后按照以下输入
mount -o remount,rw /sysroot
chroot /sysroot
passwd
输入新密码
确认密码
touch /.autorelabel
exit
exit
Linux普通用户修改root密码和基本操作
基本操作
打开终端 单击右键 点击 Open in Terminal
输入dhclient//获取IP地址
Linux普通用户修改root密码和基本操作
输入 ip a //查看IP地址
IP地址为192.168.209.128/24
Linux普通用户修改root密码和基本操作
再输入dhclient // 查看进程的***
输入kill -9 ***//强制终止进程
Linux普通用户修改root密码和基本操作
Linux普通用户修改root密码和基本操作
使用Xshell6
输入ssh IP地址 或者ssh 用户名@IP地址//远程连接虚拟机
Linux普通用户修改root密码和基本操作
输入用户名和密码
Linux普通用户修改root密码和基本操作
Linux普通用户修改root密码和基本操作
输入hostnamectl set-hostname 新主机名//修改主机名

Linux普通用户修改root密码和基本操作
Linux普通用户修改root密码和基本操作
在虚拟机中输入pwd//查看当前工作目录
Linux普通用户修改root密码和基本操作
输入mkdir xixi//创建文件夹xiix
Linux普通用户修改root密码和基本操作
切换目录 cd
1.绝对路径(以/开头的路径):cd /home/xixi
Linux普通用户修改root密码和基本操作
2.相对路径(以./开头的路径):cd / cd home cd xixi

修改密码:passwd 用户名 直接输入passwd修改当前用户的密码
删除密码:passwd -d 用户名
root用户:不需要输入原密码,可以不符合密码复杂性规则,可以给任何人修改密码
普通用户:需要输入原密码,必须符合密码复杂性规则,passwd修改密码无法指定用户