0
0
Linux CLIscripting~15 mins

passwd (change password) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Change User Password Using passwd Command
📖 Scenario: You are a system administrator who needs to update a user's password on a Linux system. You will practice using the passwd command to change the password for a specific user.
🎯 Goal: Learn how to change a user's password using the passwd command in Linux CLI by specifying the username and setting a new password.
📋 What You'll Learn
Use the passwd command to change a user's password
Specify the username whose password you want to change
Set a new password for the user
💡 Why This Matters
🌍 Real World
System administrators often need to update user passwords quickly and securely using scripts.
💼 Career
Knowing how to automate password changes is useful for managing multiple users in Linux server environments.
Progress0 / 4 steps
1
Identify the user to change password for
Create a variable called username and set it to the exact string student1 to represent the user whose password you want to change.
Linux CLI
Need a hint?

Use simple assignment like username='student1'.

2
Prepare the new password variable
Create a variable called new_password and set it to the exact string SecurePass123 which will be the new password for the user.
Linux CLI
Need a hint?

Assign the password string exactly as shown.

3
Use passwd command to change the password
Write a command using echo and passwd to change the password for the user stored in username. Use the syntax echo -e "new_password\nnew_password" | passwd username --stdin to set the password non-interactively.
Linux CLI
Need a hint?

Use echo -e "$new_password\n$new_password" | passwd $username --stdin to change password.

4
Display confirmation message
Write a echo command to print the exact message Password changed successfully for user student1 to confirm the password change.
Linux CLI
Need a hint?

Use echo "Password changed successfully for user student1" to print the message.