0
0
Linux CLIscripting~10 mins

passwd (change password) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - passwd (change password)
User runs 'passwd'
Prompt: Enter current password
User inputs current password
Prompt: Enter new password
User inputs new password
Prompt: Confirm new password
User confirms new password
System checks passwords match
Password [Error: Passwords do not match
Restart new password prompt
Success message
Exit
The passwd command asks for the current password, then the new password twice, checks if they match, and changes the password if all is correct.
Execution Sample
Linux CLI
passwd
Enter current password:
Enter new password:
Retype new password:
This sequence shows the prompts when changing a password using the passwd command.
Execution Table
StepActionUser InputSystem CheckResult/Output
1Run 'passwd' commandPrompt: Enter current password:
2User enters current passwordcurrent_passwordVerify current passwordIf correct, prompt: Enter new password:
3User enters new passwordnew_passwordPrompt: Retype new password:
4User retypes new passwordnew_passwordCheck if new passwords matchIf match, password changed successfully
5If passwords do not matchmismatched_passwordCheck if new passwords matchError: Passwords do not match, prompt again for new password
6Password changedSuccess message: password updated
7ExitReturn to shell prompt
💡 Execution stops after successful password change or user aborts.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
current_passwordunsetuser inputuser inputuser inputused for verification
new_passwordunsetunsetuser inputuser inputused for confirmation and update
password_matchunsetunsetunsettrue/falsetrue if passwords match, else false
Key Moments - 3 Insights
Why does passwd ask for the new password twice?
To make sure the new password is typed correctly both times. If they don't match (see execution_table step 5), it asks again to avoid mistakes.
What happens if the current password is entered incorrectly?
The system will reject it and not proceed to new password prompts. This is shown in execution_table step 2 where verification fails and passwd exits or retries.
Can you see the password as you type it?
No, for security reasons the input is hidden (no characters shown). This prevents others from seeing your password.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what happens at step 4 if the new passwords match?
APassword is changed successfully
BError message is shown
CUser is asked to enter current password again
DThe command exits without changes
💡 Hint
Check the 'Result/Output' column at step 4 in the execution_table
At which step does the system verify the current password?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'System Check' column in the execution_table
If the new passwords do not match, what does the system do next?
AChanges the password anyway
BExits the command immediately
CShows an error and asks to re-enter new password
DAsks for current password again
💡 Hint
See the row for step 5 in the execution_table under 'Result/Output'
Concept Snapshot
passwd command changes user password
1. Enter current password for verification
2. Enter new password twice to confirm
3. If new passwords match, password updates
4. If mismatch, prompts again
5. Password input is hidden for security
Full Transcript
The passwd command is used to change a user's password on Linux. When you run passwd, it first asks you to enter your current password to confirm your identity. Then it asks you to enter a new password twice to make sure you typed it correctly. If the two new passwords match, the system updates your password and shows a success message. If they don't match, it shows an error and asks you to enter the new password again. Passwords are not shown on screen as you type for security. This process ensures your password is changed safely and correctly.