Rootkit Prevention and System Monitoring
The only surefire way to prevent a rootkit is to minimize the opportunities an attacker has to gain access to your system and install an exploit. In order to install a rootkit, malicious actors must gain administrative access to the system they are targeting in some way - whether it be by tricking a user into granting them root access or by compromising the system using a security vulnerability. For example, threat actors may compromise a web server, overwrite a system file with their own malicious file or use a system program in a way in which it wasn't intended to be used in order to gain administrative access to a system and install a rootkit.
As you now understand, system hardening is critical in preventing the installation of rootkits on your system. Users should always engage in good security behaviors including applying security patches, implementing the principle of least privilege, installing antivirus software like ClamAV, reducing the attack surface on their system and preferably using SELinux. Engaging in security best practices that are effective in defending against all types of malware such as checking permissions, enabling firewalls, ensuring that remote access portals are properly secured, monitoring network activity, enabling multi-factor authentication (MFA), reviewing system logs regularly and implementing a reputable cloud email security solution will also help protect against rootkits.
Finally, you can monitor your system using a technique called file integrity to detect rootkits quickly by scanning the system for changes. The idea is to make a fingerprint of the machine right after a fresh install and after each newly installed program. A fingerprint is a cryptographic hash function which makes a hash that is dependent upon each bit of data in a file. After this hash is made, by calculating and comparing the stored hash value with the current hash value, changes in data can be detected.