CentOS 7

更改CentOS 7更新源为国内阿里云提供的源

1、备份

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

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
//CentOS 6
wget -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

3、之后运行 yum makecache 生成缓存

不在 sudoers 文件中.此事将被报告

新建了一个帐号linc,今天在执行sudo时回显一个很吓人的信息:

[sudo] password for linc:   
linc 不在 sudoers 文件中。此事将被报告。

为了解释这个问题,先来说说sudo。

sudo命令可以让你以root身份执行命令,来完成一些我们这个帐号完成不了的任务。

其实并非所有用户都能够执行sudo,因为有权限的用户都在/etc/sudoers中呢。

我们可以通过编辑器来打开/etc/sudoers,或者直接使用命令visudo来搞定这件事情。

打开sudoers后,像如下那样加上自己的帐号保存后就可以了。

# User privilege specification  
root    ALL=(ALL:ALL) ALL  
linc    ALL=(ALL:ALL) ALL

sudoers的权限是0440,即只有root才能读。在你用root或sudo后强行保存(wq!)即可。

centos开机自动启动网络

查看一下使用的网卡 。

$ ifconfig

然后 进入到配置linux网络目录

$ cd /etc/sysconfig/network-scripts

修改网卡下 ONBOOT=yes
即可实现开机自启动配置

CentOS7 防火墙关闭

CentOS7 的防火墙配置跟以前版本有很大区别,经过大量尝试,终于找到解决问题的关键
CentOS7这个版本的防火墙默认使用的是firewall,与之前的版本使用iptables不一样。按如下方便配置防火墙:
1、关闭防火墙:sudo systemctl stop firewalld.service

2、关闭开机启动:sudo systemctl disable firewalld.service

3、安装iptables防火墙
执行以下命令安装iptables防火墙:sudo yum install iptables-services

4、配置iptables防火墙,打开指定端口(具体跟以前版本一样,网上介绍很多,这里不多介绍了)

5. 设置iptables防火墙开机启动:sudo systemctl enable iptables
OK了,根据配置的端口就可以访问了

原文地址:https://www.cnblogs.com/airoot/p/6473704.html