LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command to skip enter current password (https://www.linuxquestions.org/questions/linux-newbie-8/command-to-skip-enter-current-password-621160/)

ssy68 02-14-2008 03:28 PM

command to skip enter current password
 
I'm in root, and added a user test1 by useradd command.
Now I want to do something like 'su - test1 -c passwd' to change the password for test1 as user test1.

The prompt will be:
Changing password for test1
(current) UNIX password:

But the test1 doesn't have a current password. Is there a command to let me su to be test1 from root but it will not prompt for the current password, and just let me type the new password?

Thanks.

apolinsky 02-14-2008 03:32 PM

If you are root, you could just say passwd test1 to add a password.

farslayer 02-14-2008 03:33 PM

how about skipping the su step and just changing the password.


Code:

it-etch:~# passwd test1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


ssy68 02-14-2008 03:50 PM

I want to change passwd as test1 not as root. Because I want test1 password to apply pam restirctions. If I don't su, pam restrictions will not work.

Poetics 02-14-2008 05:31 PM

What about changing the password via "# passwd test1" and -then- su'ing over and changing it?

chrism01 02-14-2008 11:56 PM

Try writing a short Expect script and call that
su - test1 -c myscript
Expect is designed to automate manual stuff like the paswd cmd

billymayday 02-15-2008 12:52 AM

ssy, if you change test12's password, you change tests1's password - it doesn't matter who does it (onlu root or test1 can probably).

Take up up the suggestion to either be root and

passwd test1

or as another user sudo passwd test1

PAM will use test1's password just fine


All times are GMT -5. The time now is 09:01 PM.