1. 创建需要开机执行的脚本

sudo vim /etc/AutoExec.sh

随便写点东西以供测试,如

touch ~/auto.test

加上执行权限

chmod +x /etc/AutoExec.sh

2. 新增autostart桌面启动项

这一项开机后会随桌面启动

vim ~/.config/autostart

# 编辑内容如下:
[Desktop Entry]
Type=Application
Exec="/etc/AutoExec.sh"
Terminal=yes
Name=AutoExec
X-GNOME-Autostart-enabled=true

/etc/AutoExec.sh为需要开机启动的脚本,其他项保持默认即可

3. 测试是否生效

重启查看~/auto.test是否生成,生成则代表开机自启生效,将AutoExec.sh中的内容改为实际需要的脚本即可。

4. 本文引用

封面图片:https://pixabay.com/vectors/laptop-workspace-flat-design-3214756/
教程参考:https://www.cnblogs.com/bugxch/p/13833552.html