Linux操作系统优化

目录

1)查看操作系统版本号

2)字符集优化

3)关闭防火墙

4)关闭SeLinux防火墙

5)时间同步

6)ssh优化

1)Linux查看操作系统版本号

方法一:

 

cat /etc/redhat-release

方法二:命令查看
hostnamectl

2.查看系统内核版本

方法一.
hostsnamectl

方法二.使用命令
uname -r

2)字符集优化

常用字符集:
1.utf-8 万国码
2.GBK   国标
xshell默认的是utf-8


查看操作系统字符集:
echo $LANG
查看字符集配置文件位置: 
cat /etc/locale.conf
永久+临时类似hostnamectl命令
localectl set-locale LANG="zh_CN.UTF-8"
临时修改:
LANG="zh_CN.UTF-8"

 3)关闭防火墙

防火墙分为软件和硬件防火墙

centos6.x默认防火墙: iptables
centos7.x默认防火墙: Firewalld

 查看当前防火墙状态
systemctl status firewalld

退出防火墙
systemctl stop firewalld

 

开机禁止启动防火墙 
systemctl disable firewalld
管理命令:

systemctl 动作 服务名称


    start   启动
    stop    停止
    restart 重启
    reload  重新加载配置
    status  查看服务的状态
    enable  开机自动运行
    disable 开机禁止启动  

4)关闭Selinux防火墙

作用: 对root管理员做安全限制,企业中不用


查看selinux状态
getenforce


临时关闭selinux,重启操作系统失效
setenforce

usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
Enforcing: 或者 1 开启
Permissive: 或者0 关闭

 关闭selinux命令:

setenforce 0

禁止开机自动运行需要修改配置文件

vim /etc/selinux/config

 

5) 时间同步

查看当前时间
date +%F

%H : 小时(00..23)

%M : 分钟(00..59)

%S : 秒(00..61)

%X : 相当于 %H:%M:%S %d : 日 (01..31)

%m : 月份 (01..12)

%Y : 完整年份 (0000..9999)

%F : 相当于 %Y-%m-%d

修改系统时间

只是做测试使用

date -s 2001-08-19
使用命令同步系统时间
ntpdate ntp1.aliyun.com
查看硬件时间
clock
将系统的时间同步给硬件时间
clock -w

6)修改默认的仓库

查看当前系统默认的下载仓库
yum repolist

如果不是阿里云的仓库使用以下方法

1)备份默认的仓库
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2)下载阿里云的仓库
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3)检查是否成功
yum repolist

安装拓展仓库

第一步: 下载epel扩展仓库:
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
如果没有安装 “wget”输入以下命令
yum -y install wget
第二步: 检查
yum repolist

7)优化ssh

修改配置文件
vim /etc/ssh/sshd_config

重启生效
systemctl restart sshd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值