Linux 文件系统和改root密码

内容概要

  • 系统中重要的文件系统
  • 使用单用户模式修改root密码

内容概要

解析映射文件

            Linux系统中	/etc/hosts
            Windows系统	C:\Windows\System32\drivers\etc\hosts

磁盘挂载文件

            /etc/fstab		磁盘挂载文件

开机加载脚本

            /etc/rc.local
            1.编辑开机自启动脚本
            vim /etc/rc.local

            2.设置开机自启动权限
            chmod +x /etc/rc.d/rc.local

            3.重启系统
            reboot

单用户模式修改root密码


            系统启动级别:
                0	关机
                1	单用户模式
                2	多用户无网络模式
                3	多用户模式
                4	待定
                5	桌面模式
                6	重启

            设置系统级别
                init [编号]		临时设置
                systemctl set-default [系统启动级别]


            修改root密码

            1.重启
            2.在启动选择系统内核界面, 按 e 键进入单用户模式
            3.找到 Linux16 开头的行, 删除 ro , 添加 rw init=/sysroot/bin/sh
            4.按 Ctrl + x 键进入系统重新引导
            5.执行 chroot /sysroot
            6.执行 passwd root 输入密码
            7.执行 touch /.autorelable
            8.执行 reboot 重启

变量加载文件

            在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
            3、重新登录用户
                su - [用户名]
                /etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile

                ssh root@192.168.15.99
                /etc/profile.d --> /etc/profile --> /etc/bashrc --> ~/.bashrc --> ~/.bash_profile

登录提示文件

            登录成功之后显示的信息
            /etc/motd

            例如:
                             _ooOoo_
                              o8888888o
                              88" . "88
                              (| -_- |)
                              O\  =  /O
                           ____/`---'\____
                         .'  \\|     |//  `.
                        /  \\|||  :  |||//  \
                       /  _||||| -:- |||||-  \
                       |   | \\\  -  /// |   |
                       | \_|  ''\---/''  |   |
                       \  .-\__  `-`  ___/-. /
                     ___`. .'  /--.--\  `. . __
                  ."" '<  `.___\_<|>_/___.'  >'"".
                 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
                 \  \ `-.   \_ __\ /__ _/   .-` /  /
            ======`-.____`-.___\_____/___.-`____.-'======
                               `=---='
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            *         佛祖保佑       永无BUG	    *	
            *********************************************




            登录之前显示的信息
            /etc/issue


编译安装目录

            安装第三方软件的目录
            /usr/local

            下载rpm安装包
            yum install python3 -y

系统目录日志

            /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
posted @ 2021-12-13 16:31  风花雪月*  阅读(266)  评论(0编辑  收藏  举报