Securing Ubuntu: Best Practices for Keeping Your System Safe

So, you’re using Ubuntu – that’s a solid choice! But, to really keep your system and data safe and sound, there are a few extra steps you can take. This tutorial’s gonna walk you through all the tricks and tips to make your Ubuntu secure as Fort Knox. We’ll cover everything from keeping your software up to date and patched up, to creating strong passwords, firewalls, anti-virus software, and more. Check out these tips to give your Ubuntu security a boost.

1 – Enable the firewall

Turn on your firewall protection with just a few clicks! Fire up a terminal and type in the ufw command. This handy tool lets you control all incoming and outgoing traffic like a boss.

sudo ufw enable

By enabling the firewall with just one command, you’re blocking all incoming traffic automatically. But don’t worry, you can still let the good stuff through by using the “ufw allow” command. For instance, if you need to allow incoming SSH connections, just type in this simple command and you’re good to go.

sudo ufw allow ssh

Read: How to set up a firewall on Ubuntu 18.04

2 – Create strong passwords

Protect yourself from password cracking and other nasty attacks by using strong, one-of-a-kind passwords for all your accounts. Mix it up with a combination of uppercase and lowercase letters, numbers, and special characters. Don’t make it easy for hackers by using words from the dictionary or personal info like your name or bday.

Need some inspiration? Check out this example of a solid password: “P@55w0rd123!”

Read: Linux password generator

3 – Keep your system up to date

Stay on top of security by keeping your system and apps up-to-date. You’ll get all the latest security patches and fancy features. To do this, fire up the Software Updater app or simply run this command in your terminal:

sudo apt update && sudo apt upgrade

Keep your system current by regularly running two simple commands: “apt update” and “apt upgrade.” The first one fetches the latest package lists from the repositories and the second one installs the updates. Do this often to stay on top of things.

Read: How to fix Ubuntu update errors

4 – Enable automatic security updates

You would like to keep your system secure and on point? Turn on automatic security updates. Here’s how: open the Software & Updates app and head over to the Updates tab. Under the “Automatic Updates” section, choose “Important security updates”. This’ll make sure you get the latest and greatest security patches without lifting a finger. And if you want to be in the loop, you can even get notifications when updates are ready to install.

5 – Use a secure connection

When hooking up to a network, it’s crucial to stay safe and keep your data under wraps. To do this, look for a network with “WPA2” or “WPA3” security protocol. These encryption standards are the real deal when it comes to wireless security. So, make sure the security protocol is set to WPA2 or WPA3 before connecting for a secure connection that’ll keep your info out of harm’s way.

Read: How to fix WiFi not working on Ubuntu

6 – Proceed with caution when installing new software

Only go for software from sources you can trust, like the official Ubuntu repo or top-notch websites. Steer clear of downloading software from shady sites, cuz it might have malware or other security weaknesses lurking in it.

To install software from the official Ubuntu repo, just use the apt command in the terminal. Say you would like add the VLC media player, the following command’ll do the trick:

sudo apt install vlc

7 – Use antivirus software

Linux systems may be more secure than other operating systems, but it doesn’t hurt to have an antivirus on board just in case. There are a bunch of antivirus options for Ubuntu, like ClamAV and Sophos.

To get ClamAV up and running, use the following command in the terminal:

sudo apt install clamav

Once you’ve got it installed, use the clamscan command to run a malware check on your system. To scan your home directory, for instance, use the following command:

clamscan /home

8 – Enable full disk encryption

Full disk encryption keeps your data safe if your device ever goes missing or gets swiped. To turn on full disk encryption on Ubuntu, you gotta use the “LUKS” (Linux Unified Key Setup) encryption system.

Read: How to make Raspberry Pi safer

To set up LUKS encryption, fire up the terminal and use the cryptsetup command. First, create a partition for your encrypted data. If you wanna use all the space on the second disk, for example, the following command’ll do the trick:

sudo cryptsetup luksFormat /dev/sdb

Next, open the encrypted partition using the following command:

sudo cryptsetup luksOpen /dev/sdb encrypted

This’ll whip up a new device named “encrypted” in the /dev/mapper folder. Once you’ve done that, you can create a filesystem on the encrypted partition using the mkfs command. To make an ext4 filesystem, for instance, use the following command:

sudo mkfs.ext4 /dev/mapper/encrypted

And finally, you can mount the encrypted partition by using the mount command. If you want to mount the partition to the /mnt directory, for example, just use the following command:

sudo mount /dev/mapper/encrypted /mnt

Read: Moving the Home folder to another partition in Ubuntu

9 – Use a screen lock

Protecting your device from unauthorized access is key, so don’t forget to lock your screen. Go to Settings > Privacy > Screen Lock and set a password or PIN.

10 – Use 2-factor authentication

Adding 2-factor authentication adds an extra layer of security to your accounts. It requires a second form of authentication, like a security token, one-time code sent to your phone, or biometrics like a fingerprint or facial recognition. To enable 2-factor on Ubuntu, you’ll need to use a tool like Google Authenticator, Authy or oathtool. These handy tools generate one-time codes for you to log into your accounts. Just install them from the official Ubuntu repo and set them up for each account you want to protect.

11 – Limit access to your system

If you share your device with others, it’s a good idea to set up separate accounts. This keeps track of who’s accessing your system and what they’re up to. Set up separate accounts by going to Settings > Users.

12 – Enable AppArmor

To lock down your device, you gotta turn to AppArmor. It’s like a security guard for your system, making sure only the right programs get access to what they need. To get started, you gotta install the apparmor-utils package, then turn on the AppArmor service using systemctl command. If you need to turn it off later, just hit up the Disable AppArmor page.

Read: 4 Ways to Find Large Files on Linux and Free Up Disk Space

13 – Use a VPN

Protect your online activities by using a VPN, which encrypts your internet connection and hides your IP. This is a good idea if you’re using public WiFi or don’t want your data to fall into the wrong hands. To get a VPN on Ubuntu, you’ll need to install a client, like OpenVPN or WireGuard.

14 – Use  HTTPS 

Keep your data secure while browsing by using HTTPS, a secure version of HTTP for transferring data between a web server and client. Use a browser that supports HTTPS and aim to always use HTTPS when you can. Check if a website is HTTPS by looking for a padlock in the address bar.

Read: HTTP or HTTPS: What’s the Difference and Which One is Better to Use

15 – Lock it up with key-based authentication

If you’re tired of relying on passwords alone, try key-based authentication. It’s a safer way to log into your system. You’ll use a private key stored on your device and a public key on the server. To get started, use ssh-keygen to generate a key pair, then copy the public key to the server.

16 – Keep an eye on things with auditing

Auditing is when you track and record what’s happening on your system. It’s like a digital logbook that keeps track of logins, file access, and other changes. To start auditing on Ubuntu, install the auditd package and set it up with the auditd service.

17 – Use SELinux

SELinux (Security-Enhanced Linux) is a way to control which programs can access specific parts of your system. To use it on Ubuntu, install the selinux-basics package and configure the SELinux policy. If you need to turn SELinux off, check out the following site.

Read: How to Configure Network Settings in Ubuntu 22.04

18 – Browse safely with a security-focused browser

Not all browsers are created equal. Take the Tor Browser, for example. It’s made specifically to protect your privacy and anonymity online. To use it on Ubuntu, grab the torbrowser-launcher package from the official Ubuntu repositories.

19 – Keep your conversations secret with encryption

Keep your data private by encrypting your communications. On Ubuntu, use gnupg for email encryption and openssl for general encryption to protect your messages from prying eyes.

Read: How to encrypt a USB stick on Ubuntu

20 – Keep your passwords secure with a password manager

Ain’t it a hassle trying to remember all your passwords for every online account? That’s where a password manager comes in handy. It helps you generate and store strong, unique passwords for all your accounts. On Ubuntu, you can install tools like pass or lastpass-cli to use as a password manager.

21 – Keep your email secure with a security-focused mail client

Worried about the security of your email? No need to fret, use a security-focused mail client like Thunderbird or Enigmail. These clients have added features such as encryption and digital signing to keep your email communication secure.

22 – Get a secure file manager

A file manager is your go-to for organizing and managing your files on your system. Some file managers even have added security features like encryption and password protection. Check out Gnome Encfs Manager and Cryptomator if you’re looking for a security-focused file manager on Ubuntu.

23 – Stay safe while searching with a secure search engine

A search engine is your ticket to finding information on the internet, but some prioritize privacy more than others. Look into privacy-focused search engines like DuckDuckGo and StartPage if you’re using Ubuntu and want to keep your search history private.

Read: How to Google search from Linux terminal – Build your own search engine

24 – Get a safe messaging app

A messaging app is a way to chat with others online. Some apps focus on privacy, with features like encryption and messages that disappear. Check out privacy-focused options like Signal and Wire for Ubuntu.

25 – Go for a private cloud storage

A cloud storage service lets you store and access your files online. Some services prioritize privacy, with features like encryption and two-step verification. Take a look at privacy-first options like Nextcloud and Tresorit for Ubuntu.

Conclusion

Securing your Ubuntu system is crucial to protect your sensitive information and personal data. By following the best practices discussed in this article, such as using key-based authentication, enabling auditing, using a security-focused browser and encrypted communication, using a password manager, a secure file manager, and a secure cloud storage service, you can significantly increase the ubuntu security of your system. Remember, taking the time to properly secure your Ubuntu system is worth it to ensure that your information stays safe and secure.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

Nikolaus Oosterhof

Nikolaus holds a degree in software development and has a strong passion for all things tech-related, especially gadgets with screens. Though he is nostalgic for older phone models, he's a retired gamer and continues to enjoy programming in open-source environments. Additionally, Nikolaus enjoys writing about Linux, macOS and Windows and has experience designing web pages.

Leave a Reply