Ubuntu – Startup Auto-Execution Bash Script

bashscriptsstartup

First post here. Please be gentle

There's a way to execute a bash command during the startup of Linux operating system?
I could always put the script in /usr/local/bin open the terminal and recall it, but is a little bit annoying.

EDIT1 as suggested by steeldriver: The script has to enter in a root folder and change 2 values of charge thresold contained in a text file. For each start-up I'd like to be sure that the battery level wouldn't go over the 80%.

So in order to do that the script would execute a:

  • cd command
  • sed -i 's/0 100/0 80/g'

all of this, I think, has to be in sudo mode

EDIT2: as asked by K7AAY user:

Ubuntu Desktop 18.04 LTS version, I'm not using any virtualization.


Thanks for the answers

Best Answer

  • You could use crontab -e

    @reboot /usr/local/bin/yourscript
    

    You could also copy your *.desktop applications into ~/.config/autostart/ or scripts into ~/.config/autostart-scripts/ directory. But, instead of copying, use ln -s pathtoscript ~/.config/autostart-scripts/

    You could also use the next GUI for it if you use KDE Plasma:

    enter image description here

    Or, for Unity:

    enter image description here

  • Related Question