FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Executing certain command as root after every login





leontius
In ubuntu, I need to execute certain command as root after every login (ie. after X starts). How do I do that?

I tried chmod 4755 /path/to/script and then put it on Startup applications, but it doesn't seem to work (it is not executed as root)...
sheedatali
I think you need to put it under Administration->Sessions to make it work. To run it as root, just use sudo. If still does not work then try to log the output to a file i-e 2>&1 to see what exactly is happening and why is it not running. May be then you will be able to figure out what is causing the application to not run.
the zephyrus
Someone posted an answer on the Ubuntu forums to a similar thing.
http://ubuntuforums.org/showthread.php?t=415888
leontius
Thanks the zephyrus! Now I know about /etc/rc.local Smile

The sudo solution is not optimal because I will need to enter my password again after login for the sudo (which would be annoying).
Agent ME
What are you trying to do? Do you exactly want it to run when the system is started up, when a network becomes connected, or at certain timeframes during the day?

For when the system starts up, look at /etc/rc.local as you pointed out.
For when a network becomes connected, look at /etc/network/if-up.d
For running at certain times periodically, look up crontab.
ikavec
leontius wrote:
The sudo solution is not optimal because I will need to enter my password again after login for the sudo (which would be annoying).


i think you can use /etc/sudoers for allowing specific users to launch specific commands using sudo without asking for password
blueray
Did you chown your script files ?
Fire Boar
blueray wrote:
Did you chown your script files ?


Unnecessary - root can do everything. In any case, I'm a bit confused about why this is still being discussed. /etc/rc.local is the solution, and it has already been presented. [/thread]
blueray
That because I assumed that he do not wish to change overall system settings and the script will only executed when he logged in to the system but not any other users.

It will require that the owner of the files be root in order for the bit id to take effect.
Related topics
Windows Vista Official Thread
Xbox Softmod Tutorial
an annoying problem - PLEASE help
Commando Sondre's services!
Is there a life after death?
[PHP] Faking Shell Access Through PHP
Internet Explorer 7 (beta 2 preview)
Major Startup problem!!!
FriHost PHP Parser doesn´t work?
Dog Training
10 things you should know about every Linux installation
The Middle East Conflict
Raising a puppy
National Institute for Civil Discourse - what ever for?
Reply to topic    Frihost Forum Index -> Computers -> Operating Systems

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.