Looking to start a script in Ubuntu everytime a user logs in

Derrick Irwin

New Member
Jul 23, 2018
Reaction score

I've tried searching for this issue, but I cannot seem to get it right. I am using Ubuntu 14.04 right now, I wrote a script to restart a program/process. It's a .sh script. I was wondering if it was possible to get it to run automatically when a user logs into the system. I've tried to copy it into the /etc/init.d folder using sudo, but it still doesn't seem to run at start up. Also, FYI, when I double click on it and run it as an executable it runs with no problem.

These are the commands I'm trying, but I'm not sure if this is the "old" way of getting a script to run at login:

make your script executable

copy your script to the /etc/init.d/ folder with

sudo cp /path_to_script/script.sh /etc/init.d/

invoke update-rc.d with

sudo update-rc.d script.sh defaults

If anyone has any ideas I would greatly appreciate it.

Thank you!

Hi @Derrick Irwin and welcome to linux.org :)

I am very rusty at scripting but hoping to shake that off soon (well, sometime this millennium... I am a wizard)

In your 'Trusty Tahr' you may have a file /etc/rc.local, do you have that?, or if not, you can create one.

As I understand it, scripts in rc.local only kick in normally when the X server starts, which is at or following login, but it can be run from startup, and that would serve?

There is an article here


which makes for interesting reading, and the part I refer to has 46 votes and has 9 steps.

If that is not satisfactory, then our resident scripting guru @JasKinasis may have better ideas, he is from Britain so allow for timezones. I am from Australia.

Good luck

Chris Turner
try this:

$nano ~/.bash_profile

add the script: sh /path-to-your-script/script.sh

close the editor and run this command:
$source ~/.bash_profile

if you dont have .bash_profile, search the .bashrc

Latest posts