您的位置:首页 > 产品设计 > UI/UE

ubuntu设置GUI程序开机启动

2017-12-01 12:09 549 查看

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    login
3    bash
4    startx
5    xinit
6    x-server
7    x-client"
echo "x-client is your GUI application"
echo "+++++ WangMingXing note this ++++++++++++++++++++++++++++"

echo "+++++service --status-all |grep lightdm+++++"
service --status-all |grep lightdm

echo "+++++ stop service  lightdm+++++"
/etc/init.d/lightdm stop

echo "+++++service --status-all |grep lightdm+++++"
service --status-all |grep lightdm

echo "+++++ start my  x-client+++++"
startx /myWorkSpace/app/myGUIApp --usr/bin/Xorg:0

exit 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-inetd
sudo apt-get install openbsd-inetd

安装telnetd
sudo apt-get install telnetd

重启openbsd-inetd
sudo /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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: