Skip to main content

Command Palette

Search for a command to run...

Reboot Reminder In Arch Linux

Updated
1 min read
Reboot Reminder In Arch Linux
H

I am a developer from Malaysia. I work with PHP most of the time, recently I fell in love with Go. When I am not working, I will be ballroom dancing :-)

Reboot is required when Linux kernel is updated. Ubuntu has a nice MOTD that reminds user to reboot the machine. There is a simple implementation for Arch Linux.

Append the following to end of ~/.bashrc:

versionUpdated=$(vercmp $(pacman -Q linux | cut -d " " -f 2) $(uname -r))
if [ $versionUpdated -ne 0 ]; then
    HIGHLIGHT='\033[1;33m'
    NC='\033[0m' # No Color
    echo -e "${HIGHLIGHT}Linux version changed, reboot needed.${NC}"
fi

I am using pacman -Q linux | cut -d " " -f 2 to extract installed kernel version. If you are using other distro, you will need to modify this part. vercmp is also Arch-specific command.

I am using non-zero (-ne) comparison, so it will display reminder message whenever there is changes in kernel version (both upgrade and downgrade). Font color is yellow, you can change it to a different color.

Reference: https://bbs.archlinux.org/viewtopic.php?id=173508

More from this blog

Hong's Tech Blog

110 posts

The blog is older than you know. I prefer counting from the emergence of one integral anomaly to the emergence of the next, in which case this is the forth version.