一系统运行级别文件

文件路径:/etc/inittab

文件作用说明:定义系统启动后,自动开启哪些软件程序系统

runlevel 查看当前运行级别

centos6系统运行级别: 7个级别
 
   0   -- 系统关机级别    init 0
   1   -- 系统单用户级别

用于破解系统密码root,救援恢复系统数据,没有网络服务
                      
   2   -- 系统多用户级别  没有网络多用户级别 
   3   -- 系统多用户级别  拥有网络多用户级别,生产中使用最多  
   4   -- 未使用级别
   5   -- 系统图形化级别  
   6   -- 系统重启级别    init 6

(一)查看当前运行级别

  1. [root@centos61 ~]# cat /etc/redhat-release
  2. CentOS release 6.8 (Final)
  3. [root@centos61 ~]# runlevel
  4. N
  1. [root@centos71 ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.6. (Core)
  3. [root@centos71 ~]# runlevel
  4. N

(二)centos6设置系统级别

临时设置:init   级别数字

  1. [root@centos61 ~]# cat /etc/inittab
  2. # inittab is only used by upstart for the default runlevel.
  3. #
  4. # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
  5. #
  6. # System initialization is started by /etc/init/rcS.conf
  7. #
  8. # Individual runlevels are started by /etc/init/rc.conf
  9. #
  10. # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
  11. #
  12. # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
  13. # with configuration in /etc/sysconfig/init.
  14. #
  15. # For information on how to write upstart event handlers, or how
  16. # upstart works, see init(), init(), and initctl().
  17. #
  18. # Default runlevel. The runlevels used are:
  19. # - halt (Do NOT set initdefault to this)
  20. # - Single user mode
  21. # - Multiuser, without NFS (The same as , if you do not have networking)
  22. # - Full multiuser mode
  23. # - unused
  24. # - X11
  25. # - reboot (Do NOT set initdefault to this)
  26. #
  27. id::initdefault:

此时断开远程连接

  1. [root@centos61 ~]# init
  2. [root@centos61 ~]#
  3. Connection closed by foreign host.
  4.  
  5. Disconnected from remote host(centos61) at ::.
  6.  
  7. Type `help' to learn how to use Xshell prompt.
  8. [c:\~]$

永久设置

对配置文件/etc/inittab修改

可以使用小工具进行修改,比如sed,awk,强化练习

  1. [root@centos61 ~]# sed -i s/::/::/g /etc/inittab
  2. [root@centos61 ~]# tail - /etc/inittab
  3. id::initdefault:
  1. [root@centos61 ~]# runlevel
  2. S
  3. [root@centos61 ~]# reboot
  4.  
  5. Broadcast message from root@centos61.huawei.com
  6. (/dev/pts/) at : ...
  7.  
  8. The system is going down for reboot NOW!
  9. [root@centos61 ~]#
  10. Connection closed by foreign host.
  11.  
  12. Disconnected from remote host(centos6-) at ::.
  13.  
  14. Type `help' to learn how to use Xshell prompt.

注意还要执行init  3才可以的

  1. [root@centos61 ~]# runlevel
  2. S

(三)centos7设置系统级别

和centos6有区别,使用target模式

  1. [root@centos7 ~]# ll /usr/lib/systemd/system/runlevel*target
  2. lrwxrwxrwx. 1 root root 15 Nov 26 17:33 /usr/lib/systemd/system/runlevel0.target -> poweroff.target
  3. lrwxrwxrwx. 1 root root 13 Nov 26 17:33 /usr/lib/systemd/system/runlevel1.target -> rescue.target
  4. lrwxrwxrwx. 1 root root 17 Nov 26 17:33 /usr/lib/systemd/system/runlevel2.target -> multi-user.target
  5. lrwxrwxrwx. 1 root root 17 Nov 26 17:33 /usr/lib/systemd/system/runlevel3.target -> multi-user.target
  6. lrwxrwxrwx. 1 root root 17 Nov 26 17:33 /usr/lib/systemd/system/runlevel4.target -> multi-user.target
  7. lrwxrwxrwx. 1 root root 16 Nov 26 17:33 /usr/lib/systemd/system/runlevel5.target -> graphical.target
  8. lrwxrwxrwx. 1 root root 13 Nov 26 17:33 /usr/lib/systemd/system/runlevel6.target -> reboot.target
  9. [root@centos7 ~]# runlevel
  10. N
  1. [root@centos71 ~]# ll /usr/lib/systemd/system/multi-user.target
  2. -rw-r--r--. root root Oct /usr/lib/systemd/system/multi-user.target
  3. [root@centos71 ~]# ll /usr/lib/systemd/system/rescue.target
  4. -rw-r--r--. root root Oct /usr/lib/systemd/system/rescue.target
  5. [root@centos71 ~]# cat /usr/lib/systemd/system/multi-user.target
  6. # This file is part of systemd.
  7. #
  8. # systemd is free software; you can redistribute it and/or modify it
  9. # under the terms of the GNU Lesser General Public License as published by
  10. # the Free Software Foundation; either version 2.1 of the License, or
  11. # (at your option) any later version.
  12.  
  13. [Unit]
  14. Description=Multi-User System
  15. Documentation=man:systemd.special()
  16. Requires=basic.target
  17. Conflicts=rescue.service rescue.target
  18. After=basic.target rescue.service rescue.target
  19. AllowIsolate=yes
  20.  
  21.  
  22. [root@centos71 ~]# cat /usr/lib/systemd/system/rescue.target
  23. # This file is part of systemd.
  24. #
  25. # systemd is free software; you can redistribute it and/or modify it
  26. # under the terms of the GNU Lesser General Public License as published by
  27. # the Free Software Foundation; either version 2.1 of the License, or
  28. # (at your option) any later version.
  29.  
  30. [Unit]
  31. Description=Rescue Mode
  32. Documentation=man:systemd.special()
  33. Requires=sysinit.target rescue.service
  34. After=sysinit.target rescue.service
  35. AllowIsolate=yes
  36.  
  37. [Install]
  38. Alias=kbrequest.target
   
 
临时设置:   init 级别数字
 
 
 
 
 
 

永久设置

 
在6版本的默认配置文件写明了
  1. [root@centos71 ~]# cat /etc/inittab
  2. # inittab is no longer used when using systemd.
  3. #
  4. # ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
  5. #
  6. # Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
  7. #
  8. # systemd uses 'targets' instead of runlevels. By default, there are two main targets:
  9. #
  10. # multi-user.target: analogous to runlevel
  11. # graphical.target: analogous to runlevel
  12. #
  13. # To view current default target, run:
  14. # systemctl get-default
  15. #
  16. # To set a default target, run:
  17. # systemctl set-default TARGET.target
 
 
 
  
 
 
 
 

 
输入系统设置的口令即可
 
 
 
 

 
 
 
 
实现远程连接,切换级别
 
 
 
 

 
 
 
 
 
 
 
 
 

二系统登录前后提示文件

 
 

(一)登录系统前显示提示信息

文件路径: /etc/issue     /etc/issue.net
  
  1. [root@centos71 ~]# ll /etc/issue*
  2. -rw-r--r--. root root Nov /etc/issue
  3. -rw-r--r--. root root Nov /etc/issue.net
  4. [root@centos71 ~]# cat /etc/issue*
  5. \S
  6. Kernel \r on an \m
  7.  
  8. \S
  9. Kernel \r on an \m
  10. [root@centos71 ~]# cat /etc/issue
  11. \S
  12. Kernel \r on an \m
  13.  
  14. [root@centos71 ~]# cat /etc/issue.net
  15. \S
  16. Kernel \r on an \m
  17. [root@centos71 ~]#
文件内容没有多大区别
  1. [root@centos71 ~]# diff /etc/issue*
  2. 3d2
  3. <
  4. [root@centos71 ~]# wc /etc/issue.net
  5. /etc/issue.net
  6. [root@centos71 ~]# wc /etc/issue
  7. /etc/issue
 
 
 
 
 
 
 

(二)登录系统后显示提示信息

文件路径: /etc/motd
 默认没有内容,可以添加有意义的
 
  1. [root@centos61 ~]# ll /etc/motd
  2. -rw-r--r--. root root Jan /etc/motd
 
 
  1. [root@centos71 ~]# cat /etc/motd
  2. (@@) ( ) (@) ( ) @@ () @ O @ O @
  3. ( )
  4. (@@@@)
  5. ( )
  6.  
  7. (@@@)
  8. ==== ________ ___________
  9. _D _| |_______/ \__I_I_____===__|_________|
  10. |(_)--- | H\________/ | | =|___ ___| _________________
  11. / | | H | | | | ||_| |_|| _| \_____A
  12. | | | H |__--------------------| [___] | =| |
  13. | ________|___H__/__|_____/[][]~\_______| | -| |
  14. |/ | |-----------I_____I [][] [] D |=======|____|________________________|_
  15. __/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__|__________________________|_
  16. |/-=|___|=O=====O=====O=====O |_____/~\___/ |_D__D__D_| |_D__D__D_|
  17. \_/ \__/ \__/ \__/ \__/ \_/ \_/ \_/ \_/ \_/
 
 
 
  1. [root@centos71 ~]# ll /etc/motd
  2. -rw-r--r--. root root Dec : /etc/motd
 
 
 
 
 
 
 
 
 
 
 
 

三系统主机名配置文件

文件路径信息:/etc/hostname
文件作用说明:修改主机名称
 
 
PS:企业需求,统计主机信息==资产管理
PS可以理解为多说一句,plus  say
主机信息包括主机名称、主机网络地址、主机品牌型号、主机CPU、主机内存、主机存储信息
主机名称: 区域-机房-机柜号码-机器编号 BJ - pbs-010203  - 01

 
 
 
 
 
 

(一)centos6/7系统主机名称临时修改

hostname

  1. [root@centos61 ~]# hostname
  2. centos61.huawei.com
  3. [root@centos61 ~]# hostname centos6.com
  4. [root@centos61 ~]# exit
  5. logout
  6.  
  7. Connection closed by foreign host.
  8.  
  9. Disconnected from remote host(centos6-) at ::.
  10.  
  11. Type `help' to learn how to use Xshell prompt.
  12. [c:\~]$
  13.  
  14. Connecting to 10.0.0.61:...
  15. Connection established.
  16. To escape to local shell, press Ctrl+Alt+].
  17.  
  18. Last login: Thu Dec :: from 10.0.0.1
  19. [root@centos6 ~]# hostname
  20. centos6.com

文件内容没有变化

  1. [root@centos6 ~]# cat /etc/sysconfig/network
  2. NETWORKING=yes
  3. HOSTNAME=centos61.huawei.com
centos7的方法一样

  1. [root@centos7 ~]# hostname centos7.jd.com
  2. [root@centos7 ~]# exit
  3. logout
  4.  
  5. Connection closed by foreign host.
  6.  
  7. Disconnected from remote host(centos7-1) at 09:58:58.
  8.  
  9. Type `help' to learn how to use Xshell prompt.
  10. [c:\~]$ ssh 10.0.0.72
  11.  
  12. Connecting to 10.0.0.200:22...
  13. Connection established.
  14. To escape to local shell, press Ctrl+Alt+].
  15.  
  16. WARNING! The remote SSH server rejected X11 forwarding request.
  17. Last login: Wed Dec 4 08:27:57 2019 from 10.0.0.1
  18. [root@centos7 ~]# hostname
  19. centos7.jd.com
  20. [root@centos7 ~]# cat /etc/hostname
  21. centos7.com
   
 
 
 
 
 
 

(二)centos6系统主机名称永久修改

注意修改之后要重启,注销没用

  1. [root@centos6 ~]# hostname
  2. centos6.com
  3. [root@centos6 ~]# cat /etc/sysconfig/network
  4. NETWORKING=yes
  5. HOSTNAME=centos61.com
  6. [root@centos6 ~]# exit
  7. logout
  8.  
  9. Connection closed by foreign host.
  10.  
  11. Disconnected from remote host(centos6-) at ::.
  12.  
  13. Type `help' to learn how to use Xshell prompt.
  14. [c:\~]$
  15.  
  16. Connecting to 10.0.0.61:...
  17. Connection established.
  18. To escape to local shell, press Ctrl+Alt+].
  19.  
  20. Last login: Thu Dec :: from 10.0.0.1
  21. [root@centos6 ~]# hostname
  22. centos6.com

重启之后变成了centos61

  1. [root@centos6 ~]# hostname
  2. centos6.com
  3. [root@centos6 ~]# reboot
  4.  
  5. Broadcast message from root@centos6.com
  6. (/dev/pts/) at : ...
  7.  
  8. The system is going down for reboot NOW!
  9. [root@centos6 ~]#
  10. Connection closed by foreign host.
  11.  
  12. Disconnected from remote host(centos6-) at ::.
  13.  
  14. Type `help' to learn how to use Xshell prompt.
  15. [c:\~]$
  16.  
  17. Connecting to 10.0.0.61:...
  18. Connection established.
  19. To escape to local shell, press Ctrl+Alt+].
  20.  
  21. Last login: Thu Dec :: from 10.0.0.1
  22. [root@centos61 ~]# hostname
  23. centos61.com
  24. [root@centos61 ~]# cat /etc/sysconfig/network
  25. NETWORKING=yes
  26. HOSTNAME=centos61.com

(三)centos7系统主机名称永久修改

要修改两处

  1. [root@centos71 ~]# cat /etc/hostname
  2. centos71.com
  3. [root@centos71 ~]# sed -i s@@@g /etc/hostname
  4. [root@centos71 ~]# cat /etc/hostname
  5. centos7.com
  6. [root@centos71 ~]# hostnamectl set-hostname centos7.com
 
  1. [c:\~]$
  2.  
  3. Connecting to 10.0.0.200:...
  4. Connection established.
  5. To escape to local shell, press Ctrl+Alt+].
  6.  
  7. WARNING! The remote SSH server rejected X11 forwarding request.
  8. Last login: Thu Dec :: from 10.0.0.1
  9. [root@centos7 ~]# host
  10. -bash: host: command not found
  11. [root@centos7 ~]# hostname
  12. centos7.com
 
 
 
 

Linux系统重要文件(三)的更多相关文章

  1. Linux系统中文件定位与查找

    Linux系统中文件查找 关键词 文件查找 | find | locate 本文主要介绍有关文件查找的两个命令——find和locate,以及压缩打包的命令——compress, gzip,bzip2 ...

  2. Linux系统初学-第三课 Linux网络配置1

    Linux系统初学-第三课 Linux网络配置 1.动态IP配置 配置文件路径 /etc/sysconfig/network-scripts/ ls查看网卡eth0,其中HWADDR值得获取:ifco ...

  3. Linux系统重要文件(二)

    Linux系统重要文件概述 一系统自动挂载文件 文件路径信息:/etc/fstab文件作用说明:实现存储设备自动挂载 [root@centos7 ~]# cat /etc/fstab # # /etc ...

  4. Linux系统重要文件

    Linux系统重要文件介绍与配置 一网卡配置文件 (一)网卡配置文件参数介绍 文件路径信息:/ec/sysconfig/network-scripts/ifcfg-eth0 文件作用说明:配置网卡地址 ...

  5. 实验二:Linux系统简单文件操作命令

    項目 内容 这个作业属于哪个课程() 课程链接 这个作业的要求在哪里 实验要求 学号-姓名 17043133-木腾飞 作业学习目标 学习在Linux系统终端下进行命令行操作: 学习掌握常用命令行操作并 ...

  6. Linux系统下文件压缩与打包命令

    Linux系统下文件压缩与打包命令 常用的压缩文件拓展名 * .Z * .zip * .gz * .bz2 * .xz * .tar * .tar.gz * .tar.bz2 * .tar.xz 压缩 ...

  7. Linux系统编程--文件IO操作

    Linux思想即,Linux系统下一切皆文件. 一.对文件操作的几个函数 1.打开文件open函数 int open(const char *path, int oflags); int open(c ...

  8. 树莓派与Linux系统之间文件传输

    最近因为要学习Python,于是把放在家里接了一年灰的树莓派又给搜出来了,刚买那会也捣鼓了好一阵子, 基本操作都学会了,但现在又忘光了,只能又从头开始搞了,首先第一个要解决的是怎么把文件从电脑传输到树 ...

  9. Linux学习笔记之二————Linux系统的文件和目录

    一.Windows和Linux文件系统区别 1.在 windows 平台下,打开“计算机”,我们看到的是一个个的驱动器盘符: 每个驱动器都有自己的根目录结构,这样形成了多个树并列的情形,如图所示:  ...

  10. linux系统——hosts文件修改

    1. 关于/etc/host,主机名和IP配置文件 Hosts - The static table lookup for host name(主机名查询静态表) Linux 的/etc/hosts是 ...

随机推荐

  1. BZOJ 5170: Fable

    离散化+树状数组 求当前位之前是否有k位比它大 这样的话它就需要前移k位 剩下的按照原来的顺序依次填入 其实我觉得sort一下就可以做出来了 太久没写树状数组了 所以写了一下树状数组 #include ...

  2. TODO 思维模型 尺子 游标卡尺

    100个人 两个思维切入点 1>做对的题怎么分配 m(x)表示答对x道题的最多人数f(x)表示答对x道题的人数 m(0)=5m(1)=20=>f(0)=0m(2)=m(1)+1=21=&g ...

  3. mysql_DML_select_聚合join

    聚合函数: select avg(salary)//平均值 from wsb; select sum(salary)//总和 from wsb; select max(salary)//最大 from ...

  4. Jmeter接口测试报告模板优化

    优化后在接口报告的接口信息中,直接展示url,method,结果和响应时间,详情中展示请求和响应数据.具体如下: 模板文件 jmeter-results-detail-report_21.xsl: & ...

  5. EF框架之——Code First以及踩过的这些“坑”

    传送门 Code First使用步骤 Code First报错和解决办法 以前在上海做了一段时间的Asp.net,基本用的都是.net自带的EF框架连接数据库,不过都是用的Model First,最近 ...

  6. 聊聊redis的监控工具

    序 本文主要研究一下redis的监控工具 redis-stat redis-stat是一个比较有名的redis指标可视化的监控工具,采用ruby开发,基于redis的info命令来统计,不影响redi ...

  7. crontab自动执行任务,失败原因记录

    服务器上使用crontab部署这两个每分钟自动执行的命令.首先,这两个命令是之前的人部署的,在我接手之前,就一直在了的.根据命令,实际上应该是做到每分钟都执行一次脚本.但是实际操作中,却发现,其实并没 ...

  8. C++ bitset的使用

    bitset 一般代替 bool 数组使用,常用于优化空间,因为 bitset 中一个元素只占 1 bit. bitset 的大小在定义使就需要确定.如果想要不定长的 bitset,就需要使用 vec ...

  9. Winsows10-1909正式版原版下载资料

    [简体中文版] 一.win10 1909消费者版(零售版),含家庭版.家庭单语言版.教育版.专业版.专业教育版.专业工作站版 (6个版本) 1.64位系统:Windows 10 (consumer e ...

  10. HTML5-Classlist样式操作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...