码迷,mamicode.com
首页 > 系统相关 > 详细

【第四课】Linux的基础命令使用

时间:2019-01-22 10:42:17      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:passwd   update   auth   系统运行级别   操作系统   level   运行级别   root   密钥   

目录

一、passwd重置密码

root用户,直接执行 passwd 回车 输入两次新密码即可
普通用户,也可以改。 passwd username
user1登录后,改自己密码,只需要执行 passwd 即可

[root@localhost ~]# passwd root    #修改root用户密码
Changing password for user root.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

[root@localhost ~]# useradd user1    #增加普通用户
[root@localhost ~]# passwd user1    #修改普通用户密码
Changing password for user user1.
New password: 
BAD PASSWORD: The password is a palindrome
Retype new password: 
passwd: all authentication tokens updated successfully.

二、单用户模式

当我们忘记了密码,也没有密钥,该怎么办呢???Linux系统提供了一种单用户模式。单用户模式是Centos 7系统的一个运行级别。那么什么是运行级别呢?
运行级别就是操作系统当前正在运行的功能级别,级别是从0到6。Centos7系统之前的版本是通过/etc/inittab文件来定义系统运行级别:

[root@localhost ~]#  cat /etc/centos-release 
CentOS release 6.4 (Final)
[root@localhost ~]#  cat /etc/inittab 
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)    # 运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动
#   1 - Single user mode                               #  运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)    # 运行级别2:多用户状态(没有NFS)
#   3 - Full multiuser mode                           #   运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式
#   4 - unused                                               #   运行级别4:系统未使用,保留
#   5 - X11                                                    #   运行级别5:X11控制台,登陆后进入图形GUI模式
#   6 - reboot (Do NOT set initdefault to this)    #   运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动
# 
id:3:initdefault:    # 表示运行级别3,是默认的

CentOS 7 版本不再使用该文件定义系统运行级别,相关运行级别设置无效:

[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 
[root@localhost ~]# cat /etc/inittab 
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:    #查看当前运行级别使用如下命令
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target    #设置默认运行级别,使用如下命令
#

【第四课】Linux的基础命令使用

标签:passwd   update   auth   系统运行级别   操作系统   level   运行级别   root   密钥   

原文地址:https://www.cnblogs.com/linuxk/p/10302009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!