Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

passwd Command

News Authentication and Accounts Security in "After Snowden" world Recommended Links

chpasswd

Password Policy in 'After Snowden" World Reference
Password synchronization Expect Admin Horror Stories Unix History Humor Etc

The use of passwords and their implementation is highly dependent upon your company's security policy and your system administrator. Some orgnization do not control password complexity and expiration,  while others require certain level of passwords (for example legnth and mixture of characters), perform full accounting on every user, and implement password aging.

The passwd command reads the /etc/passwd file to verify the the user name exists. The /etc/shadow file is used to store hash of the password. The password itself is never stored.

The external passwd command allows you to create or change the password associated with your user name. The super-user (system administrator) can change any user's password and is not prompted for the old password. As a user you can only change your password, if you know the current password. which creates difficulties if you longin  from your Pc terminal emulator using ssh without passord and now need to change passord for some reason.

the general format

     passwd [ user_name ]
     passwd [ -df ][ -n min ][ -x max ][ -w warn ]user_name
     passwd [ -fl ][ -n min ][ -x max ][ -w warn ]user_name
     passwd -s[-a ]
     passwd -s[ user_name ]

Options

The following list describes the options used to control how passwd functions.

-d Deletes the password for user_name. The user_name will not be prompted for a password.
-f Force the password to expire. The user_name is forced to enter a new password at the next login.
-l Lock the password entry for user_name. No changes may be made.
-n min Set the minimum number of days between password changes.
-s Display (show) password attributes for user user_name. If no user_name is specified, your login user_name is used. The format of the information is,
user-name status mm/dd/yy min max warn
or, if no password aging information is present
user-name status
where
user_name The login ID of a user
status The password status
PS Passworded
LK Locked
NP No password
mm/dd/yy The date the password was last changed
min The minimum number of days between password changes. The label MINWEEKS specifies the default. It is located in the /etc/default/passwd file and is set to NULL. If min is greater than max, the user may not change the password. Always use with the -x option.
max The maximum number of days the password is valid. The user is forced to change the password every max days. The label MAXWEEKS specifies the default. It is located in the /etc/default/passwd file and is set to NULL. If max is set to -1 then aging is turned off. If it is set to 0 then user_name is forced to change the password at the next login and aging is turned off.
warn The number of days before the password expires, based on max, that the user_name will be warned.
-a Display password attributes for all entries in the password file.
-w warn Set the number of days before the password expires to notify the user_name.
-x max Set the maximum number of days the password is valid.

Arguments

The following list describes the argument that may be passed to the passwd command.

user_name A valid user name in the /etc/passwd file. The user name is the first column (colon-separated columns) of the /etc/passwd file. Only the super-user can change another user's password.

Password aging

The passwd command is capable of checking the elapsed time since the password was last changed, referred to as password aging. If the specified perod expired, then the user is required to change the password. In other words password aging requires that a user must change passwords after a specified amount of time. The system administrator decides if password aging is activated and how long each password is aged.


BSD (Berkeley)
Most BSD based systems do not provide password aging. You should check your reference manual for specific password implementations on your system.

The following is a list of requirements that a password must meet before passwd will allow it as your password.

1.  Must contain six characters (this is default; sen be set sysadmin to higher legth). The label PASSLEN specifies the maximum length for a password. It is in the file /etc/default/passwd.
2.  Must contain 2 alphabetic characters (upper or lowercase letters) and at least one special character or number.
3.  Must not be any circular shift combination or reversal of the user name. For example, if your user name is bill, your password could not be lbil, llbi, illb, or llib, blli, ibll, libl.
4.  New passwords must have at least 3 characters that differ from the old password.

The passwd command returns the following return codes upon completion:

0 Successful
1 Permission denied
2 Invalid combination of options
3 Unexpected failure, the password file is left unchanged
4 Unexpected failure, the password file is missing
5 The password file is busy, try again later
6 Invalid argument to an option

The $? ($status-csh) shell variable contains the return code. So echo $? will display the return status.

Examples


TIP:  Your password should be some combination of two preferably meaningless strings of intermixed numbers, characters, and symbols. Names of friends, wives, husbands, etc. are easily guessed by the criminal/jerk next door, down the street, or around the world via your profiles and  posts on social sites.
If you change password on user level you will be prompted for old password. If you do not have a password, you will not see the following prompt, because UNIX knows you don't have an old password.
    cj> passwd
    Enter old passwd:
3.  After passwd verifies that you entered the correct old password it will prompt you for a new password.
    cj> passwd
    Enter old passwd:
    Enter new passwd:
4.  passwd will require you to repeat the new password so that you know you typed it correctly.  If you fail you will be asked to renter:
    cj> passwd
    Enter old passwd:
    Enter new passwd:
    Re-enter new passwd:
If the new password you typed does not match, your password will not be created or updated. Notice the following message that passwd returns in this situation.
    Mismatch - passwd not updated!
Linux passwd Command Tutorial for Beginners (8 Examples)

Following is some useful information that you need to know about passwd's operation:

       The user is first prompted for his/her old password, if one is present.
       This password is then encrypted and compared against the stored
       password. The user has only one chance to enter the correct password.
       The superuser is permitted to bypass this step so that forgotten
       passwords may be changed.

       After the password has been entered, password aging information is
       checked to see if the user is permitted to change the password at this
       time. If not, passwd refuses to change the password and exits.

       The user is then prompted twice for a replacement password. The second
       entry is compared against the first and both are required to match in
       order for the password to be changed.

       Then, the password is tested for complexity. As a general guideline,
       passwords should consist of 6 to 8 characters including one or more
       characters from each of the following sets:

       ·   lower case alphabetics

       ·   digits 0 thru 9

       ·   punctuation marks

       Care must be taken not to include the system default erase or kill
       characters.  passwd will reject any password which is not suitably
       complex.

For example, in my case, here's how I changed the passwd:

Please note that in case you have superuser privileges (or are a system admin), you can change any account's password by just mentioning the username of the account. For example:

passwd himanshu

Q2. How to make an account password-less?

The passwd command also lets you delete a password associated with a user account. For this, you need to use the -d command line option.

passwd -d

So this is basically a quick way to disable password for an account, essentially making it password-less.

Q3. How to forcibly expire a password?

Sometimes the system admin may want a user to change their password immediately. So in that case, they may use the -e command line option which results in immediate expiry of the password, forcing user to change their password on the very next login.

passwd -e

Q4. How to disable an account if password remains expired?

The passwd command also lets you deal with situations where-in user doesn't take any action even after their password is expired. Basically, the tool lets you disable the account altogether in case password remains expired for a set number of days. This you can do using the -i command line option, which requires a number as input.

For example:

passwd -i 5

So this command will make sure the account is disabled if the password remains expired for 5 days.

Q5. How to set a time gap between password changes?

The passwd command also allows you to set a minimum time gap between password changes. This is made possible through the -n command line option, which requires a numeric value that's treated as number of days.

For example:

passwd -n 10

This command makes sure there's a gap of 10 days between any two password changes. It's worth mentioning that a value of 0 indicates that the user may change his/her password at any time.

Q6. How to make passwd display account status info?

This you can do using the -S command line option.

Here's how the official documentation explains these fields:

           Display account status information. The status information consists
           of 7 fields. The first field is the user's login name. The second
           field indicates if the user account has a locked password (L), has
           no password (NP), or has a usable password (P). The third field
           gives the date of the last password change. The next four fields
           are the minimum age, maximum age, warning period, and inactivity
           period for the password. These ages are expressed in days.
Q7. How to set password validity period?

The passwd command allows you to do this through its -x option, which requires a number representing the maximum number of days a password remains valid.

For example:

passwd -x 100

Q8. How to make passwd warn users about due password change?

This can be done using the -w command line option, which requires a number as input, which is nothing but number of days prior to the password expiring that a user will be warned that his/her password is about to expire.

For example:

passwd -w 7 


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019