Operations 20 min read

All‑in‑One Linux Init Script: Automate Setup for Rocky, AlmaLinux, Ubuntu, and More

This article introduces a comprehensive shell script that automates initial system configuration—root login, network, hostname, repository, firewall, SELinux, swap, SSH, and more—across dozens of Linux distributions, provides source links, detailed feature tables, version‑specific changelogs, and step‑by‑step usage instructions.

Raymond Ops
Raymond Ops
Raymond Ops
All‑in‑One Linux Init Script: Automate Setup for Rocky, AlmaLinux, Ubuntu, and More

The repository (Gitee: https://gitee.com/raymond9/shell, GitHub: https://github.com/raymond999999/shell) contains a Bash initialization script that can be used on many Linux distributions to perform common post‑install tasks.

Supported Functions

Set root user login

Rename network interfaces

Configure network (IP, netmask, gateway, DNS) for single or dual NICs

Set hostname

Configure repository mirrors (where applicable)

Recommend additional software packages

Disable firewall (ufw or firewalld)

Disable SELinux (where present)

Disable AppArmor (openSUSE Leap 15 only)

Disable swap

Set system timezone

Optimize resource limits

Optimize kernel parameters

Optimize SSH settings

Change SSH port

Set system aliases

Configure vimrc

Install and configure mail service

Customize PS1 prompt

Set default editor to vim

Configure history format

Disable Ctrl+Alt+Del reboot

Ubuntu‑specific: uninstall unnecessary packages, remove snap

Reboot or shutdown options

Supported Operating Systems

Rocky Linux 8/9/10, AlmaLinux 8/9/10, CentOS 7, CentOS Stream 8/9/10

Ubuntu Server 18.04/20.04/22.04/24.04 LTS

Debian 11/12/13

openEuler 22.03/24.03 LTS

AnolisOS 8/23

OpenCloudOS 8/9

openSUSE Leap 15/16

Kylin Server V10/V11

UOS Server V20

Version Update Highlights

v10 : Added traditional eth0/eth1 naming for Rocky 9, AlmaLinux 9, CentOS Stream 9/10; switched to config‑file IP setting for newer kernels; GRUB path handling for UEFI; fixed Ubuntu 22.04 IP reset after reboot; added support for Rocky 10, AlmaLinux 10, Debian 13.

UOS Server : Added support for UOS V20 and related GRUB handling.

Kylin Server : Added support for Kylin V10/V11 and related GRUB handling.

openSUSE : Added Leap 15 support, fixed SWAP and Ctrl+Alt+Del bugs, added Leap 16 support with root‑login requirement.

OpenCloudOS : Added support for 8/9, fixed SWAP and Ctrl+Alt+Del bugs, added PowerTools repository enablement.

AnolisOS : Added support for 8/23, fixed SWAP and Ctrl+Alt+Del bugs, added traditional interface naming.

openEuler : Added support for 22.03/24.03, fixed SWAP and Ctrl+Alt+Del bugs, unified NIC handling.

v9 : Updated CentOS Stream 8/9/10 repository handling, added Ubuntu 24.04 support, added AlmaLinux devel repo, fixed various bugs.

v8‑v1 : Progressive addition of distro support and feature refinements, bug fixes, and repository handling changes.

Usage Notes

The script must be executed as the root user.

Install lrzsz to transfer the script (e.g., sudo apt -y install lrzsz on Ubuntu).

Run the script with bash reset_v10.sh (or the appropriate version file).

After launch a menu is displayed with 26 numbered options covering all supported tasks.

Select the desired option number and follow any prompts (e.g., entering a new root password, choosing a repository, etc.).

For CentOS Stream 9/10, ensure the auxiliary update_mirror.pl script is present in the same directory before selecting repository options.

After completing configuration, reboot or log out/in to apply changes.

Example Commands (Ubuntu)

# Install transfer tool
sudo apt -y install lrzsz
# Receive script
rz -E
# List files
ls
# Execute script
bash reset_v10.sh

Example Commands (CentOS Stream)

# Install transfer tool
dnf install -y lrzsz
# Receive script
rz -E
# List files
ls
# Execute script
bash reset_v10.sh

After the script finishes, you can use the menu to perform additional tasks such as disabling firewalls, configuring SSH, or installing recommended packages.

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.

AutomationOpsLinuxServer SetupSystem 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.