I started learning and investing time in Linux because I liked the idea that it isn't as prone to viruses, hackers etc. Or at least that's what I read somewhere.

In my testing I found myself frequently looking for answers to certain situations via Google. Some of which may have been in this exchange, others on just stack overflow. So I try suggestions and it occured to me this can be dangerous. Blindly installing a package with apt or yum, downloading a rpm or dpkg file and inatalling it just seems too risky. On thing I like about Windows is I have Mcafee to secure my web browing & scan files I download.

How can I get protection from hackers & viruses in the Linux world?

  • Would you be able to make your question a bit narrower by posing an explicit issue that you have. "Making my system safe" is too broad as answering it would have to include a full tutorial on a number of components of a standard Linux system, including configuring a firewall, common sense use of file permissions, how to safely deal with 3rd party software, possible attack surfaces and scenarios, and how to keep your system up to date with the latest security patches (etc. etc.) – Kusalananda Aug 27 '19 at 21:18

Blindly doing anything is risky. However, as long as you are installing software from your distribution's repositories (which is what you do when using apt or yum), then you're as safe as you can be and certainly safer than installing any random exe and trusting your antivirus software on a Windows machine. Anything in the repositories has already been tested and you can trust it as much as you can trust anything.

Viruses are not really an issue on Linux systems. Some do exist, but they are few and far between and not that dangerous in the first place. This is both because the Linux and Unix world is inherently more secure1 because they were written as multi-user systems from the ground up so the normal user doesn't have access to the files you'd need to screw with in order to cause real damage, but also because Linux is still not so popular, so it just isn't worth the effort to write viruses for it.

However, viruses are a very specific threat and not the one you should worry about when installing external software. I can easily write a script that won't be detected as a virus by anything and yet will delete all of your files if you run it. So yeah, blindly installing stuff is never a good idea and never secure. Not on Windows, not on Linux and not on any other operating system.

So, just stick to the software available through apt or yum or whatever tool your distribution uses for package management. As soon as you step out of that protected world, you're on your own. Which is not to say that you will have problems, only that you should be careful.

All that said, if you want to just use your machine with as little worry as possible, then Linux (or any other *nix) is the way to go.

1I'm sure that an experienced sysadmin can harden a Windows system and make it just as secure. I'm only discussing what you get with an average Linux distribution versus an average personal Windows computer.


The distribution developers are doing most of the work for you. Unless you're using third-party repositories, everything you can install through your distribution's normal package management software has been vetted by dozens of people before you could even get to the point of installing it. On top of that, the default settings are generally reasonably secure to begin with, and it's often pretty easy to secure things further by yourself.

Beyond that, it's just about the same good security practices that you should have no matter what OS you'r using. Don't install untrusted software, don't follow random links, don't browse sketchy sites on the web, etc.

If you're really paranoid about malware, you may want to look into ClamAV, the only major non-commercial AV software for Linux. It's usually not worth bothering with though unless you're doing things that are particularly risky in the first place (IOW, if you never got anything but false positives from your AV software on Windows, you almost certainly don't need to waste system resources on AV software on Linux).

Also, it's worth pointing out that Linux is not inherently more secure than Windows, at least for smart users. It's a bit easier to secure properly, but that doesn't make it inherently more secure. The reason it's touted as having so few viruses is because desktop Linux users aren't attractive targets for hackers. This is, incidentally, the same reason that macOS has so few known viruses. Put simply, Linux users tend to be smarter on average than Windows users, or at least less lazy, and thus tend not to be fooled by malware as readily. That, combined with significantly lower usage on the desktop means that it's just not worth the time to attack desktop Linux systems.

This doesn't mean that people don't attack Linux systems though, such attacks just tend to ignore desktop Linux systems because they're usually not attractive targets. Most of the malware focuses on tight-embedded systems (like Android) or servers, because Linux easily outnumbers Windows by multiple orders of magnitude in both areas. It's not unusual for Linux server systems to see hundreds of break in attempts a day (put in perspective, the company I work for is tiny, extremely niche, and in general bot really a big target, and we still see over a dozen failed attacks an hour (almost 300 a day) against our servers).

  • I'm not convinced by the argument of obscurity / niche anymore. Maybe 10-15 years ago. Mobile devices, tablets, Mac books, IOT devices put windows machines to shame in terms of usage. Sure IOT is an issue but not usually caused by the OS. It seems like windows is less secure these days because users are still encouraged to do more risky things. Like download an exe from a website you've never heard of instead of checking the app store. As discussed apt is generally safe from reputable repositories. – Philip Couling Aug 28 '19 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.