LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-26-2009, 10:42 PM   #1
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Rep: Reputation: 31
running commands upon login


What's the most appropriate place to put commands that should be run upon login? I want somewhere that will run no matter how I log in (X login via kdm/gdm, ssh, tty, etc). I want to do this so I can start a few background programs (like an ssh tunnel to be used as an HTTP proxy).
 
Old 02-26-2009, 11:01 PM   #2
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware
Posts: 1,134

Rep: Reputation: 277Reputation: 277Reputation: 277
I'd put them in .bash_profile, but in such a way that there would be checks to ensure that the processes aren't already running, ie., .bash_profile will be sourced with each of your logins.

For example, my lappy is setup so that both my wife and I autologin and startx, so my .bash_profile has this:

Code:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/vc/3 ]; then
startx
fi
which checks to ensure that x isn't already running, and that the tty that startx is called from is vc3.

You may also consider putting some commands in rc.local, for example, I have a couple of ssh tunnels that are started in rc.local, which means that they are established whether or not anyone is actually logged in.

cheers,
 
Old 02-26-2009, 11:14 PM   #3
abolishtheun
Member
 
Registered: Mar 2008
Posts: 183

Original Poster
Rep: Reputation: 31
Thank you for the reply. I didn't know about rc.local and yea, that's probably the ideal place to run ssh tunnel... but is there a shell-agnostic version way of running a script like .bash_profile? (I'm guessing no, since the way I understand it, when you log in, the tty forks a process and exec's the shell directly, so nothing in between...) does every shell have something comparable?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What SU Commands Have you Given to Your Login? halfpower Linux - General 5 08-12-2006 08:24 AM
Auto-running commands on X login for all users Yalla-One Linux - Software 0 09-05-2005 11:49 AM
Running Commands blazted Linux - Newbie 6 11-13-2004 03:49 PM
running commands ./ ?? greendemon Linux - Newbie 4 08-04-2003 09:54 AM
Running commands linuxnewbie001 Linux - Newbie 6 08-01-2003 04:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration