The course is part of these learning paths
In this section of the course, you'll learn why Linux is considered to be a relatively secure operating system. You'll learn the fundamentals of Linux security and how to keep your systems safe.
- Understand what superusers are in Linux
- Learn why Linux systems are often avoided by attackers
- Understand the security implications for open-source software such as Linux
- Learn how various Linux components contribute to security including roles, network services, encryption, accounts, and multifactor authentication
- Look at security principles that you can apply to your Linux systems
This course is intended for anyone who wants an introduction to how to secure their Linux systems.
To get the most out of this course, you should already have a good working knowledge of Linux. If you want to brush up on your Linux skills, consider taking our Learn Linux in 5 Days learning path first.
So why is Linux secure? What makes it secure, and what are some of the security features of Linux? First off, Linux is a multiuser system, meaning that many users and accounts can use the system at once. Having multiple accounts allows for separation of roles and permissions. On Linux systems the administrator of the system is called the superuser. Specifically the account named root is the superuser of a Linux system. Root the superuser can do anything. It's the all powerful account on a Linux system.
For example, normal users can't hide things from the root account. Even if they create files that should only be accessed by them, root can still access those files. This is a very important concept. If someone has a root access, they own the entire system. Also, root privileges are required to do things like install system-wide software, configure network devices, and create or disable other accounts. This is why it's extremely important to keep this account secure. Don't give access to the root account to someone unless it's absolutely necessary. We'll be talking about secure ways to do that in another section of this course. All other accounts on a system besides the root account are normal accounts. These accounts can be used by people. For example, when I log into a system I might use the login name of Jason. Each user on a system should be given their own account. And we'll talk about why this is important in just a minute.
You can also have accounts that are used to run services or applications on a system. For example, you could create an account to use for the web server on a Linux system. Having separate accounts for users and applications has some advantages. The first advantage is being able to use file permissions. The ability to view a file, edit it, or even execute it as a program is controlled by file permissions. Each file on a Linux system has an owner. The root user owns the files associated with the operating system. Each individual user owns the files that they create. Typically those files live in their individual home directories. If we're using accounts for services or applications the files associated with those services or applications will be owned by that application user. If we are using a dedicated user for our web server then that user will own the files that are used by the web server to serve up web pages. Files owned by one user cannot be modified by another user unless the other user is given explicit access to that file. You can even use file permission so that other users can't even see the contents of a file or even see the file name itself.
So if someone were to break into my Jason account they wouldn't have access to the files owned by the web server account, for example. This is just one thing that provides a layer of security to Linux. The next advantage to using separate accounts is that each process is run by an account. By default each account can only start processes as themselves. Likewise, each account can only stop or kill their own processes. The exception to the rule is with the root account. The root user can stop any process on a system no matter what account owns the process. Again, the superuser is all powerful. In the case of our web server example the web server process can only be stopped by the web server user or root. If someone were to gain access to my Jason account they couldn't stop the web server process. Also if the web server process was exploited, then the attacker would only have the web server user privileges since that process is running as the web server user. This adds another layer of security to the Linux system. This is one reason why you don't want to run applications as the root user. Many times attackers are lazy. They want big and easy wins. For many attackers Linux is simply a poor target. For one thing, there are simply more Windows-based computers than there are Linux computers. Right off the bat, Linux is a smaller attack surface. Also Linux is typically used by computer professionals or computer enthusiasts. These people aren't your average computer user. They typically have more knowledge about how computers work and about computer security. These types of people pay more attention to security than your average casual user of Windows, for example.
Since there aren't as many Linux targets and the targets that exist are harder to break into, many times Linux is left alone by attackers and virus writers. It doesn't mean that this doesn't happen but currently Windows is a much easier target. Linux is open source, meaning that anyone can see the source code. By using Linux you don't have to trust just one person or one company. It would be practically impossible for someone to sneak some malicious code into the Linux kernel without thousands and thousands of developers noticing it. Also using open source software greatly increases the odds of security holes and bugs being found and fixed. Once a bug or hole is found, it can be quickly fixed. There is no corporate bureaucracy and secrecy surrounding Linux. Windows, on the other hand, is a black box. It can be doing anything under the hood and you would probably never know. Only Microsoft can release security patches to their OS and holes can go unpatched for years at a time. Yet another thing that enhances the security of Linux is that the OS software is centralized through the use of packages and package managers.
A package is a collection of files that make up an application. A package manager is used to install, upgrade, and remove packages. Linux distributions provide repositories of packages which allow you to download and install software from a single cryptographically trusted provider. When you install a package on Linux the package manager downloads that package from the repository. Packages in the repository are signed using a public key to prove that the package that was published by the repository has not changed since the signature was applied. This provides some protection against installing software that may have been maliciously altered after the package was created but before you downloaded it. If you are using packages from a well-known Linux distribution you can feel fairly confident that those packages are free from viruses, free from malware, and that they are what they say they are. Each program available in the official repository is thoroughly tested. Not only is the Linux kernel open source the operating system tools are open source as well. Also the overwhelming majority of software applications that run on Linux are open source. Again, this means that anyone can readily view the source code for those Linux programs and security flaws can be spotted and fixed. As security issues are addressed packages in the repository are updated. This way you can easily keep your system up to date by installing the latest versions of the packages available.
Another advantage of using software provided by a distribution is that when you perform updates and patches, you not only get bug fixes and security updates for the Linux kernel, you also get updates for all the other software being used on the system. This includes network services, like web servers or database servers, and user space software, like web browsers, for example. On a Linux system, if you want to install software, you search the repository using the package manager and install it. Contrast this to other operating systems like Windows. If you want to install a piece of software you search for it on the internet and download it off some website. That software has not been reviewed by Microsoft or tested by them. Also, it's probably not open source software so you really have no idea what it does. The best you can do is hope that it will do what it says it does and no more. Unfortunately, it's a common practice to include, bundle, or slip in some additional software. You may only want to install that one piece of software and you might not realize that it also installs additional software. In the worst case scenarios this additional software is malicious. These problems arise because the software is coming from a third-party source, a source outside of the operating system ecosystem. I use Windows as an example but if you don't use packages from your distribution, then you're open to all the same issues on Linux as well.
Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.