Linux Command To Change Password For Root / User / Group

November 25, 2012 | By
| Reply More

Passwords are the way of authenticating a user in Linux system. Linux uses MD5 as an algorithm for storing the password hashes. MD5 is a one way hashing algorithm which is very secure way of authentication. This article tells how a user can change password for his/her account.

Changing password

The ‘passwd’ command can be used for changing passwords of a user account. You must provide your existing password before you proceed to changing the password. The password must be typed twice. This password is not echoed on the screen as you type it.

$ passwd
Changing password for raghu.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

You cannot provide simple words as your passwords. In the following output, a simple, dictionary based password is tried.

$ passwd
Changing password for raghu.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
Bad: new password is too simple
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Every user can change his/her password only. The ‘passwd’ command does not take any argument when run as a normal user. The 'whoami' command can be used to see your login id.

$ whoami
raghu

$ passwd jenny
passwd: Only root can specify a user name.

The root user can change password of any user. The root user is not even asked for the current password of that user.

$ whoami
root

$ passwd jenny
Changing password for user jenny.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Root user can even provide simple passwords. For example,

$ passwd jenny
Changing password for user jenny.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Although a warning is displayed, still the password is changed successfully.

Change group password

Passwords to groups can be added with 'gpasswd' command.

$ gpasswd project1
Changing the password for group project1
New Password:
Re-enter new password:

Filed Under : HOWTOS, LINUX COMMANDS, LINUX HOWTO, USER MANAGEMENT

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.