Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-15-2006, 10:39 AM   #1
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, 10:51 AM   #2
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
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, 08:38 PM   #3
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.


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

All times are GMT -5. The time now is 08:29 PM.

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