linux系统基本优化

主机优化

#系统主机名称的配置文件/etc/hostname

#修改方式一:直接编辑文件,然后重启系统;
#修改方式二:命令修改,不需要重启系统;
#查看主机名称
hostname
hostnamectl set-hostname docker
#拓展:设置主机名称的价值,是能够通过主机名称,识别出其在企业中的作用;
hostnamectl set-hostname  bj-wads-lb03
hostname命令的其他使用参数
hostname -i
fe80::e65d:444c:c009:cbf9%eth0 10.0.0.100
 hostname -I
 10.0.0.100

二、时间同步的优化

1,设置时区


timedatectl 
[root@localhost ~]# timedatectl 
      Local time: 四 2024-06-27 17:04:55 CST
  Universal time: 四 2024-06-27 09:04:55 UTC
        RTC time: 四 2024-06-27 09:04:56
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

2,查看系统中所有的时区

 timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa

3,设置系统时区

timedatectl set-timezone Asia/Shanghai

2,设置时间(对表)

手动方式同步时间
#1,安装时间同步工具
yum -y install ntpdate
#2,同步时间(我们同步阿里云的时间服务器)
ntpdate ntp.aliyun.com
自动方式同步时间
#查看系统时间信息详情
timedatectl 
查看自动时间同步工具chronyd的状态是否开启(是否有绿色的running)
systemctl status chronyd
如果没有
systemctl start chronyd

三、下载软件优化

1,配置下载源

#1,前往阿里巴巴开源镜像站https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.59aa1b119TEZaL

#-按照其介绍文档,下载阿里源
 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   7851      0 --:--:-- --:--:-- --:--:--  7859

#epel源,特殊软件仓库
 curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

2,安装重要常用的软件

yum -y install tree vim wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils methogs expect dos2unix
########################################################
bash-completion bash-completion-extras #命令补全工具
lrzsz  #上传和下载到本地
	   #本地上传到服务器:rz -E
	   #服务器下载到本地:sz 文件
nmap   #扫描端口使用的
net-tools #网络工具
dos2unix  #windows文件转化成linux问价哪个是使用;

3,查看当前的yum源地址

yum repolist

四、安全软件的关闭优化

1,selinux关闭

#1,查看selinux是否关闭
 getenforce 
Enforcing
#2,临时关闭selinux
# setenforce 0
# getenforce 
Permissive
#3,永久关闭selinux(修改其配置文件)
vim /etc/selinux/config
.......
SELINUX=disabled
.....

2,关闭防火墙firewalld

#1,临时关闭防火墙
 systemctl stop firewalld.service

#2,永久关闭(禁止其开机自启动)
 systemctl disable firewalld.service

3,拓展:systemctl命令

systemctl stop    服务名称    #关闭服务
systemctl start   服务名称    #开启服务
systemctl status  服务名称    #查看服务状态
systemctl disable 服务名称    #禁止其开机自启动
systemctl enable  服务名称    #禁止其开机自启动

五、字符集优化

1,ascll码,; 1字符1字节
2,各个国家都有计算机使用需求,GBK;
3,unicode:【每个字符占用4字节】;
4,【UTF-8万国码】;英文占用1字节,汉语占用2字节;
1字节==8bit==256
4字节==32bit==4294967296
#1,查看系统当前使用的编码
localectl 
   System Locale: LANG=zh_CN.UTF-8
       VC Keymap: cn
      X11 Layout: cn

#2,查看系统中都有哪些编码
localectl list-locales

#3,设置系统的编码表
localectl set-locale LANG=编码表名称
######################################################
localectl set-locale LANG=zh_CN.utf8

六、系统远程连接优化

vim /etc/ssh/sshd_config
#避免连接时延时
79  GSSAPIAuthentication no
#关闭反向解析;域名>ip; 反向解析:ip>域名
115 UseDNS no
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值