Bash find most recent LTS version

If I’ve understood this correctly then pacman -Q linux-lts gives me the version of the linux-lts kernel that I have installed locally on Manjaro? If it’s possible I would like a CLI or bash script command that would tell me if there was a newer suggested lts version of Manjaro/Linux Kernel available to install by using sudo pacman -S linux-lts

pacman -Q | grep linux[0-9][0*-9*][" "*] | awk ‘{print $1}’ gives me the list of any kernel versions currently installed but I’m trying to find a way of checking if there’s a new one available to be installed before needing to sign in with sudo:

$ sudo pacman -S linux-lts
[sudo] password for $USER:
warning: linux-lts-1:5.4-4 is up to date – reinstalling
resolving dependencies…
looking for conflicting packages…

Packages (1) linux-lts-1:5.4-4

:: Proceed with installation? [Y/n]

It seems a bit cumbersome to go through re-installing to check for an update. I’m assuming there is a better way of doing this somewhere but I’m not quite sure how to go about finding it.

Thanks very much

Not a Bash script, however Manjaro has the ability to do what you want out of the box with Manjaro Settings Manager Notifier. Open Manjaro Notifier Settings from the applications menu to customize what notifications you want to receive.

1 Like

Hi @P1000,

You can check perform kernel installation, checking and more with the mhwd-kernel command:

To list all installed kernels:

$ sudo mhwd-kernel -li

Currently running: 5.10.7-3-MANJARO (linux510)
The following kernels are installed in your system:
* linux510
* linux54

To list all available kernels

$ sudo mhwd-kernel -l

available kernels:
* linux414
* linux419
* linux44
* linux49
* linux510
* linux511
* linux54
* linux59
* linux54-rt
* linux59-rt

To install a kernel:

$ sudo mhwd-kernel -i <kernel_version>

For example:

$ sudo mhwd-kernel -i linux419
[sudo] password for mirdarthos: 

:: Synchronising package databases...
core                                                                                                      167.6 KiB   185 KiB/s 00:01 [----------------------------------------------------------------------------------] 100%
extra                                                                                                    1993.3 KiB  2.01 MiB/s 00:01 [----------------------------------------------------------------------------------] 100%
community                                                                                                   6.4 MiB  6.83 MiB/s 00:01 [----------------------------------------------------------------------------------] 100%
multilib                                                                                                  181.8 KiB  17.7 MiB/s 00:00 [----------------------------------------------------------------------------------] 100%
resolving dependencies...
looking for conflicting packages...

Packages (3) linux419-4.19.167-1  linux419-headers-4.19.167-1  linux419-nvidia-460.32.03-3

Total Download Size:   108.72 MiB
Total Installed Size:  190.69 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
linux419-4.19.167-1-x86_64                                                                                 74.7 MiB  10.0 MiB/s 00:07 [----------------------------------------------------------------------------------] 100%
linux419-headers-4.19.167-1-x86_64                                                                          8.8 MiB  13.3 MiB/s 00:01 [----------------------------------------------------------------------------------] 100%
linux419-nvidia-460.32.03-3-x86_64                                                                         25.2 MiB  12.7 MiB/s 00:02 [----------------------------------------------------------------------------------] 100%
(3/3) checking keys in keyring                                                                                                         [----------------------------------------------------------------------------------] 100%
(3/3) checking package integrity                                                                                                       [----------------------------------------------------------------------------------] 100%
(3/3) loading package files                                                                                                            [----------------------------------------------------------------------------------] 100%
(3/3) checking for file conflicts                                                                                                      [----------------------------------------------------------------------------------] 100%
(3/3) checking available disk space                                                                                                    [----------------------------------------------------------------------------------] 100%
:: Processing package changes...
(1/3) installing linux419                                                                                                              [----------------------------------------------------------------------------------] 100%
Optional dependencies for linux419
crda: to set the correct wireless channels of your country [installed]
(2/3) installing linux419-headers                                                                                                      [----------------------------------------------------------------------------------] 100%
(3/3) installing linux419-nvidia                                                                                                       [----------------------------------------------------------------------------------] 100%
In order to use nvidia module, reboot the system.
:: Running post-transaction hooks...
(1/5) Arming ConditionNeedsUpdate...
(2/5) Updating module dependencies...
(3/5) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux419.preset: 'default'
-> -k /boot/vmlinuz-4.19-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-4.19-x86_64.img
==> Starting build: 4.19.167-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-4.19-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux419.preset: 'fallback'
-> -k /boot/vmlinuz-4.19-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-4.19-x86_64-fallback.img -S autodetect
==> Starting build: 4.19.167-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-4.19-x86_64-fallback.img
==> Image generation successful
(4/5) Updating Kernel initcpios for Nvidia-DRM...
==> Building image from preset: /etc/mkinitcpio.d/linux419.preset: 'default'
-> -k /boot/vmlinuz-4.19-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-4.19-x86_64.img
==> Starting build: 4.19.167-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-4.19-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux419.preset: 'fallback'
-> -k /boot/vmlinuz-4.19-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-4.19-x86_64-fallback.img -S autodetect
==> Starting build: 4.19.167-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-4.19-x86_64-fallback.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux510.preset: 'default'
-> -k /boot/vmlinuz-5.10-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.10-x86_64.img
==> Starting build: 5.10.7-3-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.10-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux510.preset: 'fallback'
-> -k /boot/vmlinuz-5.10-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.10-x86_64-fallback.img -S autodetect
==> Starting build: 5.10.7-3-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.10-x86_64-fallback.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux54.preset: 'default'
-> -k /boot/vmlinuz-5.4-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.4-x86_64.img
==> Starting build: 5.4.89-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.4-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux54.preset: 'fallback'
-> -k /boot/vmlinuz-5.4-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.4-x86_64-fallback.img -S autodetect
==> Starting build: 5.4.89-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.4-x86_64-fallback.img
==> Image generation successful
(5/5) Updating Grub-Bootmenu
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/Stylish/theme.txt
Found linux image: /boot/vmlinuz-5.10-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.10-x86_64.img
Found initrd fallback image: /boot/initramfs-5.10-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.4-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.4-x86_64.img
Found initrd fallback image: /boot/initramfs-5.4-x86_64-fallback.img
Found linux image: /boot/vmlinuz-4.19-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-4.19-x86_64.img
Found initrd fallback image: /boot/initramfs-4.19-x86_64-fallback.img
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done

To remove a kernel:

$ sudo mhwd-kernel -r <kernel_version>

For example:

$ sudo mhwd-kernel -r linux419

checking dependencies...

Packages (3) linux419-4.19.167-1  linux419-headers-4.19.167-1  linux419-nvidia-460.32.03-3

Total Removed Size:  190.69 MiB

:: Do you want to remove these packages? [Y/n]
:: Running pre-transaction hooks...
(1/1) Removing linux initcpios...
:: Processing package changes...
(1/3) removing linux419-nvidia                                                                                                         [----------------------------------------------------------------------------------] 100%
(2/3) removing linux419-headers                                                                                                        [----------------------------------------------------------------------------------] 100%
(3/3) removing linux419                                                                                                                [----------------------------------------------------------------------------------] 100%
:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating module dependencies...
(3/3) Updating Grub-Bootmenu
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/Stylish/theme.txt
Found linux image: /boot/vmlinuz-5.10-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.10-x86_64.img
Found initrd fallback image: /boot/initramfs-5.10-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.4-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.4-x86_64.img
Found initrd fallback image: /boot/initramfs-5.4-x86_64-fallback.img
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done

For more info:

$ sudo mhwd-kernel -h

Usage: mhwd-kernel [option]
-h  --help              Show this help message
-i  --install           Install a new kernel        [kernel(s)] [optional: rmc = remove current kernel]
-l  --list              List all available kernels
-li --listinstalled     List installed kernels
-r  --remove            Remove a kernel             [kernel(s)]

Hope this helps!

3 Likes

The official longterm supported kernel is decided by the kernel developers at kernel.org.

Ubuntu has a fixed schedule where the fourth month of every even year designates an Ubuntu long term support release - but the kernel is not always the official LTS kernel.

Arch and Manjaro usually follows the definitions assigned by the upstream kernel developers.

The only reasonable method to locate the latest LTS would therefore be to parse their release feed found at

https://www.kernel.org/feeds/kdist.xml
2 Likes