详解CentOS7系统初始化设置

梦墨酱_9544

梦墨酱_9544

2021-01-05

5929人浏览

转载

下面由centos教程栏目给大家介绍centos7系统初始化设置的方法,希望对需要的朋友有所帮助!

CentOS7系统初始化设置

2019年03月07日系统版本:CentOS Linux release 7.3-1611

1. 网络配置

使用 nmtui 图形工具配置IP地址和主机名

IP:192.168.82.103/24  
主机名:leanote.jmkf.com

也可以更改配置文件

[root@leanote ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=eb220f0e-779d-48c6-8e1b-093b2f9eff0f
DEVICE=ens32
ONBOOT=yes
IPADDR=192.168.55.58
PREFIX=24
IPADDR1=192.168.82.103
PREFIX1=24
GATEWAY=192.168.82.254
DNS1=192.168.94.201
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

2. 关闭防火墙

2.1 查看firewall

# systemctl status firewalld.service
[root@leanote ~]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since 五 2017-12-29 12:10:34 CST; 3s ago
     Docs: man:firewalld(1)
 Main PID: 11473 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─11473 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

12月 29 12:10:33 leanote.jmkf.com systemd[1]: Starting firewalld - dynamic firewall daemon...
12月 29 12:10:34 leanote.jmkf.com systemd[1]: Started firewalld - dynamic firewall daemon.

- 此状态表示防火墙处于开启状态 -

2.2 关闭firewall

# systemctl stop firewalld.service
[root@leanote ~]# systemctl stop firewalld.service

[root@leanote ~]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

12月 29 12:10:33 leanote.jmkf.com systemd[1]: Starting firewalld - dynamic firewall daemon...
12月 29 12:10:34 leanote.jmkf.com systemd[1]: Started firewalld - dynamic firewall daemon.
12月 29 13:43:31 leanote.jmkf.com systemd[1]: Stopping firewalld - dynamic firewall daemon...
12月 29 13:43:31 leanote.jmkf.com systemd[1]: Stopped firewalld - dynamic firewall daemon.

- 此状态表示防火墙处于关闭状态 -

2.3 禁止firewall开机启动

# systemctl enable firewalld.service    启用  
# systemctl disable firewalld.service   禁用
[root@leanote ~]# systemctl enable firewalld.service

Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/basic.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.

-----------------------------------------------------------------------------------------------------------------

[root@leanote ~]# systemctl disable firewalld.service

Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

3. 关闭SELINUX

[root@leanote ~]# setenforce 0      临时关闭

永久关闭需要修改SELINUX的配置文件  /etc/selinux/config

将SELINUX=enforcing 改为 SELINUX=disable
[root@leanote ~]# vi /etc/selinux/config  

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disable
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

4. 更改YUM源

可选 阿里云、网易云、其他网站 或者内网yum源
将 /etc/yum.repos.d/ 下的文件备份并下载相应repo文件

https://opsx.alibaba.com/mirror

4.1 备份

备份所有

# mkdir /etc/yum.repos.d/bak
# mv /etc/yum.repos.d/* /etc/yum.repos.d/bak

或者只备份 CentOS-Base.repo 文件

CentOS Linux 7.9.2009
CentOS Linux 7.9.2009

CentOS Linux 7.9.2009是传统CentOS Linux 7的最后主要版本,也是很多企业历史服务器中仍可能遇到的系统版本。它以稳定、兼容RHEL 7生态、文档丰富和软件支持广泛著称,曾长期用于Web服务、数据库、虚拟化节点和企业内部业务系统。不过CentOS Linux 7已于2024年6月30日停止维护,现在继续使用会面临安全补丁缺失风险。该版本更适合旧业务迁移、历史环境恢复或离

下载
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

4.2 下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4.3 配置epel源

epel(RHEL 7)
	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

epel(RHEL 6)
	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

epel(RHEL 5)
	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo

4.4 运行yum makecache生成缓存

# yum clean all
# yum makecache
# yum repolist

5. 基本软件工具安装

通过配置好的YUM库安装常用软件和工具

# yum install -y vim
# yum install -y wget
# yum install -y lrzsz

最小化安装没有ifconfig命令解决方法

# yum search ifconfig
# yum install -y net-tools
# yum provides ifconfig

命令粘贴

nmtui

systemctl stop firewalld.service
systemctl disable firewalld.service

setenforce 0
vi /etc/selinux/config
SELINUX=disable

mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/* /etc/yum.repos.d/bak
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum clean all
yum makecache
yum repolist

yum install -y vim
yum install -y wget
yum install -y lrzsz
yum install -y net-tools

更多编程相关知识,请访问:编程教学!!

相关文章

PHP速学视频免费教程(入门到精通)
PHP速学视频免费教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

centos

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
http与https有哪些区别
http与https有哪些区别

http与https的区别:1、协议安全性;2、连接方式;3、证书管理;4、连接状态;5、端口号;6、资源消耗;7、兼容性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

2024.08.16

5670

6

磁盘配额是什么
磁盘配额是什么

磁盘配额是计算机中指定磁盘的储存限制,就是管理员可以为用户所能使用的磁盘空间进行配额限制,每一用户只能使用最大配额范围内的磁盘空间。php中文网为大家提供各种磁盘配额相关的内容,教程,供大家免费下载安装。

2023.06.21

4670

4

如何安装LINUX
如何安装LINUX

本站专题提供如何安装LINUX的相关教程文章,还有相关的下载、课程,大家可以免费体验。

2023.06.29

3913

10

linux find
linux find

find是linux命令,它将档案系统内符合 expression 的档案列出来。可以指要档案的名称、类别、时间、大小、权限等不同资讯的组合,只有完全相符的才会被列出来。find根据下列规则判断 path 和 expression,在命令列上第一个 - ( ) , ! 之前的部分为 path,之后的是 expression。还有指DOS 命令 find,Excel 函数 find等。本站专题提供linux find相关教程文章,还有相关

2023.06.30

3253

5

linux修改文件名
linux修改文件名

本专题为大家提供linux修改文件名相关的文章,这些文章可以帮助用户快速轻松地完成文件名的修改工作,大家可以免费体验。

2023.07.05

8110

7

linux系统安装教程
linux系统安装教程

linux系统是一种可以免费使用,自由传播,多用户、多任务、多线程、多CPU的操作系统。本专题提供linux系统安装教程相关的文章,大家可以免费体验。

2023.07.06

7722

7

linux查看文件夹大小
linux查看文件夹大小

Linux是一种自由和开放源码的类Unix操作系统,存在着许多不同的Linux版本,但它们都使用了Linux内核。Linux可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、视频游戏控制台、台式计算机、大型机和超级计算机。linux怎么查看文件夹大小呢?php中文网给大家带来了相关的教程以及文章,欢迎大家前来学习阅读。

2023.07.20

4373

8

linux查看ip命令
linux查看ip命令

本专题为大家提供linux查看ip命令相关文章内容,感兴趣的朋友可以免费下载体验试试。

2023.07.20

3845

4

linux查看cpu使用率
linux查看cpu使用率

在linux的系统维护中,可能需要经常查看cpu使用率,分析系统整体的运行情况。本专题为大家带来了linux查看cpu使用率的相关文章,感兴趣的朋友千万不要错过了。

2023.07.25

4099

6

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
CentOS 官方文档
CentOS 官方文档

共0课时 | 0人学习