How to switch CLI boot and GUI boot on Ubuntu 24.04

Find the current boot mode (CLI or GUI)

test@ubuntu:~$ systemctl get-default
multi-user.target

multi-user.target is CLI boot
graphical.target is GUI boot

To change CLI boot

sudo systemctl set-default multi-user.target

To change GUI boot

sudo systemctl set-default graphical.target

Reboot

Reboot your Ubuntu to apply changes

sudo reboot