LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 11-14-2012, 11:21 AM   #1
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Rep: Reputation: Disabled
How to set expiring password for existing users?


Hi to all ;

I am trying to set password expiry to all existing users.
I googled with but too much confusions. Can anyone guide me ?

Note:-
While creating user , i can set password expiry date.
how can i put it to all existing users in linux?

>> I know this option >>
Quote:
# useradd -e YYYY-MM-DD -f <days> <user_name>
# useradd -e 2012-11-14 -f 2 rose
Question is => how can i set already existing users ?
ex : existing user is sam

>> -f vs -e >>

Quote:
[root@localhost ~]# useradd -f 2 sams
[root@localhost ~]# useradd -e 2 sams1
here i did n't set expiry date ,

1.how expiry date will be calculated ?
-f <days>
-e <xxxx-xx-xx>

h

Last edited by thiyagusham; 11-14-2012 at 11:37 AM.
 
Old 11-14-2012, 12:52 PM   #2
mandyapenguin
Member
 
Registered: Nov 2011
Location: India
Distribution: RedHat, Cent OS, Fedora, Debian, Ubuntu
Posts: 106

Rep: Reputation: Disabled
Quote:
While creating user , i can set password expiry date.
how can i put it to all existing users in linux?

Question is => how can i set already existing users ?
ex : existing user is sam
You can use chage command to set password expiry date to all users.
Check the password aging policy(PAP) for sam user using
Code:
chage -l sam
For example if you want to set password aging to this user as minimum 0 days maximum 90 days and warn before 7 days, run
Code:
chage -m 0 -M 90 -W 7 sam
Now check whether or not PAP is set to this user
Code:
chage -l sam
Now you will find output something like below
Code:
Last password change				: Oct 15, 2012
Password expires					: Jan 13, 2013
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 90
Number of days of warning before password expires	: 7
The same way you can use for all users. Or even you can set PAP for all users simultaneously using single command
Code:
for i in $(awk -F':' '/\/home.*sh/ { print $1 }' /etc/passwd); do chage -m 0 -M 90 -W 7 $i; done
But before that make sure the users that you are going to set PAP to, using
Code:
for i in $(awk -F':' '/\/home.*sh/ { print $1 }' /etc/passwd); do echo $i; done
For more information
Code:
man chage
To apply PAP automatically for new users you have to edit /etc/login.defs file and there you will find something like below
Code:
PASS_MAX_DAYS   99999
PASS_MIN_DAYS   0
PASS_WARN_AGE   7
change this to
Code:
PASS_MAX_DAYS   90
PASS_MIN_DAYS   0
PASS_WARN_AGE   7

Last edited by mandyapenguin; 11-14-2012 at 10:49 PM.
 
1 members found this post helpful.
Old 11-14-2012, 01:06 PM   #3
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Now you've asked an unrelated question following up the same thread. Can I suggest starting a new thread per question with a new and meaningful title?
 
Old 11-14-2012, 01:09 PM   #4
thiyagusham
Member
 
Registered: Apr 2012
Posts: 213

Original Poster
Rep: Reputation: Disabled
@ mandyapenguin , @ linosaurusroot

Thanks for reply ..
 
Old 11-14-2012, 02:15 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Moderator note: this thread has been pruned from another one in order to give it more visibility. Please, don't hijack existing threads in the future. Thank you in advance.
 
  


Reply



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
Getting password length of already existing users. vickyk Linux - Newbie 1 11-16-2011 06:40 AM
How to : Find user with expiring password . ? avklinux Linux - Enterprise 2 12-12-2008 06:35 PM
Password ageing for existing AIX users szahri AIX 1 04-12-2005 01:44 PM
expiring users acid_kewpie LQ Suggestions & Feedback 10 04-15-2004 01:13 PM
Cant set password for new users ribbones Linux - General 1 09-03-2003 10:56 AM

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

All times are GMT -5. The time now is 02:59 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
Open Source Consulting | Domain Registration