SUSE / openSUSE This Forum is for the discussion of Suse Linux. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
11-02-2005, 05:57 PM
|
#1
|
LQ Newbie
Registered: Nov 2005
Posts: 3
Rep:
|
How to run a command automatically on start up
Sorry for (what seems to me as), a stupid question - I'm an IT pro but very new to Linux and fairly embarassed about it
I'm looking to run a command automatically at startup...
Specifically - ip route add 'ipaddress'/24 'gateway'
How could i do that?
In windows I would have just used the -p switch, is there an eqivalent in Linux?
Continuing from that - how would I launch an application immediately after log-in?
|
|
|
11-02-2005, 06:11 PM
|
#2
|
LQ Newbie
Registered: Jul 2005
Posts: 15
Rep:
|
You can make a permanent route by adding it to /etc/sysconfig/network/routes
|
|
|
11-02-2005, 06:12 PM
|
#3
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
i'd assume there's a better solution to actually do what you want, but to do literally what you're asking, you'd add a line to /etc/rc.local
as for logging on, well that can be a little messy.. what does "log-in" mean? sounds daft, but every time you open a new terminal window in X, you're essentially logging on again... you can so this by adding commands to ~/.bashrc per user, but i don't think this is really what you're after
|
|
|
11-02-2005, 06:12 PM
|
#4
|
LQ Newbie
Registered: Jul 2005
Posts: 15
Rep:
|
If it's an X application, then you can add this to .xinitrc (or equiv for your particular display manager)
You can also add to the profile for your shell - typically ~/.bashrc
|
|
|
11-02-2005, 06:24 PM
|
#5
|
Member
Registered: Jul 2003
Location: Brighton, Michigan, USA
Distribution: Lots of distros in the past, now Linux Mint
Posts: 748
Rep:
|
The ridiculously easy way is simply to take that line, preface it with a line above it invoking bash, then drop it into your start scripts directory (varies with distribution)
For instance, the script would be (and this most likely remains true on all distros):
#! /bin/bash
ip route add 'ipaddress'/24 'gateway'
create the file with your favorite editor, then navigate to /etc, and look for something along the lines of rc#.d (or a variation like rc.5, etc.), and copy the file there with the prefix S## (bigger numbers are better, as they start later, allowing more important processes to start first, though you might need a smaller number so it starts before a process that needs it up and running) (as the root user, obviously). use chmod to make sure it's readable/executable ('man chmod' on the command line can guide you), and reboot to test, or start the file manually (/etc/rc'directory'/name of your file.
Sounds complicated, but you can get the idea by looking at the relevant /etc/rc... files and directories and taking your cues from them. Don't be too worried about some of the items in the files themselves, as they are simply shell scripts to ensure that the programs don't start multiple copies or restart if they fail (you can add these things later, but for now they are redundant, as you can manually do the same if you must, and they don't typically fail in this manner).
|
|
|
11-02-2005, 06:54 PM
|
#6
|
LQ Newbie
Registered: Nov 2005
Posts: 3
Original Poster
Rep:
|
Thanks guys - perfect. Seems that I learn at least 5 new useful procedures with every thread I read round here.
As for what I meant by 'log-in', sorry about that i'm still with 'windows speak' for the time being. I was refering to starting a session in X. Say if I logged in as 'TKD' i want gaim to auto-launch - whereas i'd want different apps to launch if i logged in as root.
Should I be looking at .xinitrc for this?
|
|
|
11-03-2005, 05:41 AM
|
#7
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
well no you wouldn't, again depends what you're logging in to... gnome and KDE will autosave sessions is you want them to, so that's done at a totally hands-off patronizng gui level afaik, .xinitrc is only used when you load X from a console, not when you log into X through a grpahical login maanger. there is ~/.Xsession though.
|
|
|
All times are GMT -5. The time now is 08:48 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|