Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Problem with feeding password while changing to root user

Shell Programming and Scripting

change user, feed password automatically

Thread Tools Search this Thread Display Modes
Old Unix and Linux 01-16-2013   -   Original Discussion by mhmn
mhmn mhmn is offline
Registered User
Join Date: Jan 2013
Last Activity: 20 January 2013, 2:14 AM EST
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
Problem with feeding password while changing to root user

i want to change user to "root" from another user while running a script. how can i automatically feed the password? for example, i want to write a script say "script.sh"... it will first run the command "p" as mhmn user, and then it will change the user to "root" by using "su - root" command. at this point it asks for the password for root. say the password is "blue". i want to feed the p.w. automatically while it asks for it. inside script.sh it will look something like-

#su - root 
(feed p.w. automatically here)

Last edited by Scott; 01-16-2013 at 06:34 AM.. Reason: Code tags
Sponsored Links
Old Unix and Linux 01-16-2013   -   Original Discussion by mhmn
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Join Date: Jun 2009
Last Activity: 21 November 2017, 12:36 PM EST
Location: Zürich
Posts: 8,832
Thanks: 368
Thanked 1,201 Times in 1,025 Posts
That's not possible, except if the user is a member of the wheel group and PAM is configured to allow it.

Configuring sudo is probably the better way to go. Giving carte blanche access to root using su in this way is generally not a good idea.
The Following User Says Thank You to Scott For This Useful Post:
mhmn (01-16-2013)
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Permission denied when changing root password after reset darkone_d1_2000 UNIX for Dummies Questions & Answers 0 06-25-2010 01:32 PM
changing user password as root on LDAP client SOl10/u7 ilikecows Solaris 1 08-05-2009 10:18 AM
Problem changing user password bbbngowc Linux 6 04-24-2009 02:28 PM
Changing root password zetadhell HP-UX 3 05-14-2007 07:42 AM
changing user password mayge AIX 0 07-12-2006 12:08 PM

All times are GMT -4. The time now is 01:42 PM.