How can I run a command at boot?

Schlachter picture Schlachter · May 29, 2013 · Viewed 19.6k times · Source

I'm trying to figure out how to run a command at boot, like I would type it into the console. I'm using Rasbian with my Raspberry Pi, but I think this question is the same for Debian in general. The command I'm trying to run is:

sudo screen mono server.exe

I tried the following solution, but since I just started with Linux, I'm not sure if this is correct.

 #! /bin/sh
# /etc/init.d/server

### BEGIN INIT INFO
# Provides:          server
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       ..
### END INIT INFO

# If you want a command to always run, put it here
sudo screen mono server.exe    

exit 0

Answer

Oliver-H-Miller picture Oliver-H-Miller · Jul 23, 2014

Simple
Run cd ~
Then edit .profile
At the bottom, put whatever you would like.