Results 1 to 5 of 5

Thread: Running script as root at startup Ubuntu 19.04

  1. #1
    Join Date
    Dec 2007
    Location
    almost Southern OR
    Beans
    7
    Distro
    Ubuntu 9.10 Karmic Koala

    Running script as root at startup Ubuntu 19.04

    I needed to run

    Code:
    modprobe -r lp
    at startup so Virtualbox could grab the parallel port. I made a script "unload lp.sh" with the above code, ran chmod u+x on it to make it executable, put it into startup applications and restarted, no joy. After some searching I tried adding

    Code:
    #!/bin/bash
    to the beginning of the script, also no joy, but if I ran the script from terminal it worked as expected. I fixed my issue by creating /etc/rc.local and putting the modprobe in there, but I'm curious why it didn't work through startup applications. This is purely for my edification, I like knowing how and why stuff does (or doesn't) work.



    Thanks!

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Running script as root at startup Ubuntu 19.04

    Add `lp' to the /etc/modules file.
    https://help.ubuntu.com/community/Loadable_Modules

    EDIT: Oh, you have to remove the module. You can blacklist it in /etc/modprobe.d/blacklist:
    Code:
    blacklist lp
    Last edited by sisco311; June 25th, 2019 at 09:56 PM.

  3. #3
    Join Date
    Dec 2007
    Location
    almost Southern OR
    Beans
    7
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Running script as root at startup Ubuntu 19.04

    That info was what I was looking for before I started making the script, thanks! I am however still curious why my method didn't work, more for future reference than anything else.

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Running script as root at startup Ubuntu 19.04

    "startup applications" are automatically launched during startup of the user's desktop environment after the user has logged in, but modprobe must be run as root.
    See: https://specifications.freedesktop.o...ec-latest.html

    Putting the command in /etc/rc.local should be avoided. The file is executed by systemd for backward compatibility with sysvinit but you can't predict at which point of the booting process is executed.

  5. #5
    Join Date
    Dec 2007
    Location
    almost Southern OR
    Beans
    7
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Running script as root at startup Ubuntu 19.04

    Gotcha, I was under the assumption startup applications were run as root. I'll do the blacklist like you mentioned, thanks for all the help and information!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •