Linux Password Changing

LinuxLinuxBeginner
Practice Now

Introduction

In the bustling underground community of Cyberhaven, a place where knowledge of technology reigns supreme, the security of digital assets is not just a priority—it's a way of life. In this future city, hackers and coders thrive in a subterranean landscape of neon lights and advanced computer systems. Among this hidden society, a renowned leader known as the Cyberguardian stands out for their exceptional aptness in securing the community's digital environment.

As a new member of Cyberhaven, you’ve been given the important task of maintaining the security of the community by managing user access. Your objective is to master the passwd command, a vital skill for changing and securing user passwords. With great power comes great responsibility, and your ability to protect user accounts will bolster the defenses of the whole community against potential threats.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/UserandGroupManagementGroup -.-> linux/passwd("`Password Changing`") subgraph Lab Skills linux/passwd -.-> lab-271347{{"`Linux Password Changing`"}} end

Understanding the passwd command

In this step, you will learn how to change a user's password using the passwd command. The passwd command allows you to update the password of the user's account you are currently logged into, or as the system administrator, you can change the password for any account.

First, create a new user to practice with by using the useradd command. Navigate to the terminal's default working path, /home/labex/project:

cd /home/labex/project
sudo useradd cyberuser

Next, you'll change the password for cyberuser. Enter the passwd followed by the username:

sudo passwd cyberuser

The system will prompt you to enter a new password twice for confirmation. Make sure to choose a strong password that includes a combination of letters, numbers, and special characters.

Enforcing Password Policies

Now that you know how to change a password, it's critical to enforce strong password policies. You'll learn how to enforce password complexity and expiration.

Create a password policy file named cyberpolicy.sh in the ~/project directory with the following content:

cd ~/project
touch cyberpolicy.sh

Edit cyberpolicy.sh using your preferred text editor. You can enforce password complexity by adding rules to this file:

echo "password requisite pam_pwquality.so retry=3 minlen=8 difok=3" | sudo tee -a /etc/pam.d/common-password

To set a password expiration policy, use the chage command:

sudo chage -M 90 cyberuser

This command enforces that the password for cyberuser must be changed every 90 days.

Summary

In this lab, you practiced essential skills for changing and securing user passwords in a Linux environment. Starting with the basics of using the passwd command, you then enforced password complexity and expiration policies to enhance security. This exercise reflects real-world scenarios where password management is crucial for safeguarding digital infrastructure. Your understanding of these concepts will allow you to configure robust security policies, keeping Cyberhaven safe from digital threats. Your role in the underground city is now solidified, and you’re one step closer to becoming a trusted Cyberguardian.

Other Linux Tutorials you may like