目录
网卡的配置文件
/etc/resolv.conf
# DNS 配置文件 重点
优先于 resolv.conf 如果网中配置了DNS 然后重启网卡 则会覆盖 resolv.conf 中的配置
如果网卡中不配置DNS 重启后 则不会覆盖 resolv.conf
网卡配置 修改网卡 必须重启
DNS1=114.114.114.114
DNS2=223.5.5.5
resolv.conf 中书写方式 直接生效
nameserver 223.5.5.5
工作中建议使用 resolv.conf
/etc/fstab
# 设置开机启动挂载的文件 设备和挂载点的一个对应表 file system table 重点
/etc/rc.local
开机自动启动,自动执行文件
chmod +x /etc/rc.d/rc.local 需要给源文件执行权限
chkconfig
通过chkconfig
命令可以给每个服务的各个运行级别设置自启动/关闭
chkconfig --list|grep xxx
:筛选查看xxx服务
示例
-
查看所有服务
-
[root@wcl ~]# chkconfig --list 注:该输出结果只显示 SysV 服务,并不包含 原生 systemd 服务。SysV 配置数据 可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。 jexec 0:关 1:开 2:开 3:开 4:开 5:开 6:关 mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关 netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关 network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
-
-
查看单个mysqld服务,有两种方式;
方式1:
chkconfig --list | grep 服务名
方式2:
chkconfig 服务名--list
-
//方式1: chkconfig --list | grep mysqld [root@wcl ~]# chkconfig --list | grep mysqld mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
-
// 方式2:chkconfig mysqld --list [root@wcl ~]# chkconfig mysqld --list mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
-
-
关闭mysqld服务运行级别5的服务
chkconfig --level 服务运行级别 服务名 on/off
:开启关闭某服务运行级别的服务-
[root@wcl ~]# chkconfig --level 5 mysqld off //关闭 [root@wcl ~]# chkconfig mysqld --list //查看验证是否成功关闭 mysqld 0:关 1:关 2:开 3:开 4:开 5:关 6:关
注意:
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。
-
上面指令中查询的结果出现这段内容,只因为我是在Centos7上面操作的原因。Centos7和之前的老版本差别较大。
细节注意:chkconfig重新设置服务后自启动或关闭,需要重启机器reboot才能生效。
-
查看sshd的服务运行状态:
service sshd status
-
显示当前系统中所有服务的各个运行级别的运行状态:
chkconfig --list
-
将sshd服务在运行级别5下设置为不自动启动:
chkconfig --level 5 sshd off
-
在所有运行级别下,关闭防火墙:
chkconfig iptables off
-
在所有运行级别下,开启防火墙:
chkconfig iptables on
chkconfig --del mysqld
:删除服务mysqld
chkconfig --add mysqld
:添加服务mysqld
chkconfig mysqld off
:所有运行级别下关闭服务mysqld
chkconfig mysqld on
:所有运行级别下开启服务mysqld
/etc/inittab
# run level 运行级别的配置文件 (6中) centos6.x centos7.x
运行级别
0 关机 poweroff.target
1 单用户模式(密码忘记,重新更改密码) rescue.target
2 多用户模式 没有NFS multi-user.target
3 完全多用户模式 (当前使用的模式) multi-user.target
4 未使用 待开发 multi-user.target
5 桌面模式 (需要安装DESKTOP) graphical.target
6 重启 reboot.target
c6如果设置启动级别
vim /etc/inittab
id:3:initdefault:
或者 init 6 重启系统了
c7 设置启动级别
查看运行级别
systemctl get-default
multi-user.target
设置
systemctl set-default runlevel5.target tab补全安装 yum -y install bash-completion.noarch
或者 init 6 重启系统了
/etc/issue
# 登录系统前的提示
/etc/issue.net
# 登录系统前的提示
> /etc/issue 清空文件
> /etc/issue.net 清空文件
/etc/motd
# 系统登录后的提示
/etc/redhat-release
重点 查看当前系统的版本
[root@oldboy ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
/etc/profile
# 环境变量的配置文件 重点
1)系统环境变量大写
2)环境变量大部分位置都可使用
3)name=oldboy 等号右边一堆内容 使用一个名字来代替 称为变量
[root@oldboy ~]# test="I am oldboy teacher I am 60"
[root@oldboy ~]# echo $test
I am oldboy teacher I am 60
PS1
/etc/bashrc
别名
ll ===== ls -l
给命令起了一个小名
浩达 -----> 好大
周玉强 -----> 强哥 old强 钢炮
11. ~/.bashrc 别名
12. ~/.bash_profile 环境变量
/etc/bashrc 全局生效 针对系统所有用户 国法 22 20 规定的年龄结婚
/etc/bash_profile 全局生效 针对系统所有用户 国法
~/.bashrc 局部生效 针对当前使用用户 家规 家里 男孩子 尽快抱孙子
~/.bash_profile 局部生效 针对当前使用用户 家规 家里 女孩子 不要过早谈恋爱
/usr/local
默认编译安装的软件放在此目录下
LANG
centos6:[root@centos6 ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
centos7:[root@executive ~]# cat /etc/locale.conf
LANG="en_US.UTF-8"
Linux系统管理-软件包管理
与windows安装各种应用程序相似,在linux下也可以安装各种需要的应用程序,通常称为软件包。
1. Rpm安装软件包
1. 什么是Rpm
RPM 是Red-Hat Package Manager(RPM软件包管理器)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是
其原始设计理念是开放式的是由红帽公司开发用于软件包的安装、升级、卸载、查询等操作。在主流的linux系统上,多数
软件的安装、升级、移除以及维护工作都是使用RPM软件包管理程序来完成的。
2. Rpm包介绍
zip-3.0-11.el7.x86_64.rpm #el7
zip-3.0-1.el6.x86_64.rpm #el6
yum-utils-1.1.31-50.el7.noarch.rp