Linux环境配置常见问题

Linux环境配置常见问题

1. 换清华源

1
2
$ cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup #备份
$ vim /etc/yum.repos.d/CentOS-Base.repo #将内容修改如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#


[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7



#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7



#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7

这里是参考网址

2. 配置环境变量

/etc/profile下修改环境变量
举例:

1
2
export CMAKE_HOME=/usr/local/cmake-3.18.4-Linux-x86_64
export PATH=$CMAKE_HOME/bin:$PATH

使用source /etc/profile命令更新环境变量

3. 网络配置

配置文件位置:cd /etc/sysconfig/network-scripts

配置完成后,重启网络服务
systemctl restart network.service

4. 防火墙

查看防火墙状态:systemctl status firewalld

关闭防火墙:systemctl stop firewalld.service

开放端口:firewall-cmd --zone=public --add-port=5672/tcp --permanent

关闭端口:firewall-cmd --zone=public --remove-port=5672/tcp --permanent

使配置立即生效:firewall-cmd --reload

5. 赋予用户sudo权限

修改/etc/sudoers文件

加入以下内容

1
username ALL=(ALL) ALL