Operations 9 min read

How to Auto-Start Applications on Embedded Linux: 3 Proven Methods

Embedded Linux systems often auto‑start applications after boot to save resources, and this guide explains three methods—using a /linuxrc script, adding scripts under /etc/init.d, and editing /etc/rc.d/rc.local—plus a detailed overview of Linux runlevels and the complete boot sequence.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Auto-Start Applications on Embedded Linux: 3 Proven Methods

Three Methods to Auto‑Start Applications

1.1 Start via kernel command line (init=)

During early boot the kernel initializes hardware drivers and then executes the init process. A bootloader can pass an argument such as init=/app_program on the kernel command line. The specified program becomes the first user‑space process, bypassing the traditional /etc/inittab lookup. This method is common in embedded systems where a single application replaces the full init system.

1.2 Add a script under /etc/init.d (or /etc/rc.d/init.d )

Most Linux distributions provide a directory of service scripts. To register a custom application:

Create an executable script in /etc/init.d that implements the standard start/stop interface (e.g., handling start, stop, status arguments).

Make the script executable: chmod +x /etc/init.d/myapp.

Link the script into the appropriate run‑level directories, e.g.:

ln -s /etc/init.d/myapp /etc/rc3.d/S99myapp   # start in runlevel 3
ln -s /etc/init.d/myapp /etc/rc3.d/K01myapp   # stop when leaving runlevel 3

Optionally use the distribution’s helper tools ( update-rc.d on Debian/Ubuntu or chkconfig on Red Hat) to create the links automatically.

Typical system services (cron, httpd, syslogd, sshd) are managed in the same way.

1.3 Add commands to /etc/rc.d/rc.local

The file /etc/rc.d/rc.local (or /etc/rc.local on some distributions) is executed after all run‑level scripts have finished. Any command placed in this file runs as root before a user logs in, making it a simple way to launch a custom binary:

# Example rc.local entry
/usr/local/bin/myapp &
exit 0

Ensure the file is executable ( chmod +x /etc/rc.d/rc.local).

Runlevels

Traditional SysV init defines seven runlevels (0‑6). Each runlevel corresponds to a directory /etc/rcN.d (or /etc/rc.d/rcN.d) containing symbolic links to the scripts in /etc/init.d. The naming convention is: Knnservice – stop the service when entering the runlevel. Snnservice – start the service when entering the runlevel.

Typical meanings:

0 – Halt (system shutdown).

1 – Single‑user mode (maintenance, root only).

2 – Multi‑user without network file system.

3 – Full multi‑user with networking, console login.

4 – Reserved for custom use.

5 – Multi‑user with graphical X11 login.

6 – Reboot.

Common commands: runlevel – display the current runlevel. init N – switch to runlevel N. init 0 – halt the system. init 6 – reboot the system.

Linux Boot Process

Power‑on self‑test (POST) and BIOS – BIOS performs hardware checks and selects the boot device.

Bootloader – The BIOS loads the Master Boot Record (MBR), which starts the bootloader (commonly GRUB). GRUB loads the kernel image and an initial RAM filesystem (initramfs).

Kernel start – The kernel mounts the root filesystem and starts the init process (PID 1).

Init reads /etc/inittab (or its systemd equivalent) to determine the default runlevel and then executes /etc/rc.d/rc.sysinit (or the systemd equivalent) to set hostname, time, mount filesystems, enable swap, etc.

Run‑level scripts – Scripts in /etc/rcN.d for the selected runlevel are processed in lexical order, starting or stopping services according to the S and K prefixes.

rc.local – After all run‑level scripts finish, the commands in /etc/rc.d/rc.local are executed.

Login prompt – Virtual terminals are started and the login prompt (or graphical display manager) appears.

Understanding these stages allows developers to choose the most appropriate method for automatically launching their embedded application, whether by passing init= on the kernel command line, installing a SysV init script, or adding a command to rc.local.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxBoot Processembedded systemsRunlevelAuto-start
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.