Skip to content

Linux Autostart

Legend

  • Scope: Who it affects.
  • Trigger: When it starts.
  • Use: When this method is a good fit.

GUI applications

PurposeScopeTriggerLocation / MethodNotes / Examples
Standard GUI appSingle userGraphical login~/.config/autostart/*.desktopDiscord, Steam, Nextcloud tray, GUIs
Standard GUI appAll usersGraphical login/etc/xdg/autostart/*.desktopUpdate notifiers, corp chat clients
GUI app in terminalSingle/AllGraphical login.desktop in autostart dirs + Terminal=truePops up terminal running htop, custom TUI

Hints

  • Use OnlyShowIn= / NotShowIn= in the .desktop file if you need per‑DE behavior.
  • These only run when a desktop session is started, not on bare TTY boot.

Background services / daemons

PurposeScopeTriggerLocation / MethodNotes / Examples
User background daemonSingle userUser login / linger~/.config/systemd/user/ + systemctl --user enableSyncthing (user), personal fetchers, watchers
User daemon available to allAll users (opt‑in)User login / lingerUnit in /etc/systemd/user/ (or /usr/lib/systemd/user/), each user runs systemctl --user enableShared templates users can enable
User daemon forced for allAll usersUser login / lingerUnit in /etc/systemd/user/ + sudo systemctl --global enable foo.serviceCompany‑wide background sync
System daemon (root)System‑wideSystem boot/etc/systemd/system/ + sudo systemctl enableDocker, VPN, OpenSnitch daemon, servers

Hints

  • Use user services where possible instead of root for security.
  • For headless systems that still need user services at boot, enable lingering: loginctl enable-linger USER.

Window‑manager / desktop tools

PurposeScopeTriggerLocation / MethodNotes / Examples
WM‑tied visual toolsSingle userWM startsWM config, e.g. ~/.config/i3/configfeh wallpaper, picom, polybar
WM‑tied visual toolsAll usersWM startsGlobal WM drop‑ins, e.g. /etc/sway/config.d/Default bar, swayidle lockscreen

Hints

  • Use this when the tool is tightly coupled to that WM and should start after the WM itself, not just after “any GUI login.”

Shell / terminal startup

PurposeScopeTriggerLocation / MethodNotes / Examples
Per‑user interactive shellSingle userInteractive shell open~/.bashrc, ~/.zshrcAliases, prompts, neofetch, small helpers
Per‑user login shellSingle userLogin (TTY, first graphical shell)~/.profile, ~/.bash_profile (bash)PATH tweaks, env vars, one‑shot login setup
All users login shellAll usersLogin shell/etc/profile, /etc/profile.d/*.shGlobal env vars, system message/greeting

Hints

  • Avoid long‑running daemons or noisy commands here; they will run every time a shell starts.
  • For persistent background jobs, prefer user/system services instead of starting them from shell config.

A few extra patterns

  • One‑shot at boot (root): systemd service with Type=oneshot in /etc/systemd/system/ and WantedBy=multi-user.target for tasks that just need to run once and exit (e.g., a fixup script).
  • Cron @reboot: still possible but generally superseded by systemd; use only if you are already heavily invested in cron and don’t want to write units.
  • Headless foreground app on TTY: use a systemd service bound to a getty@ttyX.service or a Type=simple service that runs your program directly instead of a login shell.