使用单用户模式修改root密码
解析映射文件
/root/etc/hosts
C:\Windows\System32\drivers\etc
本地的DNS
例子:192.168.15.101 www.baidu.com
/etc/resolv.conf
用于设置DNS解析地址(网卡中卑职优于此文件配置)
/etc/hosts
用于设置DNS域名与IP地址对应关系
/etc/sysconfig/network
配置主机名称信息 永久生效
磁盘挂载文件
/etc/fstab
实现指定设备文件信息 进行开机自动挂载
开机加载脚本
/etc/rc.local
1.编辑开机自启动脚本
vim /etc/rc.local
2.设置开机自启动权限
chmod +x /etc/rc.d/rc.local
3.重启系统
开机加载脚本
# 启动级别文件
# 作用:设置启动系统启动级别
0 关机
1 单用户模式
2 多用户模式(无网络)
3 完全多用户模式
4 待定
5 桌面模式
6 重启
设置系统级别:
init [编号] 临时设置
systemctl set-default [系统启动级别]
通过单用户模式修改密码
1.重启
2.在选择系统内核界面,按e键进入单用户模式
3.找到 linux16 开头行,删除 ro , 并且在 ro 处添加 rw init=/sysroot/bin/sh
4.按 ctrl + x 进行系统重新引导
5.执行 chroot /sysroot
6.执行 passwd root
7.执行 touch /.autorelabel
8.执行 ctrl + d重启系统
变量加载文件
在linux中添加环境变量怎么添加呢?
文件
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bash_rc
文件夹
/etc/profile.d/
增加环境变量有两种方式:
1.临时添加
2.永久添加
增加环境变量的格式:
export PYTHON_HOME='D:/python'
查看本机的环境变量:
echo $PYTHON_HOME : 查看某一个环境变量
printenv : 查看所有的环境变量
读取环境变量的几种情况,并且测试出使用文件的先后顺序
1、重启
/etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile
2、切换用户
/etc/profile.d --> /etc/bashrc --> ~/.bashrc
知识储备:
useradd [用户名]
su [用户名]
3、重新登录用户
1、su - [用户名]
/etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile
2、ssh root@192.168.15.101
/etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile
登录提示文件
登录成功之后显示的信息
/etc/motd
登录之前显示的信息。
/etc/issue
编译安装目录
# 安装第三方软件的目录
/user/local
下载rpm安装包
yum安装python:yum install python3
系统日志目录
/var
保存系统运行状态的目录
保存CPU运行状态的:/proc/cpuinfo
lscpu
保存内存的状态的:/proc/meminfo
free
保存系统负载的:/proc/loadavg
w
0.00 : 1分钟内的CPU负载
0.01 : 5分钟内的CPU负载
0.05 :15分钟内的CPU负载
负载:当前系统的所有进程占用CPU的时间比
保存系统挂载信息:/proc/mounts
mount
umount