Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Secure an Ubuntu Server – What are the best practices?

by | Mar 5, 2021

Wondering how to secure an Ubuntu Server? We can help you.

Not to mention, security is paramount to a business, a few security implementations can go a long way.

As part of our Server Management Services, we assist our customers with several Ubuntu queries.

Today, let us discuss few best practices our Support Techs suggest to secure an Ubuntu Server.


Best practices to Secure an Ubuntu Server

Moving ahead, we will discuss User Management, Console Security, Firewall, AppArmor, Certificates, eCryptfs, Encrypted LVM.


  • Balance the access rights of users

While users have the tools to get a job done, we also need to protect other users’ privacy and confidentiality.

Ubuntu has three types or levels of user access:

a) Root

The main administrator of the server, the root account has full access to everything on the server. The root user can lock down or, limit folder access, install and remove services or applications, repartition drives, etc. and essentially modify any area of the server’s infrastructure.

b) A sudoer (user)

This user has sudo access. The “sudoer” user has advanced rights to run a function or program as another user. The rules this user has access to are defined within the “visudo” file.

c) A user

This is a regular user, set up using the adduser command, given access to and, who owns the files and folders within the user /home/user/ directory as defined by the basic settings in the /etc/skel/.profile file.


  • Enforce Strong Passwords

All of us can agree on the importance of passwords. Hence, enforcing a strong password is a must. In order to do this, we can modify the file responsible for this setting using the ‘change’ command:

$ chage -m 90 username

This command states that the user must change the password every 90 days.

/lib/security/$ISA/ retry=3 minlen=8 lcredit=-1 ucredit=-2 dcredit=-2 ocredit=-1


  • Restrict the use of old passwords

Another important step is to restrict the use of old passwords. For this, open ‘/etc/pam.d/common-password‘ file under Ubuntu/Debian/Linux Mint.

$ vi /etc/pam.d/common-password

Then add the following line to the ‘auth‘ section.

auth sufficient likeauth nullok

In addition, add the following line to the ‘password‘ section to disallow a user from re-using the last five of his or her passwords.

sufficient nullok use_authtok md5 shadow remember=5


  • Checking Accounts for Empty Passwords

Accounts with an empty password mean it is open for unauthorized access to anyone on the web.

Thus it is important that we make sure all accounts have strong passwords.

To check for accounts with an empty password, run:

$ cat /etc/shadow | awk -F: '($2==""){print $1}'


  • Install a firewall

Ubuntu provides a default firewall frontend, UFW (Uncomplicated firewall). This is another line of defense to keep unwanted or malicious traffic from actually breaching the internal processes of the server.

The firewall log creates and stores information about attempts and other connections to the server. Monitoring these logs for unusual activities will aid in securing the server.

When using UFW, we can enable logging by running the following command:

$ ufw logging on

To disable logging, we simply run the following command:

$ ufw logging off

[Need help with securing your server? Contact us now]



In short, we covered the importance of passwords, user roles, console security, and firewalls all of which are imperative to protecting Linux servers. We saw how our Support Techs perform the same.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.