Linux System Initialization Guide

Recently, I have been trying to document operations using Markdown format. Recording with Markdown is better than simply using .txt files, as it has a clear structure. It is as universal as .txt and is plain text, avoiding compatibility issues. After writing in a .txt document, it can be directly pasted into a webpage or public account without worrying about formatting issues. (Markdown tutorial link: https://markdown.com.cn/editor/)

Linux System Initialization

Hardware configuration requires at least one core, 1GB RAM, and 10GB of hard disk space.

Linux System InitializationUbuntu Upgrade (International Version)Upgrade Ubuntu 20.04 –> 22.04 –> 24.04Ubuntu Upgrade (China Version)1. Install Ubuntu 22.04 server version2. Change software source3. Upgrade system and perform major version upgradesUbuntu 24.04 server static address loss issue after rebootDebian Upgrade (International Version)1. Upgrade Debian 11 –> Debian 122. Upgrade Debian 12 to Debian 13Debian Upgrade (China Version)CentOS 9 Stream1. Obtain DHCP2. Change software source3. Upgrade systemCommon ToolsGrant necessary capabilitiesCentOS 8 Upgrade (International Version)Change software source and upgradeCentOS 8 (China Version)1. Automatically obtain address2. Change software source3. Upgrade system4. Change to static address5. Install software (optional)CentOS 71. Automatically obtain address2. Change software source3. Upgrade system4. Install common software (optional)Install common softwareInstall essential softwareInstall network debugging toolsRun software in the background1. tmux2. nohup3. screenRAID software1. mdadmSystem monitoring software1. htop2. top

Ubuntu Upgrade (International Version)

Upgrade Ubuntu 20.04 –> 22.04 –> 24.04

Execute the following commands in a loop to upgrade the Ubuntu system to the latest version across major versions.

# Upgrade Ubuntu 20.04 to the latest version. If in China, first change the source.
sudo apt update && sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y

# Ubuntu upgrade management tool
sudo apt install update-manager-core

# Start upgrading to Ubuntu 22.04, reboot after upgrading. Then upgrade the system to the latest version, and use the following command to upgrade to Ubuntu 24.04.
# Need to watch for the continue prompt and press Y.
sudo do-release-upgrade

# ***Optional command***. Delete upgrade cache to free up about 500MB
sudo apt autoclean -y
sudo apt autoremove -y
sudo apt clean

Use <span>uname -a or cat /etc/os-release</span> or <span>lsb_release -a</span> to verify the system version.

Upgrade complete. END.

Ubuntu Upgrade (China Version)

1. Install Ubuntu 22.04 server version

The Ubuntu desktop version does not have SSH remote access, so we only install the Ubuntu server version. Use a pre-prepared USB to install the system, selecting the openSSH feature during installation, with other defaults.

Check address after obtaining DHCP

After installation, log in via SSH with the created ordinary user and switch to the root user.

# Set password for root
sudo passwd root

! Important ! Enable remote access for the ROOT account

# Open SSH configuration file
nano /etc/ssh/sshd_config

# Change the commented root user SSH login method <span>#PermitRootLogin prohibit-password</span> to <span>PermitRootLogin yes</span>. Save and exit, then reboot.

At this point, the root user of the Ubuntu system can be accessed remotely.

2. Change Software Source

Change the software source to Tsinghua source.

# First backup the software source configuration file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# Open the software source configuration file
sudo nano /etc/apt/sources.list

# Change the content to the following Tsinghua software source
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

Optional command Change the Docker official source to Tsinghua Docker source

sudo mkdir -p /etc/docker
echo '{
  "registry-mirrors": ["https://docker.mirrors.sjtug.sjtu.edu.cn","https://mirror.ccs.tencentyun.com"]
}' | sudo tee /etc/docker/daemon.json

sudo systemctl restart docker

3. Upgrade System and Perform Major Version Upgrades

From Ubuntu 20.04 –> Ubuntu 22.04 –> Ubuntu 24.04.

# Upgrade system
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y

# Tool for upgrading across major versions
sudo apt install update-manager-core -y
# First check if the system is the current LTS version, only LTS versions can perform major version upgrades
lsb_release -a

# Major version upgrade system
sudo do-release-upgrade

Generally, just keep pressing Y or R to successfully upgrade; if it fails, try several times.

After successfully upgrading across major versions, use <span>uname -a or cat /etc/os-release</span> or <span>lsb_release -a</span> to verify the system version.

# Upgrade system
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y

Upgrade complete. END.

Ubuntu 24.04 Server Static Address Loss Issue After Reboot

Issue: After changing the /etc/netplan/50-cloud-init.yaml file to a static address for the Ubuntu 24.04 server physical machine, the static address configuration is lost after reboot and automatically changes to DHCP.

Issue Explanation: Due to the absence of network management tools like Network-Manager, the network is managed by cloud-init, which regenerates the cloud-init.yaml file every time the system reboots.

Solution: Disable cloud-init initialization functionality and create a new network address configuration file.

# Create a module to disable cloud-init functionality
sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

# Write the command to disable cloud-init configuration
network: {config: disabled}
# Delete the network configuration file generated by cloud-init
sudo rm -f /etc/netplan/50-cloud-init.yaml
# Create a new network configuration file
sudo nano /etc/netplan/00-installer-config.yaml

# Write the following content. The IP address is an example; write according to your actual parameters.
# In Ubuntu 24.04 server, gateway4: has been deprecated, use routers:
network:
  version: 2
  renderer: networkd
  ethernets:
    :
      dhcp4: false
      addresses:
        - /
      routes:
        - to: default
          via: 
      nameservers:
        addresses:
          - 8.8.8.8
# Set permission restrictions, otherwise an error will occur
sudo chmod 600 /etc/netplan/00-installer-config.yaml
# Apply new configuration and check for any wrong errors
netplan try
netplan apply
netplan status
ip a
# Reboot to verify
reboot

Debian Upgrade (International Version)

1. Upgrade Debian 11 –> Debian 12

Change the software source for Debian 11 (this VPS server’s software source has issues).

# First try to upgrade. If the upgrade is successful, skip the source change stage; if not, change the source.
sudo apt update
sudo apt upgrade -y

# The source for Debian 11 has issues, first change the source. Open the source link file
nano /etc/apt/sources.list

# Change the content to the following

deb http://deb.debian.org/debian bullseye main
deb-src http://deb.debian.org/debian bullseye main

deb http://security.debian.org/debian-security bullseye-security main
deb-src http://security.debian.org/debian-security bullseye-security main

deb http://deb.debian.org/debian bullseye-updates main
deb-src http://deb.debian.org/debian bullseye-updates main

deb http://archive.debian.org/debian bullseye-backports main
deb-src http://archive.debian.org/debian bullseye-backports main

Upgrade Debian 11 system

# Clean upgrade cache files and upgrade Debian 11 to the latest version
sudo apt clean all
sudo apt update
sudo apt full-upgrade -y
sudo apt --fix-broken install
sudo apt autoremove --purge -y

# Download common tools
sudo apt install -y curl wget bash socat

# Reboot
reboot

Prepare Debian 12’s software source

# Backup the software source file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# Change the software source to the official source for Debian 12 system
sudo nano /etc/apt/sources.list

# Change the content to the following

deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware

deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware

Cross-major version upgrade system Debian 11 –> Debian 12

# Update package index
sudo apt update

# Minimum upgrade across major versions, after upgrading, it will already be Debian 12, resolving basic dependencies. Default to enter key.
sudo apt upgrade --without-new-pkgs -y

# Upgrade to the full version of Debian 12. Default to enter key.
sudo apt full-upgrade -y

# Clean up unused packages and reboot
sudo apt autoremove --purge -y
sudo apt autoclean

Use <span>uname -a or cat /etc/os-release</span> or <span>lsb_release -a</span> to verify the system version.

Complete. END.

2. Upgrade Debian 12 to Debian 13

Upgrade the Debian 12 system and change the software source to Debian 13.

# Upgrade to the latest version, normally upgrade to the latest version and reboot
sudo apt update
sudo apt full-upgrade -y
sudo apt --fix-broken install
sudo apt autoremove --purge -y

# Backup the software source and change the software source to Debian 13 system's
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# Open the software source file
sudo nano /etc/apt/sources.list

# Change the content to the following

deb http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian trixie main contrib non-free non-free-firmware

deb http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
deb-src http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware

deb http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware

Cross-major version upgrade system Debian 12 –> Debian 13

# Update software source index
sudo apt update

# Minimum upgrade across major versions, resolving basic dependencies, after upgrading, it will be Debian 13. Default to enter key.
sudo apt upgrade --without-new-pkgs -y

# Upgrade to the full version of Debian 13 and upgrade to the latest version. Default to enter key.
sudo apt full-upgrade -y

Reboot

Use <span>uname -a or cat /etc/os-release</span> or <span>lsb_release -a</span> to verify the system version.

# Clean up unused software
sudo apt autoremove --purge -y
sudo apt autoclean

Upgrade complete. END.

Debian Upgrade (China Version)

CentOS 9 Stream

CentOS 9 Stream initialization configuration: Step 1: Connect to the internet and obtain an IP address Step 2: Change to Tsinghua source and upgrade Step 3: Install necessary software tcpdump, decompression, remote access, docker Step 4: Install EasyNVR

1. Obtain DHCP

If unable to obtain an IP address, change autoconnect to true:

# View network card file
cat /etc/NetworkManager/system-connections/enp20s0.nmconnection 

# Network card file content
autoconnect=true
# Restart network card
systemctl enable --now NetworkManager
nmcli connection reload
systemctl restart NetworkManager
systemctl enable NetworkManager
# Disable SELinux:
sudo sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

cat /etc/selinux/config | grep SELINUX

2. Change Software Source

# Backup old repository configuration and create a new directory:
sudo mv /etc/yum.repos.d /etc/yum.repos.d.bak.$(date +%Y%m%d-%H%M%S)
sudo mkdir -p /etc/yum.repos.d
# Write Tsinghua source configuration:
cat > /etc/yum.repos.d/CentOS-Stream.repo << 'EOF'
[baseos]
name=CentOS Stream $releasever- BaseOS
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/BaseOS/$basearch/os/
gpgcheck=0
enabled=1

[appstream]
name=CentOS Stream $releasever- AppStream
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/$releasever-stream/AppStream/$basearch/os/
gpgcheck=0
enabled=1
EOF
# Clean old cache and generate new index:
sudo dnf clean all
sudo dnf makecache

# View:
dnf repolist

3. Upgrade System

# Update system (synchronize package metadata):
sudo dnf update -y
sudo dnf upgrade --refresh -y

Common Tools

# Necessary tools
sudo dnf install -y vim git curl wget net-tools zip unzip tar htop lsof
# Install packet capture tool:
cat > /root/install-common.sh << 'EOF'
#!/bin/bash
set -euo pipefail
echo "=== Update cache and enable EPEL ==="
dnf makecache || true
dnf install -y epel-release || true
dnf makecache
echo "=== Install common toolset ==="
dnf install -y \
  pciutils usbutils lshw \
  tcpdump wireshark-cli \
  nmap net-tools bind-utils iproute \
  ethtool iftop htop nethogs \
  lsof strace socat rsync bc \
  unzip zip tar gzip bzip2 xz \
  screen tmux tree jq vim git \
  python3-pip java-17-openjdk \
  sysstat atop
echo "=== Install Development Tools (optional, for compilation) ==="
dnf groupinstall -y "Development Tools" || true
echo "=== Set dumpcap permissions (allow non-root users to use tshark for packet capture) ==="
if command -v dumpcap >/dev/null; then
  DUMPCAP_PATH=$(command -v dumpcap)

# Run script
./install-common.sh

Grant Necessary Capabilities

setcap cap_net_raw,cap_net_admin+eip “${DUMPCAP_PATH}” || true echo “setcap applied to ${DUMPCAP_PATH}”else echo “warning: dumpcap not found; tshark may not be available”fiecho “=== Enable and check sysstat (sar) ===”systemctl enable –now sysstat || trueecho “=== Complete ===”echo “Common software has been installed. Brief usage examples:”echo ” tcpdump -i <iface> -w /root/capture.pcap”echo ” tshark -r /root/capture.pcap -V”echo ” tshark -i <iface> -f ‘port 554 or port 80’ -w /root/filtered.pcap”EOF

[root@localhost ~]# [root@localhost ~]# chmod +x /root/install-common.shecho “Run installation script: bash /root/install-common.sh”

[root@localhost ~]#[root@localhost ~]# bash /root/install-common.sh

Chinese and font support:sudo dnf install -y langpacks-zh_CN glibc-langpack-zhsudo localectl set-locale LANG=zh_CN.UTF-8

Disable SELinux:sudo setenforce 0sudo sed -i ‘s/^SELINUX=.*/SELINUX=disabled/’ /etc/selinux/config

Docker installation:

sudo dnf remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

sudo dnf install -y dnf-plugins-core

sudo dnf config-manager \
–add-repo
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

sudo systemctl enable –now docker

sudo systemctl status docker

Add domestic mirror accelerators for Docker:

sudo mkdir -p /etc/dockersudo tee /etc/docker/daemon.json <<-‘EOF’{ “registry-mirrors”: [https://docker.m.daocloud.io“,https://registry.docker-cn.com“,https://mirror.ccs.tencentyun.com“,https://mirror.aliyun.com
]
}
EOF

sudo systemctl daemon-reexecsudo systemctl restart docker

sudo docker run hello-world

# Disable firewall: Stop and prevent startup
systemctl stop firewalld
systemctl disable firewalld
systemctl mask firewalld

# Optional. Ensure the firewall will not be started again
systemctl stop nftables 2>/dev/null || true
systemctl disable nftables 2>/dev/null || true
systemctl mask nftables 2>/dev/null || true

systemctl stop iptables 2>/dev/null || true
systemctl disable iptables 2>/dev/null || true
systemctl mask iptables 2>/dev/null || true
# Permanently disable SELinux (effective after reboot)
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

File decompression:

dnf install -y \
unzip zip tar gzip bzip2 xz \
lrzsz p7zip p7zip-plugins \
fuse-sshfs

System and diagnostic tools:dnf install -y \
tcpdump tshark wireshark-cli nmap \
iperf3 traceroute mtr ethtool \
net-tools bind-utils whois nethogs iftop \
lsof strace socat iptraf-ng \
curl wget rsync screen tmux tree vim git \
pciutils usbutils lshw

Remote management:

dnf install -y \
openssh-server openssh-clients \
telnet lrzsz vsftpd \
firewalld policycoreutils-python-utils \
nfs-utils samba-client samba-common

# Upload files to the system
# Decompress:
tar -zxvf easynvr-linux-amd64-v7.7.287-6220587a-250930.tar.gz -C /opt/

# Grant permissions to the files:
chmod +x install.sh uninstall.sh

# Install and start:
./install.sh

# Open the EasyNVR platform via web:
# http://IP:10000

CentOS 8 Upgrade (International Version)

Change Software Source and Upgrade

CentOS 8 and CentOS 9 have better compatibility for old servers.

The official source for CentOS 8 has been taken offline, and the source needs to be changed to Vault.

sudo sed -i 's|mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/*.repo
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/*.repo

Upgrade System

sudo dnf clean all
sudo dnf makecache
sudo dnf update -y

Upgrade complete.

It is recommended to switch from CentOS to Alma Linux (created by the founders of CentOS) or Rocky Linux (more vendor support).

Complete. END.

CentOS 8 (China Version)

CentOS 8 and CentOS 9 have better compatibility for old servers.

Applicable to CentOS 8 and CentOS 7.

1. Automatically Obtain Address

After installation, the system cannot obtain a DHCP address. You need to start the corresponding UP state network card to automatically obtain an IP address.

# Open the corresponding network card configuration file with VIM
vi /etc/sysconfig/network-scripts/ifcfg-en

# In the network card file, change onboot=no to yes to allow automatic address acquisition
ONBOOT=YES

Reboot the system or restart the network card.

systemctl restart NetworkManager

Optional Command Disable SELinux (firewall):

sudo sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
cat /etc/selinux/config | grep SELINUX

2. Change Software Source

# Delete old and backup
sudo mv /etc/yum.repos.d /etc/yum.repos.d.bak.$(date +%Y%m%d-%H%M%S)

# Create YUM file
sudo mkdir -p /etc/yum.repos.d

# Tsinghua source
cat > /etc/yum.repos.d/CentOS-Vault.repo << 'EOF'
[BaseOS]
name=CentOS-8 - Base - Vault
baseurl=http://vault.centos.org/8.5.2111/BaseOS/$basearch/os/
gpgcheck=0
enabled=1

[AppStream]
name=CentOS-8 - AppStream - Vault
baseurl=http://vault.centos.org/8.5.2111/AppStream/$basearch/os/
gpgcheck=0
enabled=1

[extras]
name=CentOS-8 - Extras - Vault
baseurl=http://vault.centos.org/8.5.2111/extras/$basearch/os/
gpgcheck=0
enabled=1

[PowerTools]
name=CentOS-8 - PowerTools - Vault
baseurl=http://vault.centos.org/8.5.2111/PowerTools/$basearch/os/
gpgcheck=0
enabled=1
EOF
# Clean and index
sudo dnf clean all
sudo dnf makecache
# Verify
sudo dnf repolist

3. Upgrade System

# Update system
sudo dnf update -y
sudo dnf upgrade --refresh -y

4. Change to Static Address

# Open the corresponding network card file
nano /etc/sysconfig/network-scripts/ifcfg-enp12s0

# Enter the following new content
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no

NAME=enp12s0
DEVICE=enp12s0
UUID=f561d600-b244-4cf3-a9a5-4006baa26a49
ONBOOT=yes

# IPv4 static config
IPADDR=46.64.40.58
PREFIX=22
GATEWAY=46.64.40.1

DNS1=202.100.192.68
DNS2=8.8.8.8

# IPv6 config (keep default)
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
# Reboot or enter the following command to make the new address take effect
sudo nmcli con reload
sudo nmcli con up enp

5. Install Software (Optional)

# Basic system tools
sudo dnf install -y vim nano wget curl tar unzip zip bzip2 gzip

# Less commonly used tools
sudo dnf install -y net-tools bind-utils lsof tree htop tmux
# Upload files to the system
# Decompress:
tar -zxvf easynvr-linux-amd64-v7.7.287-6220587a-250930.tar.gz -C /opt/

# Grant permissions to the files:
chmod +x install.sh uninstall.sh

# Install and start:
./install.sh

# Open the EasyNVR platform via web:
# http://IP:10000
# Disable firewall: Stop and prevent startup
systemctl stop firewalld
systemctl disable firewalld
systemctl mask firewalld

# Optional. Ensure the firewall will not be started again
systemctl stop nftables 2>/dev/null || true
systemctl disable nftables 2>/dev/null || true
systemctl mask nftables 2>/dev/null || true

systemctl stop iptables 2>/dev/null || true
systemctl disable iptables 2>/dev/null || true
systemctl mask iptables 2>/dev/null || true
# Permanently disable SELinux (effective after reboot)
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

CentOS 7

1. Automatically Obtain Address

After installation, the system cannot obtain a DHCP address. You need to start the corresponding UP state network card to automatically obtain an IP address.

# Open the corresponding network card configuration file with VIM
vi /etc/sysconfig/network-scripts/ifcfg-en

# In the network card file, change onboot=no to yes to allow automatic address acquisition
ONBOOT=YES

Reboot the system or restart the network card.

systemctl restart NetworkManager

2. Change Software Source

# Delete and backup
sudo mv /etc/yum.repos.d /etc/yum.repos.d.bak.$(date +%Y%m%d-%H%M%S)

# Create YUM file
sudo mkdir -p /etc/yum.repos.d

#
cat > /etc/yum.repos.d/CentOS-Vault.repo << 'EOF'
[base]
name=CentOS-7 - Base - Vault
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=0
enabled=1

[updates]
name=CentOS-7 - Updates - Vault
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=0
enabled=1

[extras]
name=CentOS-7 - Extras - Vault
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=0
enabled=1

[centosplus]
name=CentOS-7 - Plus - Vault
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=0
enabled=0
EOF
# Delete upgrade cache, re-index
sudo yum clean all
sudo yum makecache

3. Upgrade System

# Update system
yum update -y
yum upgrade --refresh -y

4. Install Common Software (Optional)

# Desktop installation:
sudo yum groupinstall -y "GNOME Desktop"

sudo systemctl set-default graphical.target

sudo systemctl isolate graphical.target


# Common software:
sudo yum install -y wget curl vim nano net-tools git
sudo yum install -y epel-release
sudo yum install -y htop tree unzip zip

Install Common Software

Essential: tcpdump packet capture tool, mdadm disk array RAID tool, curl download tool, Network-Manager network management tool, nmcli address management tool, common software?

Optional: Prometheus, Grafana,

Install Essential Software

# Edit documents vim/nano, CPU memory htop, disk iotop, network bandwidth iftop, network command set net-tools, download curl/wget, compress and decompress zip/unzip/p7zip-full, view ports lsof, tree, run in the background without affecting SSH screen/tmux, software-properties-common, ca-certificates, gnupg
sudo apt update
sudo apt install -y \
    vim nano htop iotop iftop \
    net-tools curl wget \
    zip unzip p7zip-full \
    lsof tree screen tmux \
    software-properties-common \
    ca-certificates gnupg \

Install Network Debugging Tools

# Test network throughput performance iperf3, port scanning nmap, route tracing traceroute, network card driver ethtool, packet capture tcpdump, service connection status dnsutils, serial port socat, connection tracking (firewall) conntrack, view disk usage ncdu, packet capture view wireshark, iputils-ping
sudo apt install -y \
    iperf3 \
    nmap \
    traceroute \
    ethtool \
    tcpdump \
    dnsutils \
    socat \
    conntrack \
    ncdu \
    wireshark \
    iputils-ping

Run Software in the Background

1. tmux

Proven effective

# Install tmux
sudo apt install tmux -y

After starting tmux, run the software you want to run in the background; finally, exiting the current SSH will not affect the software running in the background.

# Start
tmux

# Run the software you want to run in the background

# Exit the interface
# Press Ctrl and B keys, then press D to exit, and the program will continue running in the background
# Re-enter
tmux attach

2. nohup

# Start with the program that needs to run in the background
nohup  > output.log 2>&1 &

3. screen

# Install
sudo apt install screen -y
# Create a new screen session
screen -S mywork

# Run the background program

# Exit but do not stop the program
# Press ctrl and a keys, then press d
# If successful, it will display "[detached from mywork]"

# Reconnect to the running session
screen -r mywork

RAID Software

1. mdadm

# Install mdadm
sudo apt install mdadm

# Clean the disks
sudo mdadm --zero-superblock /dev/sdb /dev/sdc /dev/sdd

# Create RAID 5 array (may take several hours)
sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd

# Create filesystem and mount; disks cannot be directly stored, they need to be mounted to a directory. (may take several hours)
sudo mkfs.ext4 /dev/md0
sudo mkdir /mnt/watchdata
sudo mount /dev/md0 /mnt/watchdata

# Enable auto-start and auto-detection
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u
# Check status. U indicates healthy, _ indicates abnormal, [3/3] indicates three are normal, blocks indicate total capacity that is unformatted.
cat /proc/mdstat

# Check detailed information of RAID disk
mdadm --detail /dev/md0

# Check remaining disk space
df -h

# Check hard disk status
lsblk

# Check if the hard disk has smart errors (hard disk health)
smartctl -a /dev/sdb

Optional Command

# Test RAID write speed
sudo dd if=/dev/zero of=/mnt/watchdata/test.img bs=1G count=2 oflag=direct

System Monitoring Software

1. htop

Proven effective, needs to be installed

# Install
apt install htop

# Run CPU performance monitoring
htop

# Press q to exit

2. top

Comes with the system

# Start
top

# Press q to exit

END.

Leave a Comment