Welcome to our brand-new tutorial series on Linux security hardening. In this tutorial series, we will cover security and hardening techniques that apply to any Linux based server or workstation. By following this guide, you can make sure that no attacker can compromise your Linux system. This guide will contain a total of 7 sections as shown below.

  1. Disabling root access and setting up sudo privileges for full administrative users
  2. Securing your server with a firewall
  3. Encrypting and SSH hardening
  4. Mastering discretionary access control
  5. Access control lists and shared directory management
  6. Implementing mandatory access control with SELinux and app armour
  7. Scanning, auditing and hardening

This tutorial series will be a basic-to-advanced level guide filled with real-world examples that will help you secure your Linux system. by the end of this series, you will be equipped with many tools at your disposal which will help you to fully protect your system.

So, Let’s start.

Section 1: Disabling root account and setting up sudo privileges for full administrative users

The user “root” is the default administration account on Linux and other Unix operating systems. Since this account has superuser access with permissions to read, write and execute all files and commands, it is necessary to disable this user and setup superuser privileges to another admin user.

  1. Make sure to create an administrative account before disabling root. We will create a user called “AdminUser” for this.

# useradd -m -c “AdminUser” admin

# passwd admin

  1. Add the user “AdminUser” to sudo group

# usermod -aG sudo admin

Now, the user “AdminUser” can be used for administrative tasks instead of using “root”.

  1. Switch to the “AdminUser”

# su admin

  1. Now disable root user shell so that he cannot login. To do that, edit /etc/passwd file as shown below

# vim /etc/passwd

  1. Change the root user shell from /bin/bash to /sbin/nologin


  1. Save this file and close it
  2. To Disable root login via SSH, go to /etc/ssh/sshd_config file

# sudo vim /etc/ssh/sshd_config

  1. set the PermitRootLogin value to no

  1. Save and exit

From now on, root account cannot be used to login to this Linux machine with administrative privileges. In our next tutorial, we will see how to Secure your Linux machine with a firewall.

Stay tuned…

The following two tabs change content below.
Ruwantha Nissanka is a Professional Cyber Security Engineer from Sri lanka with having a demonstrated history of providing cyber security services for multiple organizations in Sri Lanka. He is a positive person who wants to believe the best in others and he likes to help, encourage people and make them feel good.