LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-15-2006, 09:39 AM   #1
prasanta.choudhury
LQ Newbie
 
Registered: Feb 2006
Posts: 1

Rep: Reputation: 0
changing user using su


I am trying to change user from within a script using the su command. But su command does not take the password as argument. So when i call su from my script, it displays the enter password prompt. But I want to hard code the password in the script itself and use it for the user change. Is it possible somehow? If not is there any other way to achive this (i.e. change the user)?
 
Old 02-15-2006, 09:51 AM   #2
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
as a simple shell script you'd be putting your root password in plain text if you put it as part of the command (hard coding).... BAAAAAAAAAAAAD (even if setting strict permissions)

You could use sudo (man sudo) edit /etc/sudoers to allow your user to run that program that normally requires root, and without a password, so the command in your script is
Code:
sudo <command>
and it runs

more than one user? setup a group in sudoers, add the users to the group.

What is the script trying to do?

As an after thought (i'm still new to Linux and sripting), maybe you could pipe the correct column value from /etc/passwd or the shadow file and it would work, maybe worth a try.
 
Old 02-15-2006, 07:38 PM   #3
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
If you're trying to do something with root permissions, it probably should be in a script run as root (such as a startup script), rather than doing something funny with su or sudo.
 
  


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
Changing User name akpadhi@hotmail.com LQ Suggestions & Feedback 7 01-13-2006 05:59 PM
Changing a User carlosinfl Linux - General 11 11-29-2005 02:25 PM
Changing user preference kool_kid Slackware 9 02-04-2005 09:19 AM
Changing User Info... rnturn LQ Suggestions & Feedback 4 12-26-2004 08:51 AM
User id (needs changing) podollb Linux - Software 2 05-15-2004 09:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration