Has My Linux Server Been Hacked? Signs and Next Steps
Linux server hacked? Signs such as high CPU, unknown processes and users, the commands to check, a clean rebuild and the steps to stop it happening again.

Contents
If you suspect your Linux server has been hacked, you need to act quickly but without panicking. A compromised server doesn't only put your own data at risk; it can also be used to attack other systems, send spam or mine cryptocurrency. That can lead your provider to stop the server and get your IP address onto blacklists.
This guide covers the signs that a Linux server has been compromised, the places you need to check, how to rebuild the server safely and the measures that stop the same thing from happening again. If the problem is a website rather than your server, take a look at our Website hacked? What to do guide.
The signs
- Constantly high CPU usage: The most common thing found on compromised servers is a cryptocurrency miner.
- Processes you don't recognize: Programs with random names, or programs that look like system processes such as
kworkerorsystemdbut run from odd locations. - Users or SSH keys you don't know about.
- Scheduled tasks you didn't add.
- Unexpected outgoing traffic: The server connecting to lots of outside addresses, sending email or generating heavy traffic.
- An abuse report from your provider: A notice that attacks, spam or scans have come from your server.
- Changed files or commands that don't work: Modified system programs, deleted logs.
None of these alone is proof; high CPU usage can also come from a stuck application. But if several show up together, assume the server has been compromised. We cover performance problems in our Why is my server slow? guide.
First step: limit the damage
- Don't delete your data and don't rebuild the server straight away. First you need to understand what happened and recover your data.
- Stop the server from causing harm to others. If the server is being used for attacks or spam, restrict outgoing traffic in the firewall, or shut the server down and continue investigating from the panel's web console.
- Tell your provider. If you've received an abuse report, let them know you've noticed the problem and are dealing with it.
- Get ready to change the passwords of accounts with access to the server, but make the actual changes after the clean rebuild.
Where to look
The commands below help you understand what the attacker did and how they got in. The attacker may have modified system programs, so don't trust the output completely; the goal is to gather evidence, not to declare the server "clean".
Processes and CPU:
htop
ps auxf --sort=-%cpu | head -20
sudo ls -l /proc/<PID>/exe
The last command shows which file a suspicious process actually runs from. Programs running from folders such as /tmp, /dev/shm or /var/tmp are a typical sign.
Network connections:
sudo ss -tunp
Look for connections to outside addresses you don't recognize and listening ports you didn't open.
Logins:
last -a | head -30
sudo lastb | head -30
sudo grep "Accepted" /var/log/auth.log
last shows successful logins and lastb failed attempts. The Accepted lines in auth.log show which user logged in, from which IP address and whether with a password or a key. On AlmaLinux, the log file is /var/log/secure.
Users and SSH keys:
awk -F: '$3 >= 1000 || $3 == 0 {print $1}' /etc/passwd
sudo cat /root/.ssh/authorized_keys
cat ~/.ssh/authorized_keys
A user other than root with user ID 0, or a key you don't recognize, is a sure sign.
Scheduled tasks and services:
sudo crontab -l
for u in $(cut -d: -f1 /etc/passwd); do sudo crontab -l -u $u 2>/dev/null | sed "s/^/$u: /"; done
ls -la /etc/cron.* /etc/cron.d
systemctl list-units --type=service --state=running
Attackers often add a cron job or a systemd service so they keep running after the server restarts. We cover cron in our What is cron? article.
Recently changed files:
sudo find /etc /usr/bin /usr/sbin /var/www -mtime -7 -type f 2>/dev/null | head -50
Write down what you find; it helps you understand the way in and close the same hole.
Rebuild instead of cleaning up
It's tempting to "clean up" a compromised server, but the attacker may have left a backdoor you haven't noticed. The safest route is to rebuild:
- Recover your data: Copy database dumps, user-uploaded files and your settings. Bring back executables, scripts and application code from trusted sources (your own Git repository, official packages), not from the backup.
- Install the operating system from scratch. Reinstalling wipes the data on the disk, so make sure you've taken everything you need to recover first.
- Don't expose the server to the internet until it's secured: Install updates, set up SSH key login, turn off password login and enable the firewall.
- Reinstall your applications and restore the data you recovered, checking it as you go.
If you don't know when the attack started, your recent backups may be affected too; inspect the files you restore carefully. We cover setting up a backup routine in our Server backups guide.
Renew every secret
After the clean rebuild, and from a clean computer, change:
- Every user password on the server and the SSH keys (create a new key pair).
- Database passwords.
- API keys, tokens and secrets in your applications'
.envand config files: payment providers, email services, cloud storage, Discord bot tokens. - The passwords of other systems accessed from the server.
- The password of your account with your hosting provider; turn on two-factor authentication too.
Close the way in
If the same hole isn't closed, the new server will soon be compromised too. The most common ways in:
- SSH logins with weak or leaked passwords: Allow key-only login and install Fail2ban.
- Outdated web applications and plugins.
- Services left open to the internet: Databases, Redis, admin panels. Open only the ports you really need; the details are in our How to use UFW guide.
- Leaked keys:
.envfiles accidentally pushed to a Git repository.
We've collected every measure step by step in our Linux server security checklist.
On Nodesty servers
On Nodesty AMD Ryzen 9 9950X VPS and AMD EPYC 7763 VPS plans, you can shut down your server from the client panel, connect without SSH through the panel's web console and reinstall the operating system. Daily backups are free on VPS plans and are kept for 7 days, so you can recover your data from a backup taken before the attack. nShield L3–L7 DDoS protection protects your server from attacks coming from outside. To protect your account, turn on two-factor authentication in the client panel.
Frequently Asked Questions
How do I know if my server has been hacked?
The most common signs are constantly high CPU usage, processes you don't recognize, users or SSH keys you don't know about, scheduled tasks you didn't add, unexpected outgoing traffic and abuse reports from your provider. None of these alone is proof, but if several show up together, assume the server has been compromised.
Can I clean up a hacked server and keep using it?
It's not recommended. Once an attacker has got in, they may have left a backdoor you haven't noticed, and a server you think you've cleaned can be used again. The safest route is to recover your data, rebuild the server with a clean operating system and reinstall your applications from trusted sources.
How might the attacker have got into my server?
The most common ways in are SSH logins with weak or leaked passwords, outdated web applications and plugins, databases or admin panels left open to the internet and leaked API keys. Go through the logs to try to find the way in; rebuilding without closing the same hole just repeats the problem.
Could my backups be affected too?
Yes. If you don't know when the attack started, recent backups may also contain malicious files. Restore your data, such as databases and user files, but reinstall application code from trusted sources rather than from the backup, and check the files you restore.
Why is my server using 100 percent CPU?
The most common thing found on compromised servers is a cryptocurrency miner; it keeps the CPU at 100 percent around the clock and often uses fake names or names that look like system processes. That said, high CPU usage can also come from a stuck application. Find the process with htop and check where the file it runs from lives.
Which passwords should I change?
Change every user password on the server, the SSH keys, the database passwords, the API keys and secrets in your applications' .env and config files, the passwords of services that have access to the server and the password of your account with your hosting provider. Make the changes after the clean rebuild, from a clean computer.
About the author
Nodesty Team · Infrastructure & Support
The Nodesty team runs our servers, network and DDoS protection day to day and answers customer support requests around the clock. These guides come from that work.
Related articles

WordPress Security: A Hardening Checklist for Your Site
WordPress security checklist: updates, strong logins and 2FA, file permissions, wp-config.php, no PHP in uploads, XML-RPC, firewalls and tested backups.

How to Install Let's Encrypt SSL with Certbot (Nginx and Apache)
How to install Let's Encrypt SSL with Certbot on a Linux server: Nginx and Apache setup, automatic renewal, wildcard certificates and common errors.

How to Set Up SSH Keys and Disable Password Login
How to set up SSH keys: create an ed25519 key with ssh-keygen, copy it to your Linux server, test the login and safely turn off password login.