Linux系统优化

优化ssh链接速度

xshell中内置了ssh链接的客户端,Linux系统内置了ssh的服务端sshd,默认是开启的,在mac系统中,sshd是默认关闭的,需要手动开启。

[root@localhost ~]# ls /etc/ssh
moduli      sshd_config         ssh_host_ecdsa_key.pub  ssh_host_ed25519_key.pub  ssh_host_rsa_key.pub
ssh_config  ssh_host_ecdsa_key  ssh_host_ed25519_key    ssh_host_rsa_key

# sshd_config就是服务端的配置文件,修改之前先进行备份
[root@localhost ssh]# cp sshd_config sshd_config.bak
[root@localhost ssh]# vi sshd_config
:set number
79gg  #定位到79行
GSSAPIAuthentication yes  改为no
115gg #定位到115行
#UseDNS yes  去掉井号  改为no
UseDNS no
:wq #保存
# 重启sshd程序
[root@localhost ssh]# systemctl restart sshd

优化selinux

安全机制,但是开启后操作起来会很麻烦。
永久关闭配置

[root@localhost ssh]# vi /etc/selinux/config
:set number
7gg
SELINUX=enforcing改为disabled
# 需要重启生效,生产环境下无法重启,可以先临时关闭
[root@localhost ssh]# setenforce 0
# 查看selinux状态
[root@localhost ssh]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive允许不使用  enfrocing强制使用
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

关闭firewalld

关闭防火墙和开机自启动


[root@localhost ssh]# systemctl stop firewalld
[root@localhost ssh]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

安装常用软件

[root@localhost ssh]# yum install lrzsz vim tree wget net-tools screen tcpdump bash-completion -y
lrzsz:上传下载
vim:编辑器
tree:显示目录结构
wget:下载东西
net-tools:网络相关工具,可以通过rpm -ql net-tools查看相关命令。
screen:屏幕工具,网络不稳定时防止程序中断
tcpdump:抓包
bash-completion:tab键的加强版 输入-再使用tab键会提示有哪些参数

screen用法

# 开启screen屏幕
[root@localhost ssh]# screen
# 查看screen窗口
[root@localhost ~]# screen -ls
There is a screen on:
	2002.pts-0.localhost	(Detached)
1 Socket in /var/run/screen/S-root.
# 恢复screen窗口
[root@localhost ~]# screen -r 2002   # screen编号  通过 screen -ls查询
# 退出screen窗口
[root@localhost ssh]# exit

tcpdump 抓包工具,一般配合Wireshark使用

# 查看本机使用的网卡 
[root@localhost ~]# ifconfig
# -i 后面加指定网卡
[root@localhost ~]# tcpdump -i ens33
# port 抓取指定端口
[root@localhost ~]# tcpdump -i ens33 port 80
# -nn 显示访问主机ip和对应端口号,不加-nn显示的是主机名称和协议
[root@localhost ~]# tcpdump -i ens33 port 80 -nn
# -w 将捕获的数据写进test.pacp文件中,pcap或者cap captured的简写,捕获的文件,可以通过Wireshark直接打开
[root@localhost ~]# tcpdump -i ens33 port 80 -nn -w test.pcap
# 取出test.pacp文件
[root@localhost ~]# sz test.pcap 
# -c 指定抓取数据包的个数
[root@localhost ~]# tcpdump -i ens33 port 80 -nn -c 20
# -S 不把随机序列和确认序列解析成绝对值
[root@localhost ~]# tcpdump -i ens33 port 80 -nn
05:42:27.588156 IP 192.168.239.1.12120 > 192.168.239.129.80: Flags [.], ack 1, win 4106, length 0
05:42:27.588177 IP 192.168.239.1.12121 > 192.168.239.129.80: Flags [.], ack 1, win 4106, length 0
05:42:27.588355 IP 192.168.239.1.12120 > 192.168.239.129.80: Flags [P.], seq 1:539, ack 1, win 4106, length 538: HTTP: GET / HTTP/1.1
05:42:27.588364 IP 192.168.239.129.80 > 192.168.239.1.12120: Flags [.], ack 539, win 237, length 0
[root@localhost ~]# tcpdump -i ens33 port 80 -nn -S
05:43:06.534001 IP 192.168.239.1.12120 > 192.168.239.129.80: Flags [.], ack 2945834625, win 4104, length 0
05:43:12.599443 IP 192.168.239.1.12121 > 192.168.239.129.80: Flags [.], seq 4328223:4328224, ack 2071745027, win 4106, length 1: HTTP
05:43:12.599464 IP 192.168.239.129.80 > 192.168.239.1.12121: Flags [.], ack 4328224, win 229, options [nop,nop,sack 1 {4328223:4328224}], length 0
05:43:19.825486 IP 192.168.239.130.49993 > 23.199.157.202.80: Flags [F.], seq 2049496165, ack 262153147, win 64240, length 0
05:43:19.825911 IP 23.199.

查看已经安装的软件包

# 查看已安装软件包的个数
[root@localhost ~]# rpm -qa | wc -l

关闭NetworkManager

CentOS有两个网络管理服务,如果这两个服务都开启,就会不能上网,关闭NetworkManager,使用network服务

# 关闭NetworkManager服务
[root@localhost nginx]# systemctl stop NetworkManager
# 关闭NetworkManager开机自启动服务
[root@localhost nginx]# systemctl disable NetworkManager
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值