Operating System - Linux
1830226 Members
1546 Online
109999 Solutions
New Discussion

Re: how to Adding scripts in startup

 
ramadashsuresh
Frequent Advisor

how to Adding scripts in startup

Hai

i want to know the method of adding a script to startup and it will run itself only when i login as a root

8 REPLIES 8
Vitaly Karasik_1
Honored Contributor

Re: how to Adding scripts in startup

Add your script into root's .bash_profile.
Alexander Chuzhoy
Honored Contributor

Re: how to Adding scripts in startup

Yep,the file is /root/.bash_profile or /root/.bashrc (if /root/.bash_profile
executes .bashrc)
Patrick Terlisten
Honored Contributor

Re: how to Adding scripts in startup

Hello,

watch out: ~/.bash_profile and ~/.bashrc will be used in different ways. The ~/.bash_profile will be read by a login shell, the ~/.bashrc only by an interactive shell. When you login, the ~/.bash_profile will be read. When you start a new shell with "sh" oder "bash", the ~/.bashrc will be read. Some distributions read both files in any way (openSUSE for example).

Regards,
Patrick
Best regards,
Patrick
ramadashsuresh
Frequent Advisor

Re: how to Adding scripts in startup

Actualy my script is based on GUI mode it will run only a GUI it couldn't run in tty

when i adding script to .bash_profile file it will reflect only a tty terminal. i want to run the script GUI mode when i log in as root
Patrick Terlisten
Honored Contributor

Re: how to Adding scripts in startup

Hello,

you mean a login over xdm or kdm? If you're running KDE, you can try to put you script in ~/.kde/Autostart.

Regards,
Patrick
Best regards,
Patrick
ramadashsuresh
Frequent Advisor

Re: how to Adding scripts in startup

I am login over gnome
Mike Stroyan
Honored Contributor

Re: how to Adding scripts in startup

You can run gnome-session-properties and add your script to the list under the "Startup Programs" tab. Use the complete path to it. It will be run each time that user logs in. You should "chmod +x" your
script and make it start with a "#!/bin/bash" line so that it can be run like an executable.
ramadashsuresh
Frequent Advisor

Re: how to Adding scripts in startup

Thank u guys

Now my script working in startup perfectly