如何從Linux服務器掃描並刪除惡意軟件
首先檢查異常網絡連接、未知進程、可疑用戶或計劃任務、系統文件修改及日誌異常;2. 安裝並運行ClamAV掃描惡意軟件,使用rkhunter和chkrootkit檢測rootkit;3. 對可疑文件使用file、strings、stat等命令分析,並通過VirusTotal核驗,檢查進程的文件和端口占用;4. 終止惡意進程,刪除惡意文件和計劃任務,更新系統,修改密碼,關閉不必要的服務和端口,啟用自動更新,配置SSH密鑰登錄並部署fail2ban;5. 若係統嚴重感染,尤其是發現rootkit,應備份已掃描的必要數據後重裝系統以確保徹底清除威脅。
If you suspect your Linux server has been compromised or is running malicious software, acting quickly is essential. Unlike desktop systems, Linux servers often run critical services, making malware detection and removal a high-priority task. Here's how to scan for and remove malware effectively.

1. Check for Signs of Compromise
Before running scans, look for common indicators of malware or unauthorized access:
- Unusual network activity : Use
netstat -tulnp
orss -tulnp
to list active connections and identify suspicious outbound connections. - Unknown processes : Run
ps auxf
ortop
to review running processes. Look for unfamiliar or obfuscated names. - Unexpected users or cron jobs : Check
/etc/passwd
for unknown users and review cron jobs withcrontab -l
andls /etc/cron.*
. - Modified system binaries : Tools like
rkhunter
andchkrootkit
can detect replaced binaries (eg,ls
,ps
) used by rootkits. - Log anomalies : Review
/var/log/auth.log
(or/var/log/secure
on RHEL) for failed login attempts or unexpected root logins.
2. Install and Run Malware Scanning Tools
Use trusted open-source tools to scan your system. Install them from official repositories.

ClamAV – General Malware Scanner
ClamAV is widely used for detecting malware, trojans, and phishing content.
# Install ClamAV sudo apt update && sudo apt install clamav clamav-daemon -y # Debian/Ubuntu sudo yum install epel-release && sudo yum install clamav # RHEL/CentOS # Update virus definitions sudo freshclam # Scan the entire system (exclude /proc, /sys, /dev to avoid errors) sudo clamscan -r --exclude-dir=^/proc --exclude_dir=^/sys --exclude_dir=^/dev / # To remove infected files automatically (use with caution) sudo clamscan -r --remove --exclude_dir=^/proc --exclude_dir=^/sys --exclude_dir=^/dev /
Note: ClamAV is more effective for Windows malware on file servers, but can still catch known Linux threats.
rkhunter – Rootkit Detection
Rootkits hide deep in the system. rkhunter checks for known rootkit signatures and system anomalies.
# Install sudo apt install rkhunter # Debian/Ubuntu sudo yum install rkhunter # RHEL/CentOS # Update and run test sudo rkhunter --update sudo rkhunter --check # Review the log at /var/log/rkhunter.log
chkrootkit – Lightweight Rootkit Scanner
Another tool for detecting rootkits.
# Install and run sudo apt install chkrootkit sudo chkrootkit
3. Analyze Suspicious Files and Processes
If a scan or manual check finds something suspicious:
- Identify the file : Use
file /path/to/suspicious
to see what type it is. - Check hash against known malware : Upload suspicious files (if safe) to VirusTotal or use
clamscan
on them. - Inspect with strings : Run
strings /path/to/file | head -20
to see readable text—can reveal C2 servers or commands. - Check file origin : Use
stat
andls -la
to see creation/modification times and ownership. - Search for related files : Use
find / -name "*suspicious_pattern*" 2>/dev/null
.
If a process is suspicious:
- Use
lsof -p <PID>
to see what files and ports it's using. - Use
ps aux | grep <PID>
to see command line arguments.
4. Remove Malware and Harden the System
Once malware is identified:
- Kill malicious processes :
sudo kill -9 <PID>
- Delete malicious files :
sudo rm -f /path/to/malware
- Remove malicious cron jobs or startup entries :
- Edit
crontab -e
or check/etc/cron.d/
- Check
/etc/rc.local
, systemd services (systemctl list-unit-files
), and init scripts.
- Edit
Then, take steps to prevent reinfection:
- Update the system :
sudo apt upgrade && sudo apt autoremove # Debian/Ubuntu sudo yum update # RHEL/CentOS
- Change passwords for root and user accounts.
- Disable unused services and close unnecessary firewall ports.
- Enable automatic security updates where possible.
- Use SSH key authentication and disable root login over SSH.
- Install fail2ban to block brute-force attempts.
- Back up only essential data (after scanning it).
- Reinstall the OS from scratch.
- Restore services and data with caution.
5. Consider Rebuilding (Best Practice for Severe Infections)
If you're unsure whether the system is clean—especially if a rootkit was detected—the safest option is to:
A compromised system may have hidden backdoors that scanners miss.
Scanning and cleaning a Linux server takes care and verification. Use multiple tools, validate findings, and prioritize security hardening. When in doubt, rebuild.
以上是如何從Linux服務器掃描並刪除惡意軟件的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undress AI Tool
免費脫衣圖片

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

要讓PHP容器支持自動構建,核心在於配置持續集成(CI)流程。 1.使用Dockerfile定義PHP環境,包括基礎鏡像、擴展安裝、依賴管理和權限設置;2.配置GitLabCI等CI/CD工具,通過.gitlab-ci.yml文件定義build、test和deploy階段,實現自動構建、測試和部署;3.集成PHPUnit等測試框架,確保代碼變更後自動運行測試;4.使用Kubernetes等自動化部署策略,通過deployment.yaml文件定義部署配置;5.優化Dockerfile,採用多階段構

搭建獨立PHP任務容器環境可通過Docker實現,具體步驟如下:1.安裝Docker與DockerCompose作為基礎;2.創建獨立目錄存放Dockerfile、crontab文件;3.編寫Dockerfile定義PHPCLI環境並安裝cron及必要擴展;4.編寫crontab文件定義定時任務;5.編寫docker-compose.yml掛載腳本目錄並配置環境變量;6.啟動容器並驗證日誌。相比Web容器內執行定時任務,獨立容器具備資源隔離、環境純粹、穩定性強、便於擴展等優勢。為確保日誌與錯誤捕

確認目標硬盤設備名(如/dev/sda),避免誤刪系統盤;2.使用sudoddif=/dev/zeroof=/dev/sdXbs=1Mstatus=progress全盤覆寫零值,適用於大多數場景;3.敏感數據使用sudoshred-v-n3/dev/sdX進行三次隨機數據覆寫,確保無法恢復;4.可選執行sudobadblocks-wsv/dev/sdX做破壞性寫入測試;最後用sudohexdump-C/dev/sdX|head驗證是否全為零,完成安全擦除。

Windowsisbetterforbeginnersduetoeaseofuse,seamlesshardwarecompatibility,andsupportformainstreamsoftwarelikeMicrosoftOfficeandAdobeapps.2.LinuxoutperformsWindowsonolderorlow-resourcehardwarewithfasterboottimes,lowersystemrequirements,andlessbloat.3.Li

cronisusedforpreciseschedulingonalways-onsystems,whileanacronensuresperiodictasksrunonsystemsthataren'tcontinuouslypowered,suchaslaptops;1.Usecronforexacttiming(e.g.,3AMdaily)viacrontab-ewithsyntaxMINHOURDOMMONDOWCOMMAND;2.Useanacronfordaily,weekly,o

AfterinstallingLinux,thefirststepsincludeupdatingyoursystem,installingessentialsoftware,settingupbackupandsecuritymeasures,andcustomizingtheinterfacetosuityourpreferences.1)Updateyoursystemusingtheappropriatecommandforyourdistro(e.g.,sudoaptupdate&am

在Linux上安裝軟件主要有三種方法:1.使用包管理器,如apt、dnf或pacman,通過更新源後執行install命令安裝,例如sudoaptinstallcurl;2.對於.deb或.rpm文件,分別使用dpkg或rpm命令安裝,並在需要時修復依賴;3.使用snap或flatpak跨平台安裝應用,如sudosnapinstall軟件名,適用於追求版本更新的用戶,推薦優先使用系統自帶包管理器以獲得更好的兼容性和性能。

ChoosePop!_OS,Ubuntu,NobaraLinux,orArchLinuxforoptimalgamingperformancewithminimaloverhead.2.InstallofficialNVIDIAproprietarydriversforNVIDIAGPUs,ensureup-to-dateMesaandkernelversionsforAMDandIntelGPUs.3.EnabletheperformanceCPUgovernor,usealow-latenc
