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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
| #!/bin/sh
# 更新为阿里云 sudo bash -c 'cat <<EOF > /etc/apt/sources.list
# aliyun deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse EOF'
# 禁用内核更新 sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic # 锁定内核 sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic sudo apt-mark hold linux-image-generic linux-headers-generic
sudo apt update
# 禁用内核更新 sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic # 锁定内核 sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic sudo apt-mark hold linux-image-generic linux-headers-generic
sudo timedatectl set-timezone Asia/Shanghai sudo cat /etc/timezone
# sudo mkdir -p /root/snap/chromium/common/chromium/BrowserMetrics sudo apt install language-pack-zh-hans -y sudo locale-gen zh_CN.UTF-8 sudo update-locale LANG=zh_CN.UTF-8
export LANG=zh_CN.UTF-8
sudo apt-get install vim -y && sudo apt-get remove vim -y sudo apt install fonts-wqy-zenhei fonts-wqy-microhei fonts-noto-cjk -y sudo apt install -y fontconfig sudo apt install -y fonts-dejavu-core fonts-liberation
sudo apt install fonts-wqy-zenhei fonts-wqy-microhei fonts-noto-cjk -y sudo apt install -y git sudo apt install net-tools -y sudo apt install openssh-server -y sudo apt install -y fontconfig sudo apt install -y fonts-dejavu-core fonts-liberation
# 禁用自动更新 sudo sed -i 's/APT::Periodic::Update-Package-Lists "1";/APT::Periodic::Update-Package-Lists "0";/g' /etc/apt/apt.conf.d/10periodic sudo sed -i 's/APT::Periodic::Unattended-Upgrade "1";/APT::Periodic::Unattended-Upgrade "0";/g' /etc/apt/apt.conf.d/10periodic
# 禁用无人值守升级 sudo sed -i 's/APT::Periodic::Update-Package-Lists "1";/APT::Periodic::Update-Package-Lists "0";/g' /etc/apt/apt.conf.d/20auto-upgrades sudo sed -i 's/APT::Periodic::Unattended-Upgrade "1";/APT::Periodic::Unattended-Upgrade "0";/g' /etc/apt/apt.conf.d/20auto-upgrades
# 禁用 apt-daily 服务和计时器 sudo systemctl stop apt-daily.service sudo systemctl disable apt-daily.service sudo systemctl mask apt-daily.service sudo systemctl daemon-reload sudo systemctl stop apt-daily.timer sudo systemctl disable apt-daily.timer sudo systemctl mask apt-daily.timer sudo systemctl daemon-reload
# 禁用 unattended-upgrades 服务 sudo systemctl disable unattended-upgrades
# 禁用 Snap 自动更新 sudo snap refresh --hold
# 禁用自动更新 sudo systemctl stop apt-daily.service sudo systemctl disable apt-daily.service sudo systemctl kill --kill-who=main apt-daily.service sudo systemctl disable apt-daily.timer sudo systemctl mask apt-daily.timer sudo systemctl stop unattended-upgrades.service sudo systemctl disable unattended-upgrades.service
sudo systemctl daemon-reload
# Ubuntu自动登录和开机锁屏取消 ## 禁用自动锁屏: # gsettings set org.gnome.desktop.screensaver lock-enabled false # gsettings set org.gnome.desktop.lockdown disable-lock-screen true
# 禁用内核更新 sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic # 恢复内核更新 sudo apt-mark unhold linux-generic linux-image-generic linux-headers-generic
sudo sed -i 's/1/0/' /etc/apt/apt.conf.d/10periodic sudo sed -i 's/2/0/' /etc/apt/apt.conf.d/10periodic
sudo sed -i 's/1/0/' /etc/apt/apt.conf.d/20auto-upgrades sudo sed -i 's/2/0/' /etc/apt/apt.conf.d/20auto-upgrades
sudo apt remove update-notifier -y
# 禁用屏幕休眠 # gsettings set org.gnome.desktop.session idle-delay 0
sudo mkdir -p /home/mes/.config/autostart sudo mkdir -p /home/mes/.ssh
sudo touch /home/mes/.config/autostart/chromium.desktop sudo touch /home/mes/.ssh/authorized_keys
# 写入文件内容 sudo cat <<EOF > /home/mes/.config/autostart/chromium.desktop [Desktop Entry] Type=Application Exec=sh -c "sleep 15 && /usr/bin/google-chrome-stable --disable-background-networking --start-maximized --disable-infobars --password-store=basic --kiosk 'http://127.0.0.1:8081/hmi/a3886ab468c84417a24df00fcf56a253/zlg63v?pageId=LJ-A '" EOF
sudo chown -R mes:mes /home/mes/.config/autostart/chromium.desktop sudo chmod a+x /home/mes/.config/autostart/chromium.desktop
sudo mkdir -p /etc/gdm3/
sudo cp -f /etc/gdm3/custom.conf /etc/gdm3/custom.conf.backup-$DATE sudo touch /etc/gdm3/custom.conf
# 写入文件内容 sudo cat <<EOF > /etc/gdm3/custom.conf [daemon] AutomaticLoginEnable=True AutomaticLogin=mes EOF
# Linux优化-Ulimit # 写入文件内容
sudo bash -c 'cat <<EOF > /etc/security/limits.conf * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535 EOF'
# >> 表示 追加 到文件末尾,不会破坏原有内容 sudo bash -c 'cat <<EOF > /etc/systemd/system.conf [Manager] DefaultLimitNOFILE=1048576 EOF'
# >> 表示 追加 到文件末尾,不会破坏原有内容 sudo bash -c 'cat <<EOF > /etc/sysctl.conf net.ipv4.ip_forward = 1 fs.file-max = 1048576 fs.inotify.max_user_instances=512 fs.inotify.max_user_watches=262144 EOF'
# >> 表示 追加 到文件末尾,不会破坏原有内容 #sudo bash -c 'cat <<EOF >> /etc/sudoers #mes ALL=(ALL:ALL) NOPASSWD: ALL #EOF'
# 安装chrome谷歌浏览器 # 安装chrome谷歌浏览器 sudo wget -O google-chrome-stable_current_amd64.deb --no-check-certificate http://xx.xx.xx.xx:9000/Ubuntu20.04/google-chrome-stable_current_amd64.deb sudo dpkg -i google-chrome-stable_current_amd64.deb sudo apt update sudo apt-get install google-chrome-stable -y
# 谷歌浏览器取消登录密钥环**然后重启系统,首次打开 Chrome 时会提示创建新密钥环,直接留空密码并继续即可 rm -rf /home/mes/.local/share/keyrings/* sudo rm -rf /home/mes/.local/share/keyrings/*
# 调整电视连接显示配置 sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/g' /etc/systemd/logind.conf
sudo apt autoremove -y
# 固定IP地址(01-network-manager-all.yaml) #sudo bash -c 'cat <<EOF > /etc/netplan/01-network-manager-all.yaml #network: # version: 2 # renderer: NetworkManager # ethernets: # enp0s25: # dhcp4: no # dhcp6: no # addresses: [192.168.10.$1/24] # gateway4: 192.168.10.1 # nameservers: # addresses: [8.8.8.8, 114.114.114.114] #EOF'
# 配置密钥允许 sudo bash -c 'cat <<EOF >> /home/mes/.ssh/authorized_keys
EOF'
# ubuntu 启动时,默认30秒的时间能调整为5S #sudo vim /etc/default/grub #找到这一行: #GRUB_TIMEOUT=30 sudo bash -c 'cat <<EOF > /etc/default/grub GRUB_DEFAULT=0 GRUB_TIMEOUT_STYLE=menu GRUB_TIMEOUT=5 GRUB_RECORDFAIL_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" EOF'
sudo update-grub
# enp0s25网卡名字调整统一 sudo mkdir -p /etc/udev/rules.d/ # sudo touch /etc/udev/rules.d/10-rename-network.rules
#sudo bash -c 'cat <<EOF > /etc/udev/rules.d/10-rename-network.rules #SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="", NAME="enp0s25" #EOF'
# sudo apt autoremove -y # sudo reboot # sudo systemctl restart systemd-logind
|