sudo touch /etc/rc.d/rc.local
sudo vim /etc/rc.d/rc.local

在/etc/rc.d/rc.local文件中写入, 然后使用:wq命令 保存并退出.

#!/bin/bash

# 在这个文件中写入开机启动需要执行的命令

赋予可执行权限:

sudo chmod+x /etc/rc.d/rc.local

设置开机启动:

sudo systemctl enable rc-local.service

如果出现以下错误提示:

[root@dev-zhanghua ~]# systemctl enable rc-local.service
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
sudo vim /usr/lib/systemd/system/rc-local.service

在rc-local.service文件末尾加入:

[Install]
WantedBy=multi-user.target

并重新设置开机启动:

sudo systemctl enable rc-local.service

查看状态, 如果出现以下提示, 设置成功!

[zhanghua@dev-zhanghua ~]$ systemctl status rc-local.service
● rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled)
Active: active (running) since Wed -- :: CST; 1h 44min ago

Fedora 21 设置开机启动脚本的更多相关文章

  1. ubuntu-18.04 设置开机启动脚本-亲测有效

    ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.local重新发挥作用. 2.将下列内容复制进rc-local.servi ...

  2. ubuntu-18.04 设置开机启动脚本

    ubuntu-18.04 设置开机启动脚本 参阅下列链接 https://askubuntu.com/questions/886620/how-can-i-execute-command-on-sta ...

  3. Ubuntu 18.04 设置开机启动脚本 rc.local systemd

    ubuntu18.04不再使用initd管理系统,改用systemd. ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.l ...

  4. ubuntu高版本如何设置开机启动脚本

    ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本 可以通过下列简单设置后,可以使rc.local重新发挥作用. 1.建立rc-local.service文件 ...

  5. Ubuntu 16.04设置开机启动脚本的方法

    需求:公司卡片机容量太小,只有100G,由于使用的人比较的多,开机使用后有时候就会出现磁盘空间占满数据写不进去的情况,影响工作进度,而且每次使用完都得关掉卡片机,所以就有必要写个清理磁盘的脚本,当卡片 ...

  6. Ubuntu 14.04设置开机启动脚本的方法

    rc.local脚本 rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/etc/路径下,需要root权限才能修改. 该脚本具体格式如下: #! ...

  7. ubuntu设置开机启动脚本

    rc.local脚本 rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/etc/路径下,需要root权限才能修改. 该脚本具体格式如下: #! ...

  8. Ubuntu-18.04设置开机启动脚本

    参考:https://www.cnblogs.com/defifind/p/9285456.html    http://www.cnblogs.com/airdot/p/9688530.html s ...

  9. Ubuntu14.04设置开机启动脚本(转)

    原文:https://www.magentonotes.com/ubuntu-config-autostart-shell-script.html 方法一:将脚本添加到文件/etc/rc.local ...

随机推荐

  1. ubuntu adb devices 找不到任何东西,安装驱动

    在Android平台下做开发,adb总是需要使用到的,同时,因为linux没有windows这样操作傻瓜化,有些东西还是需要自行设置的,否则将会连接不上. 关于这些内容,google也有一定的描述,可 ...

  2. Implement the hash table using array / binary search tree

    今天在复习Arrays and String 时看到一个很有趣的问题.希望跟大家分享一下. Implement the hash table using array / binary search t ...

  3. hdoj 2036 改革春风吹满地

    改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  4. IOS开发之内存管理--dealloc该写些什么

    在非ARC开发环境中,dealloc是类释放前,清理内存的最后机会.到底那些变量和属性该释放呢,一些特殊的类(nstimer,observer)该怎么释放.需要注意的是不释放会引起内存泄露,过度释放也 ...

  5. modelsim使用命令

    1. 常用仿真命令 vlib work    // 建立work仿真库 vmap work wrok   // 映射库 vlog   -cover  bcest  *.v    // 加覆盖率分析的编 ...

  6. 第一次JAVA基础考试后的反思

    今天进行了第一次JAVA基础考试,考查了课本上前面三章和方法的知识,基本没有涉及到数组.通过这次的考试,暴露了自己在学习中的很多问题. 机试题是编写一个学员状态转换器,主要运用的是选择语句和方法,而没 ...

  7. (转)关闭WordPress自动加载的Open Sans字体,总是连接googleapi.com,导致打开wordpress很慢

    转自http://www.xuanfengge.com/turn-off-automatic-loading-wordpress-open-sans-fonts.html 一.'在网上搜了一番,有四种 ...

  8. [置顶] Linux下的截图小工具

    Linux下的截图工具scrot 基于命令行 先下载:scrot apt-get install scrot 对该工具的操作: 分为以下几个部分 1.抓取整个桌面 scrot pic.jpg 2.抓取 ...

  9. delegate和event

    经过查阅资料和自己的理解整理出来的,欢迎大家指教. delegate和event 何时使用: 异步的时候,比如加载完成通知. 需要回调的时候,比如按钮点击.动画播放结束等. 发送事件通知的时候. 比如 ...

  10. sort()排序 collections.sort();

    1.main方法: public class Test { public static void main(String[] args) { /** * * sort()方法详解 * 1.Collec ...