• Stars
    star
    580
  • Rank 77,010 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Linux Optimizer

Linux Optimizer

This Bash script automates the optimization of your Linux server.

It performs the following tasks:

  1. Set the server TimeZone to Asia/Tehran.

  2. Update, Upgrade, and Clean the server:

    • Update
    • Upgrade
    • Dist-Upgrade
    • AutoRemove
    • AutoClean
    • Clean
  3. 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

  4. Enable Packages at Server Boot.

  5. Create & Enable SWAP File:

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

  7. Optimize the SYSCTL Configs.

    • Optimize SWAP.
    • Optimize Network Settings.
    • Activate BBR.
    • Optimize the Kernel.

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

  8. Optimize SSH:

    • Back up the original sshd_config file.
    • 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 & Compression.
    • Enable X11 Forwarding.

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

  9. Optimize the System Limits:

    • ulimit -c -d -f -i -n -q -u -v -x -s -l optimizations.
    • Soft & Hard nproc limits.
    • Soft & Hard nofile limits.
  10. Optimize UFW & Open Common Ports.

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

Reboot at the end is Recommended.

Pre-Run

Packages wget and sudo must be installed.

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

Run

Tested on: Ubuntu 18+, Debian 11+, CentOS 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

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.

More Repositories

1

SNI-Finder

SNI Finder
Go
199
star
2

Blockchain

A Simple Blockchain
HTML
128
star
3

IBM-IT-Project-Manager-Professional-Certificate

IBM IT Project Manager Professional Certificate
21
star
4

Microsoft-Cybersecurity-Analyst-Professional-Certificate

Microsoft Cybersecurity Analyst Professional Certificate
20
star
5

Tools

Various scripts to make my life easier.
Shell
20
star
6

Google-Cybersecurity-Professional-Certificate

Google Cybersecurity Professional Certificate
18
star
7

Coursera-Software-Design-and-Architecture-Specialization

Coursera Software Design and Architecture Specialization
Java
16
star
8

CS50-Cybersecurity

CS50 Cybersecurity
15
star
9

Google-IT-Support-Professional-Certificate

Google IT Support Professional Certificate
Python
15
star
10

Coursera-Programming-Languages

Coursera Programming Languages Part A,B,C
Standard ML
14
star
11

IBM-IT-Support-Professional-Certificate

IBM IT Support Professional Certificate
14
star
12

Coursera-Introduction-to-Discrete-Mathematics-for-Computer-Science-Specialization

Coursera Introduction to Discrete Mathematics for Computer Science Specialization
Python
14
star
13

SwapMaker

Linux Swap Space Maker
Shell
13
star
14

Trivia-CS50X

Trivia-CS50X
HTML
13
star
15

Coursera-Data-Structures-and-Algorithms-Specialization

Coursera Data Structures and Algorithms Specialization
Python
13
star
16

Coursera-Microsoft-365-Fundamentals-Specialization

Coursera Microsoft 365 Fundamentals Specialization
13
star
17

hawshemi

Config files for my GitHub profile.
13
star
18

ip-tools

IP Tools
Python
13
star
19

Finance-CS50X

Finance-CS50X
Python
13
star
20

forex-position-size-calculator

Forex Position Size Calculator
Python
13
star
21

Search-CS50W

Search-CS50W
HTML
12
star
22

kezab-website

Kezab Village Website
HTML
12
star
23

SHA-1-password-cracker-freecodecamp

SHA-1 Password Cracker Freecodecamp
Python
12
star
24

port-scanner-freecodecamp

Port Scanner Freecodecamp
Python
12
star
25

AverageCalculator

Average calculator with user inputs.
Python
12
star
26

Google-IT-Automation-with-Python-Professional-Certificate

Google IT Automation with Python Professional Certificate
Python
12
star
27

Commerce-CS50W

Commerce CS50W
Python
12
star
28

Wiki-CS50W

Wiki-CS50W
Python
12
star
29

anonymous-message-board-freecodecamp

Anonymous Message Board Freecodecamp
JavaScript
12
star
30

Birthdays-CS50X

Birthdays-CS50X
HTML
12
star
31

CS50X

CS50x Problems & Lab Solutions.
C
12
star
32

Coursera-Python-for-Everybody-Specialization

Coursera Python for Everybody Specialization
Python
12
star
33

Homepage-CS50X

Week 8 Project from CS50.
HTML
12
star
34

secure-real-time-multiplayer-game-freecodecamp

Secure Real Time Multiplayer Game Freecodecamp
JavaScript
12
star
35

stock-price-checker-freecodecamp

Stock Price Checker (freecodecamp)
JavaScript
12
star
36

time-calculator-freecodecamp

Time Calculator freecodecamp
Python
11
star
37

polygon-area-calculator-freecodecamp

Polygon Area Calculator freecodecamp
Python
11
star
38

budget-app-freecodecamp

Budget App freecodecamp
Python
11
star
39

Palo-Alto-Networks-Cybersecurity-Professional-Certificate

Palo Alto Networks Cybersecurity Professional Certificate
11
star
40

arithmetic-formatter-freecodecamp

Arithmetic Formatter freecodecamp
Python
11
star
41

probability-calculator-freecodecamp

Probability Calculator freecodecamp
Python
11
star
42

CompTIA-a_cyber-Specialization

CompTIA a+_cyber Specialization
10
star
43

Blockchain-Specialization

Blockchain Specialization
Solidity
10
star
44

JournalCalendar

Journal Calendar App
Python
9
star
45

Cybersecurity-Operations-Fundamentals-Specialization

Cybersecurity Operations Fundamentals Specialization
9
star
46

Akamai-Network-Engineering-Professional-Certificate

Akamai Network Engineering Professional Certificate
9
star
47

Network-Automation-Engineering-Fundamentals-Specialization

Network Automation Engineering Fundamentals Specialization
8
star
48

Network-CS50W

Network CS50W
Python
8
star
49

Mail-CS50W

Mail CS50W
Python
8
star
50

CompTIA-a_network-Specialization

CompTIA a+_ network Specialization
8
star
51

Healthcare-IT-Support-Specialization

Healthcare IT Support Specialization
8
star
52

Akamai-Customer-Consulting-and-Support-Professional-Certificate

Akamai Customer Consulting and Support Professional Certificate
8
star
53

Fintech-Foundations-Applications-of-Financial-Technology-Specialization

Fintech: Foundations & Applications of Financial Technology Specialization
7
star
54

SSL

A Script to manage SSL Certifications.
Shell
3
star