Skip to content

ubuntu 相关

基础

shell
vi /etc/netplan/00-installer-config.yaml
sudo netplan apply

防火墙

ufw allow 80
ufw status
ufw disable

yum

修改国内源

shell
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
vi /etc/apt/sources.list
# 添加以下源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# 更新
apt-get update
apt-get upgrade -y

安装软件

shell
apt update
apt upgrade -y
apt install -y wget zip unzip tar git screen vnstat telnet nethogs net-tools  bash-completion lsof

iptables

手动

shell
iptables-save > /etc/iptables.rules
iptables-restore < /etc/iptables.rules

重启生效

SHELL
vi /etc/rc.local
# 添加开机启动
shell
#!/bin/bash
iptables-restore < /etc/iptables.rules

检查 rc.local

shell
chmod +x /etc/rc.local

检查是否存在 /lib/systemd/system/rc.local.service

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

生效

shell
systemctl enable rc.local
reboot