deepin 开机自启动脚本之 rc.local
Tofloor
poster avatar
heisen
deepin
2019-12-05 01:37
Author
众所周知debian系发行版本中貌似没有/etc/rc.local
这给很多小伙伴带来了很多困扰,没有rc.local 开机怎么自动执行命令呢??
这个问题也困扰了我很久,但是已经被我解决了,现在贴出来分享给大家


打开终端执行下面命令,会在 /etc 下生成 rc.local 文件,每次开机系统会执行脚本内的命令
您只需要在/etc/rc.local 文件中 exit 0 字段前添加您的命令,在下次开机时便会自动执行

  1. ### debian系linux(debian、ubuntu、deepin),开机自启动脚本之 /etc/rc.local
  2. ### 全选复制粘贴到终端执行

  3. sudo touch /etc/init.d/rc.local
  4. sudo chmod 777 /etc/init.d/rc.local
  5. echo '''#!/bin/sh
  6. ### BEGIN INIT INFO
  7. # Provides:          skeleton
  8. # Required-Start:    $remote_fs $syslog
  9. # Required-Stop:     $remote_fs $syslog
  10. # Should-Start:      $portmap
  11. # Should-Stop:       $portmap
  12. # X-Start-Before:    nis
  13. # X-Stop-After:      nis
  14. # Default-Start:     2 3 4 5
  15. # Default-Stop:      0 1 6
  16. # X-Interactive:     true
  17. # Short-Description: Example initscript
  18. # Description:       This file should be used to construct scripts to be
  19. #                    placed in /etc/init.d.
  20. ### END INIT INFO

  21. ########### scripts velues ############
  22. #######################################


  23. exit 0 ''' >> /etc/init.d/rc.local

  24. sudo update-rc.d rc.local defaults
  25. sudo ln -s /etc/init.d/rc.local /etc/
  26. echo '已生成/etc/rc.local启动文件'
Copy the Code


注意:请勿删除#号开头注释内容,否则会遇到问题!!!
Reply Favorite View the author
All Replies
avatar
heisen
deepin
2019-12-05 01:40
#1
占楼备用!!!
Reply View the author
avatar
foxbcd
deepin
2019-12-05 02:10
#2
不都是用 systemd  的吗?
Reply View the author
avatar
RedPanda
deepin
2019-12-05 17:10
#3
systemd貌似是debian系的解决方案。而且我个人觉得systemd更方便一点....
Reply View the author