登录和 root 登录后立即运行 .sh 文件

登录和 root 登录后立即运行 .sh 文件

如何在使用常规凭据和 root 密码登录后立即自动运行 .sh 文件。谢谢

答案1

您可以使用.desktop中的文件执行此操作~/.config/autostart。要创建这样的文件,只需执行以下操作:

cat > ~/.config/autostart/myscript.desktop << "EOF"
[Desktop Entry]
Name=myscript.sh
GenericName=my script for foo-fu
Comment=does bar the foo or fu foos the bar
Exec=sh ~/scripts/myscript.sh
Terminal=true
Type=Script
Icon= 
Categories=Tools;
StartupNotify=true
EOF

在此之前请确保您已经chmod 755通过以下方式对该脚本进行了操作:

chmod 755 myscript.sh

并将其设置为在 nautilus 中执行,如下面的示例图所示:

在此处输入图片描述

相关内容