Create an auto.desktop startup configuration file on the desktop (or other directories)
sudo gedit auto.desktop
Below is the text content
[Desktop Entry]
Version=1.0
Name=auto.desktop
Exec=/home/li/test/build-HelloWorld-Desktop_Qt_6_5_0_GCC_64bit-Release/HelloWorld
Icon=/home/li/Desktop/auto.png
StartupNotify=false
NoDisplay=true
Type=Application
Categories=System;Utility;Archiving;
Name[zh_CN]=auto.desktop
Give permission to the file
sudo chmod 777 auto.desktop
Copy to the /etc/xdg/autostart directory
sudo cp auto.desktop /etc/xdg/autostart
restart the system
sudo reboot
To cancel autostart, remove the corresponding files in the /etc/xdg/autostart/ directory
sudo rm -rf auto.desktop
Note: If you are not running a QT graphical interface but a terminal service, you need to use the gnome-terminal command