Wifi dongle driver problem linked to kernel errors?

Hello,
I'm trying to install a new driver for a new wifi dongle - the old one is just about hanging on but I need to get a new one up and running asap.
I have the driver on a cd but I cannot find a way to install it. Can someone give me instructions please?

I have tried various "fixes" but end up with:

sub-process/usr/bin/dpkg returned an error code(1)

or

Errors were encountered while processing
rtl8822bu-dkms
rtl8821cu-dkms

and

Bad return status for module build on kernel: 6.8.06.5-generic (x86-64)

I don't understand the messages or how to correct any of the errors.

Can someone help please?

Many thanks

Please disable secure boot in your BIOS.

You can add this ppa for rtl8822bu:

sudo add-apt-repository ppa:kelebek333/kablosuz
sudo apt update
sudo apt install r8822bu-dkms

(I'm not sure if the name of the package is rtl8822bu-dkms or r8822bu-dkms)

Thanks for your answer.
This is what I get:

david@david-DH61CR:~$ sudo add-apt-repository ppa:kelebek333/kablosuz
[sudo] password for david:
Repository: 'deb Index of /kelebek333/kablosuz/ubuntu jammy main'
Description:
PPA for Realtek wifi drivers

If you installed your system in UEFI mode, you must disable secureboot for modules installed by dkms after installation.

You can check installation mode with following command.

[ -d /sys/firmware/efi ] && echo "EFI" || echo "BIOS"

You can check status of secureboot with following command.

mokutil --sb-state
More info: https://launchpad.net/~kelebek333/+archive/ubuntu/kablosuz
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Found existing deb entry in /etc/apt/sources.list.d/kelebek333-ubuntu-kablosuz-jammy.list
Adding deb entry to /etc/apt/sources.list.d/kelebek333-ubuntu-kablosuz-jammy.list
Found existing deb-src entry in /etc/apt/sources.list.d/kelebek333-ubuntu-kablosuz-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/kelebek333-ubuntu-kablosuz-jammy.list
Adding key to /etc/apt/trusted.gpg.d/kelebek333-ubuntu-kablosuz.gpg with fingerprint F30D3DBFB7534F670B44C71923E50C670722A6D9
Hit:1 fr.archive.ubuntu.com / ubuntu.lafibre.info jammy InRelease
Hit:2 Index of /ubuntu jammy InRelease
Hit:3 fr.archive.ubuntu.com / ubuntu.lafibre.info jammy-updates InRelease
Hit:4 Index of /ubuntu jammy-security InRelease
Hit:5 fr.archive.ubuntu.com / ubuntu.lafibre.info jammy-backports InRelease
Hit:6 Index of /cappelikan/ppa/ubuntu jammy InRelease
Hit:7 Index of /kelebek333/kablosuz/ubuntu jammy InRelease
Hit:8 Index of /tuxinvader/jammy-mainline/ubuntu jammy InRelease
Ign:9 Index of /tuxinvader/lts-mainline/ubuntu jammy InRelease
Hit:10 Index of /zorinos/apps/ubuntu jammy InRelease
Hit:11 Index of /zorinos/drivers/ubuntu jammy InRelease
Hit:12 Index of /zorinos/patches/ubuntu jammy InRelease
Hit:13 Index of /zorinos/stable/ubuntu jammy InRelease
Err:14 Index of /tuxinvader/lts-mainline/ubuntu jammy Release
404 Not Found [IP: 185.125.190.80 443]
Hit:15 Index of /stable/ jammy InRelease
Hit:16 Index of /patches/ jammy InRelease
Hit:17 Index of /apps/ jammy InRelease
Hit:18 Index of /drivers/ jammy InRelease
Reading package lists... Done
E: The repository 'Index of /tuxinvader/lts-mainline/ubuntu jammy Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
david@david-DH61CR:~$ apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
david@david-DH61CR:~$ apt install r8822bu-dkms
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

This means you have the software center open or the updater is running. Please close any of them.

You sources look as you have tried to install a newer kernel. This would also be an option to install kernel 6.14, then the drivers should be contained in the kernel.

Sorry! I closed it and tried again. This is what I got this time.

sudo apt install r8822bu-dkms
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED
rtl8822bu-dkms
The following NEW packages will be installed
r8822bu-dkms
0 to upgrade, 1 to newly install, 1 to remove and 10 not to upgrade.
2 not fully installed or removed.
Need to get 1,575 kB of archives.
After this operation, 15.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 Index of /kelebek333/kablosuz/ubuntu jammy/main amd64 r8822bu-dkms all 5.2.4~jammy5 [1,575 kB]
Fetched 1,575 kB in 2s (671 kB/s)
(Reading database ... 302843 files and directories currently
installed.)
Removing rtl8822bu-dkms (5.8.7.1~jammy3) ...
Deleting module rtl8822bu-5.8.7.1~ppa completely from the DK
MS tree.
update-initramfs: deferring update (trigger activated)
Selecting previously unselected package r8822bu-dkms.
(Reading database ... 302161 files and directories currently
installed.)
Preparing to unpack .../r8822bu-dkms_5.2.4~jammy5_all.deb ..
.
Unpacking r8822bu-dkms (5.2.4~jammy5) ...
Setting up rtl8821cu-dkms (5.4.1~jammy9) ...
Removing old rtl8821cu-5.4.1~ppa DKMS files...
Deleting module rtl8821cu-5.4.1~ppa completely from the DKMS
tree.
Loading new rtl8821cu-5.4.1~ppa DKMS files...
Building for 6.8.0-65-generic
Building initial module for 6.8.0-65-generic
Error! Bad return status for module build on kernel: 6.8.0-6
5-generic (x86_64)
Consult /var/lib/dkms/rtl8821cu/5.4.1~ppa/build/make.log for
more information.
dpkg: error processing package rtl8821cu-dkms (--configure):
installed rtl8821cu-dkms package post-installation script s
ubprocess returned error exit status 10
Setting up r8822bu-dkms (5.2.4~jammy5) ...
Loading new r8822bu-5.2.4~ppa DKMS files...
Building for 6.8.0-65-generic
Building initial module for 6.8.0-65-generic
Error! Bad return status for module build on kernel: 6.8.0-6
5-generic (x86_64)
Consult /var/lib/dkms/r8822bu/5.2.4~ppa/build/make.log for m
ore information.
dpkg: error processing package r8822bu-dkms (--configure):
installed r8822bu-dkms package post-installation script sub
process returned error exit status 10
Processing triggers for initramfs-tools (0.140ubuntu13.5) ..
.
update-initramfs: Generating /boot/initrd.img-6.8.0-65-gener
ic
Errors were encountered while processing:
rtl8821cu-dkms
r8822bu-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

How do I install a new kernel?

Thank you.

Welcome to the Forum!

Could You plug in the Dongle and type in the Terminal sudo lshw -C network please? This will show a List with Details about Your Network Devices. Post the Output here.