How To Run A Command On StartUp in Linux (works on Centos & Ubuntu)



Free Linux Cheat Sheet: http://eepurl.com/dkRNM9

In this Linux tutorial I will show you how to run a command on startup on Linux. This tutorial uses Centos 7 but the commands will allow you to run a command on startup on Ubuntu and raspberry pi

This Linux tutorial first starts with showing you how to edit the rc.local file on Centos.

You then add content to this file.

You then give the rc.local the execute permission and then reboot the system.

By the end of this tutorial the viewer will be able to run a command on start up on Centos 7 Linux. The viewer will also be able to run a command on startup on Ubuntu and on other Linux systems including the raspberry pi

If you encounter any difficulty following this tutorial please comment below.

All the commands used can be found here:

How to run a command on Startup on Linux (works on CentOS & Ubuntu)

Read More

1 Comment

  1. That rc.local file is my go-to for this. It needs at least 700 permissions, and should be 0:0 ownership.

    I use it mainly to set one or two kernel parameters which refuse to stay set otherwise, and for downloading any new packages, for a quick update later.

    By the way, it's worth noting, if you didn't already mention it, that the commands in that file will be executed even before you've logged in; this way, I can sit at the login screen (greeter) with updates downloading. Probably obvious, but maybe some missed it.

    Last thing I can think of worth mentioning, is that some distributions have ditched rc.local in favor of another method (can't recall which) so you'll have to enable that yourself; see online guides for how to. IIRC, Arch is one of them.

Comments are closed.