To modify your username, the most effective and secure method in any operating system involves creating a fresh user with a new profile and password. The root user or a user with sudo privileges can then update another user’s password and determine whether it should be kept or altered.
The guidelines mentioned are applicable to various Linux distributions, such as Ubuntu, Debian, and CentOS.
In addition, you will gain knowledge on compelling employees to change their password upon their next login.
The passwd utility in Linux enables the alteration of a user account password.
A file located at /etc/shadow contains confidential account credentials and other information related to passwords.
To ensure security, it is necessary for daily users to regularly update their passwords. The root user and users with sudo privileges have the authority to update the passwords of other users and determine whether they should be kept or changed.
Ensure that the password you select when changing it is both distinct and efficient.
To ensure the security of your account, it is crucial to have a strong password consisting of a minimum of 16 characters, including at least one uppercase letter, one lowercase letter, one number, and one special character.
For optimal security, it is recommended to periodically change your password and use a unique password for each account.
Change Your User Password
Use the passwd command to modify the password for your user account.
To proceed, enter your current password. If it matches, you will be prompted to input and confirm your new password.
The passwords are not shown on the screen when you enter them.
Kindly utilize your recently created password during your next login attempt on the device.
Change Another User’s Password
As mentioned in the introduction, the ability to change the password of another user account is limited to root users and users with access to the sudo account.
The below example suggests that you are logging in as a user with sudo privileges.
To modify the password of a different user account, adhere to the steps provided below:
- Execute the passwd command, specifying the user name afterwards.
- To change the password for a user named linuxize, execute the following command as an example.
You will be required to input the new password and then verify it.
The command will display a result similar to the following output:
Force User to Change Password at Next Login
By default, passwords are set to never expire. To prompt users to change their password upon their next login, utilize the passwd command with the —expire option and specify the username of the user.
With the command provided, the user’s password will expire immediately.
The next time the user tries to log in using the old password, a notification will appear, prompting the user to change their password.
After the user sets a new password, the connection will be closed.