Home Debian How to check for updates at login on Debian

How to check for updates at login on Debian

by Karen
check for updates at login on debian

Due to increased security risks and ensuring you are running the latest software packages, you might want your system to always check for updates and upgrades on login. This post will guide you on configuring your Debian system to automatically check for updates at login.

What’s an update?

An update can be defined as any modification to existing data by adding or removing specified data from existing data. An update is simply a modification of existing software or hardware in the IT world. When an existing software has been updated, we say the software version has been upgraded.

Hence software and hardware have versions to differentiate the most recent version from a previously existing version. So, a version is just a revision of previously existing software or rather a revised edition of existing software. Updates are performed on software, firmware, operating system, hardware, etc.

Why do we need to perform updates?

Let’s list some of the importance of updates;

  • Adding new and improved features in software.
  • Removing outdated or unwanted features from software or hardware.
  • Fixing bugs increases computer security.
  • Increase or decrease compatibility with different devices.

Though alerts to updating software or systems are becoming more automatic, there’s still a need to perform manual checks periodically. Let’s look at how to check for updates on Debian OS manually. We’ll use the terminal to check for software updates.

Before we dive into checking and updating, make sure you have the following:

  • Your device has internet connectivity since updates need to be downloaded from repositories(these are locations for storage of software packages).
  • Ensure your device is plugged into a power supply to prevent your device from going off before completing updates.

How to check for updates at login on Debian

We will use simple logic to carry out this project. We will write a script that gets executed in a terminal emulator whenever a user logins to the system. Unfortunately, since the --command parameter is now deprecated in the Gnome-Terminal for most recent distributions, we need to use another Terminal emulator. For this post, we will Xterm. Follow the steps below.

Step 1. Install Xterm

Xterm is the standard Terminal emulator for the X windowing system and can smoothly run on Debian. I love this emulator because you can run several instances simultaneously within the same window. If you tried that on Gnome, you would get a screaming error – “there was an error creating a child process for this Terminal.”

Execute the command below to install Xterm on Debian.

sudo apt update
sudo apt install xterm

Step 2. Write the script

You have two options to ensure that our script is executed on system login. One, append the script at the end of the .profile file in your home directory or create a script file inside the /etc/profile.d directory.

We will write our script in a file and save it in the /etc/profile.d directory to keep things neat and orderly. Use the command to create the file using the nano editor.

sudo nano update-script.sh

Paste the script below.

if ! command -v xterm &>/dev/null
sudo apt install -y xterm
(xterm -e sudo apt update 2>/dev/null)||(sudo apt install update)
update script

Update script

When done, save the script using the keyboard combination (Ctrl + S) and exit (Ctrl + X).

Understanding the script

Let’s look at the first part of the code above.

if ! command -v xterm &>/dev/null
sudo apt install -y xterm

Here, we first check whether Xterm is installed on the system. If it’s not installed, the script will install the utility.

The last line is the most important part of the script.

(xterm -e sudo apt update 2>/dev/null)||(sudo apt install update)

If you look closely, there are two commands in this one line separated by the pipe (||) character. The first part xterm -e sudo apt update 2>/dev/nullis used to manage the Graphical login. If you are using a Graphical Desktop, Xterm will launch and execute the update command when you log in.

The next part is used to update the system if you log in via console. For example, if you access the system via SSH, you will see a prompt to enter your Password to update the system.

enter password to update system

Enter a password to update the system

Checking for updates manually

As a Linux user, you should be conversant in updating software on the terminal. On your Debian system. Launch the Terminal from the applications menu and execute the command below.

sudo apt update

Since the update command can modify existing software, any update or upgrade on the terminal should be run as the root user. Thus, we wouldn’t want that kind of privilege/power to be at the hands of an average user. As with any great power comes with great responsibility, which should be assigned to a root user.

update system

Update system

We need to upgrade to the latest updates found after running the update command. So run the following command as shown in the image below:

sudo apt upgrade

An upgrade tells the system that it needs to revise the existing software with the newly found updates. Recall that an update does not only mean the addition of a new feature but also the removal of any outdated current feature.


That’s it. You have learned the importance of performing update checks and how you can comfortably check for updates on the terminal. Before I check out, it’s good practice that updates should be done pronto, but always be wary with the updater’s source, as threat actors might poison some packages to gain access to your device. So, always remember that an update a day keeps the bugs away.

You may also like

Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.