LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 04-05-2006, 05:32 PM   #1
Etoile
LQ Newbie
 
Registered: Apr 2006
Distribution: Ubuntu 5.10 (Breezy)
Posts: 3

Rep: Reputation: 0
How to tell shell script a password?


I'm running Ubuntu (Breezy) and I need to execute a 'sudo' command at startup. I don't think it will work through the "startup programs" window because sudo requires a password. So I want to write a shell script that I can just execute manually at startup. But how do I tell it what my password is so it can answer the Password prompt? Thanks!
 
Old 04-05-2006, 05:47 PM   #2
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 61
If all you need to do is one command I would edit /etc/sudeors file. You have to use ' visudo ' command to edit the file. In it I assume there is a section like this.
# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL) ALL

You can it to this so as not to need to use a passwd ever again. ( not the best idea )
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

Or just allow a single or a few commands to execute without roots password.
username ALL=NOPASSWD: /sbin/ifdown, /sbin/mount

Brian1
 
Old 04-05-2006, 06:18 PM   #3
Etoile
LQ Newbie
 
Registered: Apr 2006
Distribution: Ubuntu 5.10 (Breezy)
Posts: 3

Original Poster
Rep: Reputation: 0
I used your last suggestion and it did the trick for me. Many thanks!
 
Old 04-05-2006, 06:41 PM   #4
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 61
Yes the last one would be more secure. This way it limits the cammands you can do this way. The second one would work as long as you never add other users to the wheel group. Kind of gives you full root anytime with only the need to add sudo before the command to execute.

Brian1
 
Old 04-05-2006, 07:39 PM   #5
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
If it's something that can be run before a user logs on, you can add it to your local boot script (/etc/boot.local or something similar). This script is run as root, so sudo is not necessary.

If it's a command that needs to be run in a graphical environment, then it won't work this way.
 
Old 04-05-2006, 09:16 PM   #6
Etoile
LQ Newbie
 
Registered: Apr 2006
Distribution: Ubuntu 5.10 (Breezy)
Posts: 3

Original Poster
Rep: Reputation: 0
Cool, thanks! Hopefully I can figure out BUM for that, or something.
edit - turns out to be "or something"

Last edited by Etoile; 04-05-2006 at 09:24 PM.
 
  


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
Shell script to change password kamal_aitin Linux - General 6 07-25-2007 12:09 AM
Setting password for users in a shell script?? krishvij Linux - Newbie 3 03-10-2005 09:17 AM
Shell Script For Password cpope67 Programming 4 01-10-2005 02:16 AM
Password Shell Script Solaris 9 cpope67 Solaris / OpenSolaris 1 12-30-2004 03:15 PM
how to assign password for a user in shell script mtest Programming 10 10-29-2003 06:52 AM


All times are GMT -5. The time now is 07:38 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration