Home / Guides

Server guide

Linux server security checklist: 12 checks you can run today

Most hacked servers were not attacked with anything clever. They had an old package, a password login, an open port nobody needed or a backup nobody tested. This checklist covers those basics, each with the command that shows where you stand.

4 min readUpdated November 2026 by the RootManage teamWorks on Ubuntu, Debian, AlmaLinux and Rocky unless noted

The short answer

Update the system, log in with keys and not passwords, stop direct root login, open only the ports you need, remove services you do not use, check file permissions and users, keep logs, and keep backups you have restored at least once.

Updates are installed

terminal
# Debian and Ubuntu
sudo apt update && apt list --upgradable
# AlmaLinux, Rocky, RHEL
sudo dnf check-update

Security updates are the single biggest item. Install them in a quiet hour, restart when the kernel or core libraries changed, and turn on automatic security updates (unattended-upgrades on Debian and Ubuntu, dnf-automatic on the Red Hat family) if you cannot patch every week.

Also check that your operating system version is still supported. A release that no longer gets updates cannot be made safe by settings alone.

SSH uses keys, not passwords

terminal
sudo sshd -T | grep -Ei 'passwordauthentication|pubkeyauthentication|permitrootlogin|maxauthtries'

You want passwordauthentication no, pubkeyauthentication yes and root login set to no or prohibit-password. sshd -T prints the setting that is really in use, which can differ from what you see in one file because drop-in files are read too. The full steps, with a safe way to test, are in the SSH hardening guide.

Only the accounts you need exist

terminal
awk -F: '$3 == 0 {print $1}' /etc/passwd
sudo awk -F: '($2 == "") {print $1}' /etc/shadow
sudo lastlog | head -20

The first command lists accounts with the powers of root. It should print root and nothing else. The second lists accounts with an empty password, which should print nothing. Lock or delete accounts of people who have left, and give admins sudo instead of sharing the root password.

A firewall is on and closed by default

terminal
# Ubuntu / Debian with ufw
sudo ufw status verbose
# AlmaLinux / Rocky with firewalld
sudo firewall-cmd --list-all

The rule should be: deny incoming, then allow only SSH, web and whatever else you really use. Do not turn a firewall on over SSH before you have allowed SSH, or you lock yourself out.

You know every open port

terminal
sudo ss -tulpn

Read the list line by line. A database (3306, 5432), Redis (6379) or a control panel login that listens on all addresses (0.0.0.0 or [::]) should usually be limited to the server itself or to a few trusted addresses. If you do not know what a listening program is, find out before you decide it is harmless.

Services you do not use are off

terminal
systemctl list-unit-files --state=enabled --type=service

Every running service is something that can have a bug. Disable what you do not need, such as old mail servers, test web servers, FTP or telnet. Use sudo systemctl disable --now name and check the site still works.

File permissions are sane

terminal
ls -l /etc/shadow /etc/passwd /etc/ssh/sshd_config
sudo find / -xdev -type f -perm -0002 -not -path "/proc/*" 2>/dev/null | head
sudo find / -xdev -perm -4000 -type f 2>/dev/null

/etc/shadow should be readable only by root (and the shadow group on some systems). Files that anyone can write (the second command) are a risk, especially in web folders. The third lists programs that run with the owner's rights (SUID). The normal list is short and stable; a SUID program in a home or temp folder is a red flag.

Nothing odd runs from temp folders or cron

terminal
sudo ls -la /tmp /var/tmp /dev/shm
sudo crontab -l; ls /etc/cron.d /var/spool/cron* 2>/dev/null

Miners and backdoors like /tmp and /dev/shm, and they often start from a cron entry or a systemd timer. Look for programs you did not install and for cron lines that download and run a script (curl ... | sh).

Logs exist and you can read them

terminal
sudo journalctl -u ssh -u sshd --since '1 day ago' | grep -i 'failed' | tail
sudo lastb 2>/dev/null | head
last -n 10

Failed logins from the internet are normal. A successful login from a place or time you do not recognise is not. Make sure logs are kept for weeks, not hours, and consider sending them to another machine.

The kernel has basic protections

terminal
sysctl net.ipv4.conf.all.rp_filter net.ipv4.tcp_syncookies kernel.randomize_va_space

Sensible values are tcp_syncookies = 1, randomize_va_space = 2 and reverse-path filtering on. Most distributions set these already; this check only confirms nobody switched them off.

Web, PHP and database software is supported

  • Check the PHP version your sites use. Versions that no longer get security fixes should be moved to a supported one.
  • Check MySQL or MariaDB the same way, and that the database listens only where it should.
  • Keep .git folders, .env files and database dumps out of web folders: anyone who guesses the address can download them.

Backups exist, are off the server, and restore

Backups kept only on the same disk go with the server when it fails or is encrypted by ransomware. Keep a copy somewhere else, and restore one to a test location at least once. Our restore test guide shows how.

Check your work in one go

Doing all twelve by hand takes an hour and you will forget some. The RootManage security audit is a read-only script that runs these checks (and many more, including cPanel, Plesk and DirectAdmin settings) and prints a score with a fix for each finding. You can run it yourself without an account: see the free Linux security audit. It is a review of settings, not a penetration test, and it will not find unknown holes in your own applications.

Questions people ask

How often should I run a server security check?

After every big change, and at least once a month. A weekly automatic check is better, because a setting can change without anyone noticing.

Is a firewall enough?

No. A firewall limits who can reach a service. It does not fix an old package, a weak password or a vulnerable website on an open port.

Does this work for cPanel servers?

The basics are the same. A cPanel server also needs its own settings checked; see the [cPanel security checklist](/guides/cpanel-server-security-checklist).

Can I be sure my server is secure after this?

No one can promise that. These checks remove the most common easy ways in. Keep updating, keep backups and watch your logs.

Want a person to look at it?

Tell us what you see. We reply with what we think is wrong and what it would take to fix it.