Linux passwd Practices: 10 Exercises
Practice 1: Changing Your Own Password
Objective: Learn to change your own user password.
Instructions:
1. Open your Linux terminal.
2. Type the command to change your password:
passwd
3. Follow the prompts to enter and confirm a new password.
4. Imagine you’re securing access to your Stark Tower systems.
Practice 2: Changing Another User’s Password (Admin Required)
Objective: Use passwd as an administrator to change another user’s password.
Instructions:
1. Open the terminal and ensure you have administrative privileges.
2. Change the password for the user IronMan:
sudo passwd IronMan
3. Enter the new password when prompted and confirm.
4. Think of this as reconfiguring Iron Man’s suit authentication.
Practice 3: Disabling a User’s Password
Objective: Learn to disable a user’s password.
Instructions:
1. Open your terminal.
2. Disable the password for the user Thor:
sudo passwd -l Thor
3. Verify that the user cannot log in with Thor's password.
4. Consider this as restricting Thor’s access to the Bifrost temporarily.
Practice 4: Re-Enabling a User’s Password
Objective: Re-enable a previously disabled password.
Instructions:
1. Open your terminal.
2. Re-enable the password for the user Thor:
sudo passwd -u Thor
3. Verify that the user can log in again.
4. Think of this as granting Thor access back to the Avengers database.
Practice 5: Forcing Password Change at Next Login
Objective: Require a user to update their password upon next login.
Instructions:
1. Open the terminal.
2. Set the BlackWidow user to change their password at the next login:
sudo passwd --expire BlackWidow
3. Verify that BlackWidow is prompted to change the password upon login.
4. Consider this as a precaution for a secured mission.
Practice 6: Setting a Password Expiry Date
Objective: Set a password expiration policy for a user.
Instructions:
1. Open the terminal.
2. Set the password for Hulk to expire in 30 days:
sudo chage -M 30 Hulk
3. Verify the password expiration policy with:
sudo chage -l Hulk
4. Think of this as limiting Hulk’s access to sensitive data for a specific period.
Practice 7: Viewing Password Information
Objective: Use passwd to view password details for a user.
Instructions:
1. Open the terminal.
2. View password status for CaptainAmerica:
sudo passwd -S CaptainAmerica
3. Observe the output to see if the account is locked or active.
4. Imagine this as checking Cap’s shield system status.
Practice 8: Locking a System Account
Objective: Use passwd to lock a non-human system account.
Instructions:
1. Open the terminal.
2. Lock the system account Jarvis:
sudo passwd -l Jarvis
3. Verify that the account is locked with:
sudo passwd -S Jarvis
4. Think of this as disabling an AI system for upgrades.
Practice 9: Unlocking a System Account
Objective: Unlock a previously locked system account.
Instructions:
1. Open the terminal.
2. Unlock the system account Jarvis:
sudo passwd -u Jarvis
3. Verify the account is active again with:
sudo passwd -S Jarvis
4. Consider this as rebooting Jarvis after maintenance.
Practice 10: Removing a Password
Objective: Remove a password for a user to allow password-less login.
Instructions:
1. Open the terminal.
2. Remove the password for the user Hawkeye:
sudo passwd -d Hawkeye
3. Verify that the user can now log in without a password.
4. Think of this as temporarily enabling Hawkeye’s free access during an
emergency.