xjychengzhang

第1章 优化yum源

yum源相当于软件仓库,默认的yum源有三个:

base(用的较多), 与光盘里面的内容类似 ,比光盘多一点

extra(额外的)

updates(更新的)

1.1 修改系统默认的yum源为 阿里云

https://opsx.alibaba.com/mirror里找到CentOS帮助,按步骤执行

[root@skr ~ 10:53:35]# yum repolist

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com

 * extras: mirrors.aliyun.com

 * updates: mirrors.aliyun.com

repo id                repo name                                            status

base/7/x86_64          CentOS-7 - Base - mirrors.aliyun.com                  9,911

epel/x86_64            Extra Packages for Enterprise Linux 7 - x86_64       12,756

extras/7/x86_64        CentOS-7 - Extras - mirrors.aliyun.com                  432

updates/7/x86_64       CentOS-7 - Updates - mirrors.aliyun.com               1,614

repolist: 24,713

1.2 添加一个yum源(epel源)

https://opsx.alibaba.com/mirror里找到epel源,找到帮助,按步骤执行。

epel源:Extra Packages  for Enterprise  Linux  企业级linux的额外的软件包 (redhat centos Fedora)

配置完成后装sl和 cowsay两个软件

yum install -y   sl cowsay 

检查是否装上:

rpm -qa  sl cowsay

1.3 装补全工具包

装好epel源后,装两个补全工具

yum install bash-completion-extras bash-completion  -y

查看系统yum源的目录

[root@skr ~ 11:09:50]# ll /etc/yum.repos.d/

total 44

-rw-r--r--. 1 root root 2523 Jun 16 06:22 CentOS-Base.repo(改了)

-rw-r--r--. 1 root root 1309 Apr 29  2018 CentOS-CR.repo

-rw-r--r--. 1 root root  649 Apr 29  2018 CentOS-Debuginfo.repo

-rw-r--r--. 1 root root  314 Apr 29  2018 CentOS-fasttrack.repo

-rw-r--r--. 1 root root  630 Apr 29  2018 CentOS-Media.repo

-rw-r--r--. 1 root root 1331 Apr 29  2018 CentOS-Sources.repo

-rw-r--r--. 1 root root 4768 Apr 29  2018 CentOS-Vault.repo

-rw-r--r--. 1 root root  664 May 11 11:35 epel.repo

-rw-r--r--. 1 root root  951 Oct  3  2017 epel.repo.backup

-rw-r--r--. 1 root root 1050 Oct  3  2017 epel-testing.repo(增加)

第2章 关闭SElinux

SElinux : Security Enhanced Linux ,是美国国家安全局研发的,但平时不用。

2.1 永久改 - 重启系统之后生效

2.1.1 改配置文件

vim /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.             默认 selinux开启正在运行

#     permissive - SELinux prints warnings instead of enforcing.   selinux关闭 提示警告

#     disabled - No SELinux policy is loaded.                      selinux彻底关闭

SELINUX=disabled

# 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

2.2 临时关闭selinux

[root@skr ~ 11:33:20]# setenforce 0        1:开启0:关闭

setenforce: SELinux is disabled

2.3 检查是否关闭

[root@skr ~ 11:34:03]# getenforce

Disabled

查看是否关闭:

[root@skr ~ 11:25:38]# grep disable /etc/selinux/config

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

第3章 关闭防火墙

3.1 防火墙应用场景:

1.服务器 拥有公网ip时要用到防火墙

2.服务器没有公网ip 外部无法直接访问时要关闭防火墙当高并发时也要关闭防火墙(软件)打开硬件防火墙       

3.2 关闭正在运行的防火墙(临时)

systemctl  stop firewalld.service

stop 停止

start 开启

restart 重启

3.3 关闭开机自启动(永久)

不让防火墙在开机的时候自动运行

systemctl disable  firewalld.service

#disable  关闭 开机自启动

#enable   开机自启动

3.4 查看防火墙的详细信息(检查)

[root@skr ~ 11:54:21]# 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)

 

#是否 正在运行

[root@oldboyedu-lnb ~]# systemctl is-active firewalld.service

unknown

#是否 开机自启动

[root@oldboyedu-lnb ~]# systemctl is-enabled firewalld.service

disabled

3.5 CentOS 7(firewalld)与 CentOS 6(iptables)关闭防火墙的对比

CentOS 7(firewalld)                          CentOS 6(iptables)

1.临时- 关闭正在运行                        1.临时- 关闭正在运行

       systemctl  stop  firewalld              /etc/init.d/iptables stop  #service   iptables  stop

2.永久- 不在开机自启动                      2.永久- 不在开机自启动 

       systemctl  disable firewalld            chkconfig   iptables off   # on 或off

3.检查                                     

       status                                   /etc/init.d/iptables status #当前是否运行

                                               chkconfig |grep iptables     #是否 开机自启动

       is-active  #是否 正在运行

       is-enabled #是否 开机自启动

第4章 linux显示中文乱码 (如何修改字符集 语言)

4.1 什么是字符集?

是语言文字 在计算机中表示方法 方式

UTF-8 万国码(通用)

GBK   国标

4.2 如何查看系统字符集

 [root@oldboyedu-lnb ~]# echo $LANG

en_US.UTF-8

4.3 修改字符集

4.3.1 临时修改:

[root@oldboyedu-lnb ~]# export LANG=zh_CN.UTF-8

vimtutor   验证

4.3.2 永久修改

方法1:使用命令

[root@skr ~ 12:22:23]# localectl set-locale LANG=zh_CN.utf8

[root@skr ~ 12:29:53]# cat /etc/locale.conf

LANG=zh_CN.utf8

生效:重新登录或

[root@skr ~ 01:02:42]# source /etc/locale.conf

方法2:改变配置文件

[root@skr ~ 11:57:46]# vim /etc/locale.conf

LANG=en_US.utf8

4.4 检查

[root@oldboyedu-lnb ~]# echo $LANG

zh_CN.UTF-8

 

[root@oldboyedu-lnb ~]# cat  /etc/locale.conf

LANG="en_US.UTF-8"

4.5 Linux乱码

4.5.1 原因

linux系统的字符集 与 远程连接工具字符集 不同

4.5.2 如何检查

1、查看系统的字符集

echo $LANG

2、检查Xshell使用的字符集

4.5.3 解决乱码

修改Xshell的字符集或者修改系统的字符集

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2021-11-19
  • 2021-06-10
  • 2021-11-17
  • 2021-08-23
  • 2022-02-05
  • 2021-12-12
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2021-10-08
  • 2022-01-02
  • 2022-12-23
相关资源
相似解决方案