Linux is often described as more secure than other mainstream operating systems, but that claim seems complicated. Linux has malware, botnets, exposed services, and plenty of opportunities for dangerous misconfiguration. In some situations, it may even be easier to accidentally expose a service to the internet.
On the other hand, Windows is targeted more heavily because it has a much larger desktop user base, and Linux commonly separates normal user privileges from administrative access. Linux software is also often installed through distribution repositories, and many systems use additional protections such as sandboxing or mandatory access control.
What actually prevents a malicious script or dropper from running on a Linux desktop? If an attacker compromises a normal user account, is privilege escalation generally easier on Linux than on Windows, or does Linux provide meaningful security advantages when it is configured and used normally?
3 Answers
Linux is not automatically secure, and any internet-connected system can be compromised. Its advantages come from the defaults and ecosystem: normal users generally do not have administrative rights, sensitive changes usually require entering a password, and software can often be installed from trusted distribution repositories. Many desktop distributions also use sandboxing or mandatory access controls. Those protections make common attacks harder, but they do not eliminate vulnerabilities or protect someone who knowingly runs untrusted code with elevated privileges.
The amount of malware is not a simple measure of how secure an operating system is. Desktop Windows has historically been a more profitable target because there are many users who install software from random websites and can be tricked into approving prompts. Linux is also widely used in servers, phones, and embedded systems, so it absolutely has malware and botnets; those systems are just often managed differently and attacked through exposed services or known vulnerabilities rather than through a deceptive desktop installer.
A malicious program can run as a regular Linux user if the user downloads and executes it. It can read that user's files, access available credentials, and abuse applications running under that account. What it normally cannot do without an exploit or administrator authorization is modify protected system files, install system-wide services, or take over the entire machine. Linux does not prevent the initial execution; it limits what the process can do afterward. File permissions, separate accounts, package management, timely updates, firewall rules, and tools such as SELinux or AppArmor all contribute to reducing the damage.

That is also why a Linux server can be very secure or disastrously exposed. Leaving an unnecessary service reachable from the internet, using weak credentials, or failing to patch it can defeat the operating system's built-in protections.