ubuntu设置GUI程序开机启动

来源:互联网 发布:经传软件三板斧不准 编辑:程序博客网 时间:2024/06/14 03:09

ubuntu 开机启动 自己的GUI程序

我的是ubuntu 16.04 LTS

1 、在 /etc/rc.local中替换成如下代码

#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.echo "++++++++start /etc/rc.local++++++"echo "this run  GUI application need x-server and        kill x-client( /etc/init.d/lightdm )      use your GUI application instead lightdm service"echo "system start order :1    init 2    login3    bash 4    startx5    xinit6    x-server7    x-client"echo "x-client is your GUI application"echo "+++++ WangMingXing note this ++++++++++++++++++++++++++++"echo "+++++service --status-all |grep lightdm+++++"service --status-all |grep lightdmecho "+++++ stop service  lightdm+++++"/etc/init.d/lightdm stopecho "+++++service --status-all |grep lightdm+++++"service --status-all |grep lightdmecho "+++++ start my  x-client+++++"startx /myWorkSpace/app/myGUIApp --usr/bin/Xorg:0exit 0

修改成自己的GUI程序,只需要替换 倒数第二行
startx /myWorkSpace/app/myGUIApp --usr/bin/Xorg:0
/myWorkSpace/app/myGUIApp 替换成自己的GUI程序的绝对路径

2、赋予执行权限

chmod 777 /etc/rc.local

然后重启就可以看到自己的GUI程序了

注意事项:

1 可以先在ubuntu机器上安装telnet服务

安装openbsd-inetdsudo apt-get install openbsd-inetd安装telnetdsudo apt-get install telnetd重启openbsd-inetdsudo /etc/init.d/openbsd-inetd restart查看telnet运行状态sudo netstat -a | grep telnet登录telnet IP address

然后可以使用 MobaXterm 建立telnet链接 ubuntu主机,查看或控制
MobaXterm 百度网盘 链接: https://pan.baidu.com/s/1pLJZooj 密码: bkj5

2 可以注释掉 rc.local 中 /etc/init.d/lightdm stop 这样就是这启动x-server iPublicManager 作为x-client,并且启动x-server lightdm 作为x-client样
linux 使用 Ctrl + Alt + (F1 ~ F7) ,风别切换 tty1 - tty7,
其中 tty1 启动iPublicManager,tty7是默认ubuntu界面
3 系统故障无法启动修复:
1 使用启动U盘系统挂在原系统硬盘,访问并修复原系统
2 在原系统安装远程登录服务,作为虚拟终端访问
4 脚本无法启动修复:
1 赋予执行权限 sudo chmod 777 /etc/rc.local
2 若1步骤后仍然未能执行,是bash 与 sh 命令的区别,
修改脚本头 把 #!/bin/sh -e 改为 #!/bin/bash