Linux优化

vim编辑/ect/sysctl.conf文件,添加在文件末尾.

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
###################################################################
# Magic system request Key
# 0=disable, 1=enable all, >1 bitmask of sysrq functions
# See https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html
# for what other values do
#kernel.sysrq=438

# Accept IPv6 advertisements when forwarding is enabled

# for high-latency network
# net.ipv4.tcp_congestion_control = hybla

# for low-latency network, use cubic instead
# net.ipv4.tcp_congestion_control = cubic

net.ipv6.conf.all.accept_ra = 2

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

#########################NEW#######################################

# max open files
fs.file-max = 51200
# max read buffer
net.core.rmem_max = 67108864
# max write buffer
net.core.wmem_max = 67108864
# default read buffer
net.core.rmem_default = 65536
# default write buffer
net.core.wmem_default = 65536
# max processor input queue
net.core.netdev_max_backlog = 4096
# max backlog
net.core.somaxconn = 4096

# resist SYN flood attacks
net.ipv4.tcp_syncookies = 1
# reuse timewait sockets when safe
#net.ipv4.tcp_tw_reuse = 1

# turn off fast timewait sockets recycling
#net.ipv4.tcp_tw_recycle = 0

# short FIN timeout
net.ipv4.tcp_fin_timeout = 30
# short keepalive time
net.ipv4.tcp_keepalive_time = 1200
# outbound port range
net.ipv4.ip_local_port_range = 10000 65000
# max SYN backlog
net.ipv4.tcp_max_syn_backlog = 4096
# max timewait sockets held by system simultaneously
net.ipv4.tcp_max_tw_buckets = 5000
# turn on TCP Fast Open on both client and server side
net.ipv4.tcp_fastopen = 3
# TCP receive buffer
net.ipv4.tcp_rmem = 4096 87380 67108864
# TCP write buffer
net.ipv4.tcp_wmem = 4096 65536 67108864
# turn on path MTU discovery
net.ipv4.tcp_mtu_probing = 1


net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1

用resolvconf配置DNS服务器

原文地址:https://note.qidong.name/2020/05/resolvconf/

安装resolvconf

1
sudo apt install resolvconf

配置

一般直接使用的是/etc/resolv.conf文件。 安装了resolvconf后,不仅多了对应的可执行文件,还新增了/etc/resolvconf/这个配置目录。 其中,主要有三个配置。

1
2
3
/etc/resolvconf/resolv.conf.d/base:在自动生成的resolv.conf为空时,替换它。
/etc/resolvconf/resolv.conf.d/head:在自动生成的resolv.conf前添加。
/etc/resolvconf/resolv.conf.d/tail:在自动生成的resolv.conf后添加。

一般使用的是head。 在其中添加以下内容(具体的IP则根据自己的实测情况选择):

阅读更多
DNS Server addr

阿里巴巴

  • 223.5.5.5
  • 223.6.6.6
  • [2400:3200::1]
  • [2400:3200:baba::1]
阅读更多
Docker部署halo博客系统

Step1 建立存储目录

1
2
mkdir ~/halo

阅读更多
OpenSUSE安装清华大学源packman

添加清华大学镜像源packman

1
sudo zypper ar -fc 'https://mirrors.tuna.tsinghua.edu.cn/packman/suse/openSUSE_Leap_$releasever' packman 

将系统软件包切换到 packman 中的软件包 (两者混用会导致一些问题, 所以要切换)

1
zypper dup --from packman --allow-vendor-change

原文地址https://forum.suse.org.cn/t/topic/12937


Docker install Portainer
1
2
3
4
5
6
7
$ docker volume create portainer_data 
$ docker run -d \
-p 8000:8000 \
-p 9000:9000 --name=portainer --restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce

Termux SoftWare Install

Update

1
2
3
nano $PREFIX/etc/apt/sources.list

pkg up

Openssh

1
pkg install openssh

Tinyproxy

1
pkg install tinyproxy

openSUSE网络配置

图形化配置工具

1
nmtui

网桥配置

参考链接 https://lala.im/7552.html


Linux挂载samba文件系统

1.安装软件

1
apt install cifs-utils smbclient

2.列出目标主机共享目录

1
smbclient -L <服务器IP或主机名>  -U  <用户名>

3.挂载

1
mount -t cifs //<共享点路径>/<共享名> <挂载点> -o username=<用户名>,password=<密码>,pid=<pid>,uid=<uid>

4.开机自动挂载方法

在 /etc/fstab 末尾添加:

1
<共享点路径>  <挂载点>  cifs  username=<用户名>,password=<密码>,pid=<pid>,uid=<uid>  0  0

Linux查看端口占用

安装工具

1
sudo apt install net-tools

运行命令

1
netstat -ntulp

-n 拒绝显示别名,能显示数字的全部转化为数字
-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-l 仅列出Listen(监听)的服务状态
-p 显示建立相关链接的程序名