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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I've got a script I'd like to run as root when I log in. What's the best way to achieve what I'd like?
Should I have A or B.
A) Within 'Startup applications' have the machine run 'sudo ./myscript'. If so, will the machine grant it root rights to the startup applications list to run said script?
B) Within 'Startup applications' have the machine run './myscript'. Within myscript have each of the commands prefixed by 'sudo'? Again, will my machine allow the script to execute the commands as root even though I've not typed in my password?
Do you really mean 'when I login', or do you actually mean at boot time? If the former, you can add almost anything to your shell login script, probably $HOME/.bashrc. If it needs root privileges, you can either use sudo, or su. If you mean at boot time, then you can add code to /etc/rc.local, which always runs as root.
I added the commands from my script into /etc/rc.local, as it seemed the most appropriate, however it doesn't work. I then changed rc.local so that it executes the script by having the line: sh /path/to/my/script.sh. No joy
I know the script itself works, I just need it to be executed at start up or boot.
I hope I don't seem petulant, I certainly don't mean to come across this way, but from my understanding, it does. I switch the computer on and without striking a single key or clicking a button it arrives at the Desktop ready to use. Do we have two different understanding of what's taking place?
Originally Posted by NevemTeve
Try to debug:
exec >/tmp/debug.log 2>&1
sh -x /path/to/my/script.sh
I copied and pasted this into a command line and it appeared to freeze the screen? In a new terminal I executed the script:
$sh -x /path/to/my/script.sh
+ xset s off
+ xset -dpms
Is that what you're expecting to see?
Last edited by NotAComputerGuy; 01-01-2013 at 03:16 AM.
I have no idea what much of that means. I've removed it from rc.local and added it (sudo sh /path/to/my/script.sh) to the list of startup applications within the environment itself. I'm using MATE, I think that was your question...
Unfortunately, despite the script in the list of things to be run at startup, it appears for whatever reason, it doesn't work. This is really frustrating. If I SSH into the computer and type 'sudo sh /path/to/my/script.sh' it works, but why can my computer not do that automatically for me?
Last edited by NotAComputerGuy; 01-01-2013 at 08:12 AM.