Giter Club home page Giter Club logo

linux-optimizer's Introduction

Linux Optimizer

This Bash script automates the optimization of your Linux server.

It performs the following tasks:

  1. Fix hosts file and DNS (temporarily):

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

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

    • Add 1.1.1.1, 1.0.0.1, 8.8.8.8 and 8.8.4.4 to /etc/resolv.conf.

    Original dns 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 LTS Kernel (Only on Ubuntu & Debian):

  5. Install Useful Packages:

    apt-transport-https apt-utils autoconf automake bash-completion bc binutils binutils-common binutils-x86-64-linux-gnu build-essential busybox ca-certificates cron curl dialog epel-release gnupg2 git haveged htop iptables iptables-persistent jq keyring libssl-dev libsqlite3-dev libtool locales lsb-release make nano net-tools nftables packagekit preload python3 python3-pip qrencode socat screen software-properties-common ufw unzip vim wget zip

  6. Enable Packages at Server Boot.

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

  8. Create & Enable SWAP File:

    • Swap Path: "/swapfile"
    • Swap Size: 2Gb
  9. Enable IPv6 Support.

  10. Optimize the SYSCTL Configs:

    • Optimize SWAP.
    • Optimize Network Settings.
    • Activate BBR (BBRv3 with XanMod).
    • Optimize the Kernel.

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

  11. Optimize SSH:

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

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

  12. Optimize the System Limits:

    • Soft and Hard ulimit -c -d -f -i -l -n -q -s -u -v -x optimizations.
  13. Optimize UFW and open Common Ports:

    • Open Ports SSH, 80, 443.
    • With IPv6, TCP & UDP.

Reboot at the end is Recommended.

Prerequisites

Ensure that the sudo and wget 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.

linux-optimizer's People

Contributors

hawshemi avatar samsesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.