LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-10-2005, 08:29 AM   #1
scottjwoodford
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Rep: Reputation: 15
Run program as root at logon?


Is there any way to run a program as root at log on for a RedHat 9.0 system running Gnome? I have already used the rc.local file, and it starts up the program during boot - which works fine. But I need the program to be run during logon. I'm really lost. Thanks for any help,

Scott
 
Old 06-10-2005, 08:38 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
You mean that when any non-root user logs on, this program should run with root permissions?

Make sure the program is owned by root, then chmod u+s

Put the command to call the program in ~/.login and you should be set.

John
 
Old 06-10-2005, 08:41 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
You can always edit your /etc/sudoers file and add :
Code:
scottjwoodford  <hostname>  = NOPASSWD: /path/to/command <args...>
And put in ~/.bash_profile :
Code:
sudo /path/to/command <args...>
I assume your program does not present a risk to do
any damage and is not writtable by the user
 
Old 06-10-2005, 09:34 AM   #4
scottjwoodford
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Jkobrien, what exactly does chmod u+s do? Just curious. Also, I do not have a ~/.login file. Is it maybe called something else in RedHat 9.0? I do have a login.defs file, but I don't think that's what you were referring to.

Keefaz, I will try your suggestion. When you put down "scottjwoodford", did you mean that literally? Or should I put "root"?

Thanks guys!
 
Old 06-10-2005, 09:46 AM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
It is the username as seen when you type 'id' or 'whoami'
in a terminal when you're logged as user
 
Old 06-10-2005, 09:58 AM   #6
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Quote:
Jkobrien, what exactly does chmod u+s do? Just curious. Also, I do not have a ~/.login file. Is it maybe called something else in RedHat 9.0? I do have a login.defs file, but I don't think that's what you were referring to.
I would go with Keefaz' suggestion. It's neater and easier to track and modify later.

u+s means that whoever runs the program will have the same permissions as whoever owns the program. Type "man chmod".

You can always make a .login file if there isn't one there already - be adventurous! .login will be run, I think, regardless of which shell you use, while something like .bashrc, or .tcshrc, and so on, are shell specific.

John
 
Old 06-10-2005, 10:12 AM   #7
scottjwoodford
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Ok, but there's no way for me to know which user it will be logging on (there are multiple users), so can I add a line for all user's? And this may be a dumb question, but for <hostname>, do I literally enter that, or do I enter the actual hostname?
 
Old 06-13-2005, 04:30 AM   #8
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
You'll have to a little reading up on this, but in /etc there are files that are read and executed for every user that logs in. I'm not clear myself on which ones are read when so, like I say, you'll have to do a little digging yourself but look at files like /etc/profile or it maybe that you can create /etc/login. The man pages and google will help you out there.

Watch out for the difference between scripts that are called at boot-up, log-on or when opening a new shell.

<hostname> means you should replace all that text (including the <>) with your actual hostname. It's a convention that's often used to indicate a placeholder (a bit like algebra) for your actual values. Square brackets [ ] are sometimes used for optional arguments.

Good luck,

John
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run GUI program as root shadkong Slackware 8 09-20-2005 02:24 PM
My Knoppix 3.7 need root password when I run program AskMe Linux - Software 5 04-15-2005 05:35 AM
run program as root / password prompt acidjuice Linux - Software 6 03-15-2005 10:33 PM
forcing program to run in root mode acidjuice Linux - Software 1 03-09-2005 07:17 AM
Automatically run root program. Hammett Linux - Software 4 05-16-2004 12:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:30 PM.

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