Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Linux Optimizer

License

NotificationsYou must be signed in to change notification settings

hawshemi/linux-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This Bash script automates the optimization of your Linux server.

Notes:

  1. This script is designed for execution on Linux server environments, including VPS, VDS, Dedicated, and Bare Metal systems. It is not recommended for use on Linux desktop environments.
  2. Modifying the kernel (options 1 and 2) may result in removing or resetting some GPU drivers.
  3. Some VMs do not support kernel changes (options 1 and 2). Installing XanMod could cause the VM to break. Please be cautious and test beforehand.

It performs the following tasks:

  1. Fixhosts file and DNS(temporarily):

    • Check and add 127.0.1.1 and server hostname to/etc/hosts.

    Originalhosts file is backed up at/etc/hosts.bak.

    • AddCloudflare-Security DNS servers(1.1.1.2, 1.0.0.2) nameservers to/etc/resolv.conf.

    Originaldns file is backed up at/etc/resolv.conf.bak.

  2. Update, Upgrade, and Clean the server:

    • Update
    • Upgrade
    • Full-Upgrade
    • AutoRemove
    • AutoClean
    • Clean
  3. Disable Terminal Ads(Only on Ubuntu).

  4. Install XanMod Kernel(Only on Ubuntu & Debian):

  5. Install Useful Packages:

    apt-transport-httpsapt-utilsautoconfautomakebash-completionbcbinutilsbinutils-commonbinutils-x86-64-linux-gnubuild-essentialbusyboxca-certificatescroncurldialogepel-releasegnupg2githavegedhtopjqkeyringlibssl-devlibsqlite3-devlibtoollocaleslsb-releasemakenanonet-toolspackagekitpreloadpython3python3-pipqrencodesocatscreensoftware-properties-commonufwunzipvimwgetzip

  6. Enable Packages at Server Boot.

  7. Set the server TimeZone to the VPS IP address location.

  8. Create & EnableSWAP File:

    • Swap Path:"/swapfile"
    • Swap Size:2Gb
  9. Optimize theSYSCTL Configs:

    • Optimize File System Settings.
    • Optimize Network Core Settings.
    • OptimizeSWAP.
    • OptimizeTCP andUDP Settings.
    • OptimizeUNIX Domain Sockets Settings.
    • OptimizeVirtual memory (VM) Settings.
    • Optimize Network Configuration Settings.
    • Optimize the Kernel.
    • ActivateBBR(BBRv3 with XanMod).

    Original file is backed up at/etc/sysctl.conf.bak.

  10. OptimizeSSH:

    • Disable DNS lookups for connecting clients.
    • Remove less efficient encryption ciphers.
    • Enable and Configure TCP keep-alive messages.
    • Allow TCP forwarding.
    • Enable gateway ports, Tunneling and compression.
    • Enable X11 Forwarding.

    Original file is backed up at/etc/ssh/sshd_config.bak.

  11. Optimize theSystem Limits:

    • Soft and Hardulimit-c -d -f -i -l -n -q -s -u -v -x optimizations.
  12. OptimizeUFW and open Common Ports:

    • Open PortsSSH,80,443.
    • WithIPv6,TCP &UDP.

Reboot at the end is recommended.

Prerequisites

Ensure that thesudo andwget packages are installed on your system:

  • Ubuntu & Debian:
sudo apt update -q && sudo apt install -y sudo wget
  • CentOS & Fedora:
sudo dnf up -y && sudo dnf install -y sudo wget

Run

Tested on: Ubuntu 20+, Debian 11+, CentOS Stream 8+, AlmaLinux 8+, Fedora 37+

Root Access is Required. If the user is not root, first run:

sudo -i

Then:

wget "https://raw.githubusercontent.com/hawshemi/Linux-Optimizer/main/linux-optimizer.sh" -O linux-optimizer.sh && chmod +x linux-optimizer.sh && bash linux-optimizer.sh

Menu Image

Debian & Ubuntu:

debian-based-menu

CentOS, AlmaLinux & Fedora:

rhel-based-menu

Disclaimer

This script is provided as-is, without any warranty or guarantee. Use it at your own risk.

License

This script is licensed under the MIT License.


[8]ページ先頭

©2009-2025 Movatter.jp