Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a program I have made, and I would like it to run as soon as the system is finished booting. I am using Ubuntu Mini Remix to recreate a LiveCD/USB stick. After booting, it drops me to a command line where I can enter "sudo qct" and it will run my program (which is called qct, and it has to be run as root).
I want this to be automated. Instead of going to a command line, I want it to run the program itself at that point. How would I go about doing this? I have read many tutorials about scripting but I cannot seem to get it to work.
Does your distro contain the /etc/rc.d/init.d/ directory? It should, but I have never used your distro.... You could always move your script into that directory, then create links to your runlevel directories, such as /etc/rc.d/rc5.d/ and so forth. Or you could just move the script to /etc/rc.d/rc.local.
Well in order to run it as root, you will have to manually enter your root password. Since you said your distro is command line only, you could place your script name within rc.local and go from there.
Just put /path/to/qct into /etc/rc.local before the final line exit 0 and it will be run as root after everything else has booted up. You'll have to adjust the path to your command, don't take "/path/to/" literally. Example:
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/rawful/qct
exit 0
Just put /path/to/qct into /etc/rc.local before the final line exit 0 and it will be run as root after everything else has booted up. You'll have to adjust the path to your command, don't take "/path/to/" literally. Example:
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/rawful/qct
exit 0
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.