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.
putting the script in /usr/local/bin just means you can type the name without having to type the full path
if you now out the command you use to exicute the script in your
~/.bashrc it will runn whenever you log in (if you log in graphically it may not run untill you open a terminal)
If you're using KDE you can place it in ~/.kde/Autostart and it will run whenever you start your kde session. I know gnome has a similar folder somewhere as well.
I don't think placing it in ~/.bashrc is a good idea, because then it will run every time you open a new bash shell, not just on startup. Unless you want that behavior, of course.
Oh, and placing the script in /usr/local/bin will only allow you to run it by name only if that directory is set in your PATH variable. Most distros add this by default, but it's not guaranteed. /usr/local/bin is one of the recommended traditional locations in which to keep personal scripts and programs, however.
Last edited by David the H.; 10-08-2008 at 09:23 AM.
I wrote my first useful shell script! now I would like to make it run as soon as I log in. where should I put the shell scrip to auto run?
From the man page for bash:
Code:
When bash is invoked as an interactive login shell, or as a
non-interactive shell with the --login option, it first reads
and executes commands from the file /etc/profile, if that
file exists. After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile, in that order,
and reads and executes commands from the first one that exists
and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.
You can call it from one of those files. If none of those files exist, you can create them.
I wrote my first useful shell script! now I would like to make it run as soon as I log in. where should I put the shell scrip to auto run?
thanks!
may be you are interested on running the script once at boot, on that case you should put you your script in /etc/rc.local, this script is launched after all /etc/rc.d stuff. and with root privileges.
ok... This is a personal computer, I'm running as user. I placed my script on /etc/rc.local (I had to md rc.local) but my script didn't run when I logged in.
I also put it on /etc/rc.d but it didn't work!
last thing I did was to put the scrip on in /etc/init.d but nothing!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.