Ubuntu批量添加IP

ubuntu 18.04 17.04

#写入到 /etc/netplan/01-netcfg.yaml
echo "      addresses: " >> /etc/netplan/01-netcfg.yaml
for ((i=1;i<=64;i++))
do
echo "        - 1.2.3.$i/29" >> /etc/netplan/01-netcfg.yaml
done
echo "      gateway4: 1.2.3.4" >> /etc/netplan/01-netcfg.yaml

#应用
netplan apply

ubuntu 16.04 14.04 脚本

# !/bin/bash
for ((i=1;i<=64;i=i+1))
do
echo "auto eth0:$i">>/etc/network/interfaces
echo "iface eth0:$i inet static">>/etc/network/interfaces
let j=$i+5
echo "address 1.2.3.$j">>/etc/network/interfaces
echo "netmask 255.255.255.248">>/etc/network/interfaces
echo "gateway 1.2.3.4">>/etc/network/interfaces
echo " ">>/etc/network/interfaces
done
# end

Ubuntu系统为用户添加sudo权限

系统:Ubuntu 18.04 LTS,使用sudo执行命令时提示:XXX is not in the sudoers file. This incident will be reported. 没有sudo权限,解决方法如下:

使用root用户登录

#给/etc/sudoers文件写入权限
chmod u+w /etc/sudoers

#编辑/etc/sudoers文件
vi /etc/sudoers

/etc/sudoers文件中的#User privilege specification下增加需要使用sudo的用户,添加到root这一行的下面即可,也可以复制root这一行,把root改成你的用户名。:wq保存退出。

#撤消/etc/sudoers的写入权限
chmod u-w /etc/sudoers

参考: https://blog.csdn.net/u012897374/article/details/78827359

Ubuntu更换内核并开启BBR加速

## http://kernel.ubuntu.com/~kernel-ppa/mainline/

64位: v4.19.34

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.34/linux-image-unsigned-4.19.34-041934-generic_4.19.34-041934.201904051741_amd64.deb

v4.9.168

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.168/linux-image-4.9.168-0409168-generic_4.9.168-0409168.201904051739_amd64.deb

32位: v4.19.34

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.34/linux-image-4.19.34-041934-generic_4.19.34-041934.201904051741_i386.deb

v4.9.168

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.168/linux-image-4.9.168-0409168-generic_4.9.168-0409168.201904051739_i386.deb

安装

dpkg -i image.deb

删除旧内核

dpkg -l|grep linux-image 
apt-get purge 旧内核

更新grub

/usr/sbin/update-grub
reboot

写入开启

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

保存

sysctl -p

验证

sysctl net.ipv4.tcp_available_congestion_control
sysctl net.ipv4.tcp_congestion_control
lsmod | grep bbr