Operations 19 min read

Comprehensive Multi‑Distro Linux Initialization Script Guide

This article presents a complete collection of shell scripts for initializing a wide range of Linux distributions—including Rocky, AlmaLinux, CentOS, Ubuntu, Debian, openEuler, AnolisOS, OpenCloudOS, openSUSE, Kylin Server, and Uos Server—detailing supported features, version‑specific updates, and step‑by‑step usage instructions.

Raymond Ops
Raymond Ops
Raymond Ops
Comprehensive Multi‑Distro Linux Initialization Script Guide

Supported Functions and Systems

Rename network interfaces, configure network (IP address, netmask, gateway, DNS) for single or dual NICs, set hostname, configure mirror repositories, recommend minimal installation packages, disable firewall, disable SELinux, disable swap, set system timezone, optimize resource‑limit and kernel parameters, optimize SSH, change SSH port, set system alias, configure vimrc, install and configure mail service, set PS1, set default editor to vim, configure history format, disable Ctrl+Alt+Del reboot, enable root login on Ubuntu/Debian, uninstall unnecessary packages and snap on Ubuntu.

Supported distributions: Rocky Linux 8/9/10, AlmaLinux 8/9/10, CentOS 7, CentOS Stream 8/9/10, Ubuntu 18.04/20.04/22.04/24.04, Debian 11/12, openEuler 22.03/24.03, AnolisOS 8/23, OpenCloudOS 8/9, openSUSE 15, Kylin Server V10, Uos Server V20.

Version Update Log

v10: added traditional NIC names eth0 and eth1 for Rocky 9, AlmaLinux 9, CentOS Stream 9/10; switched IP configuration to file‑based due to nmcli changes; unified handling of single/dual NICs; added GRUB handling for UEFI where grub.cfg location changed; optimized IP changes on Ubuntu/Debian; fixed Ubuntu 22.04 IP reset after reboot; fixed NIC‑rename bugs; added support for Rocky 10 and AlmaLinux 10; various bug fixes.

Uos Server: added support for Uos Server V20; GRUB handling for UEFI NIC rename; bug fixes.

Kylin Server: added support for Kylin Server V10; GRUB handling for UEFI NIC rename; bug fixes.

openSUSE: added support for openSUSE 15; fixed SWAP disabling, Ctrl+Alt+Del disabling, PS1 setting; renamed packages ( pcre-tools, libopenssl-devel); unified NIC handling; fixed DNS setting.

OpenCloudOS: added support for OpenCloudOS 8/9; fixed SWAP and Ctrl+Alt+Del disabling; added traditional NIC names for OpenCloudOS 9; file‑based IP configuration; unified NIC handling; GRUB handling for UEFI; added PowerTools repository for OpenCloudOS 8; bug fixes.

AnolisOS: added support for AnolisOS 8/23; fixed SWAP and Ctrl+Alt+Del disabling; added traditional NIC names; file‑based IP configuration; unified NIC handling; GRUB handling for UEFI; bug fixes.

openEuler: added support for openEuler 22.03/24.03; fixed SWAP and Ctrl+Alt+Del disabling; unified NIC handling; GRUB handling for UEFI; bug fixes.

v9: updated for end‑of‑life of CentOS Stream 8 and CentOS 7, switched to vault repositories; added Ubuntu 24.04 support (netplan, DEB822 repo format, ssh service name); added Debian 11/12 support; added AlmaLinux devel repository; fixed Ctrl+Alt+Del disabling; added CentOS Stream 10 support, updated SWAP handling, renamed packages to pcre2 / pcre2-devel; bug fixes.

v8: added AlmaLinux 8/9 support; added Ubuntu snap removal.

v7: fixed numerous bugs in repository configuration, IP setting, system alias, kernel parameter optimization.

v6: removed CentOS 6/8 support after official EOL; provided Perl‑based mirror update scripts.

v5–v1: progressive additions of network configuration, firewall, SELinux, SWAP, timezone, resource limits, kernel tuning, SSH hardening, system alias, vimrc, mail service, PS1, editor defaults, history format, root login on Ubuntu/Debian, and minimal package recommendations.

Reset Script Usage Notes

The script must be executed as the root user.

# Rocky, AlmaLinux, CentOS, openEuler, AnolisOS, OpenCloudOS, openSUSE, Kylin Server, and Uos Server can use root login directly; Ubuntu and Debian require enabling root login first.
# Install lrzsz to transfer the script
sudo apt -y install lrzsz
rz -E   # receive script file
bash reset_v10.sh

After selecting menu option 21 , you can set the root password for Ubuntu/Debian.

When configuring mirror repositories on CentOS Stream 9/10, ensure the helper script update_mirror.pl is placed in the same directory as the reset script; otherwise the process will abort.

# Install lrzsz on CentOS
dnf -y install lrzsz
rz -E   # receive script and update_mirror.pl
bash reset_v10.sh   # run the reset script
# Follow the interactive menu to choose repository options (e.g., base, epel, CRB, PowerTools)

Other functions can be selected from the interactive menu (1‑26) as needed.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AutomationOperationsLinuxshell scriptSystem Initialization
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.