Linux set or change user password how to

by Vivek Gite · 15 comments

Q. How do I set or change Linux system password?

A. Both Linux and UNIX use passwd command to change user password.

passwd changes passwords for user and group accounts. A normal user may only change the password for his/her own account, the super user may change the password for any account. The administrator of a group may change the password for the group. passwd also changes account information, such as the full name of the user, user's login shell, or password expiry date and interval.

Task: Set or change user password

Type passwd command as follows>
$ passwdOutput:

Changing password for vivek
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

The user is first prompted for his/her old password, if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed.

A new password is tested for complexity. As a general guideline, passwords should consist of 6 to 8 characters including one or more from each of following sets:
=> Lower case alphabetics
=> Upper case alphabetics
=> Digits 0 thru 9
=> Punctuation marks

Task: Change for any user

You must login as root user, type the command to change password for user vivek:
# passwd vivekOutput:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Where,

  • vivek - is username or account name.

Task: Change group password

When the -g option is used, the password for the named group is changed. For example change password for group sales:
# passwd -g sales

The current group password is not prompted for. The -r option is used with the -g option to remove the current password from the named group. This allows group access to all members. The -R option is used with the -g option to restrict the named group for all users.

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 15 comments… read them below or add one }

1 bambi 04.24.07 at 7:22 am

Could you help me how to edit the commands before booting in CentOS? I can’t seem to get it right.
choose the desired OS, in this case CentOS then press e for edit then select the kernel then press e again and type space linuxsingle then enter to accept changes, press b for boot. They told me that a prompt will appear but there is none so that i can type passwd to change the password and username. Pls. help me.

2 Rick 02.12.08 at 3:02 am

thanks this help alot

3 Aloka 02.03.09 at 7:52 am

hi!
I am Aloka . I am student of computer science & I have linux on my machine.
i forgotten the username & password of it.
can u help me for this for changing the username & password.
plz help me.

4 Andy 02.17.09 at 3:19 am

Go to linux rescue mode (single user mode) at the boot prompt when the linux image is loaded and reset your password through the prompt.

5 Chloe 05.07.09 at 8:19 pm

Hey, i want to set my password so that when my linux laptop starts up, my account name comes up and i have to type my password in so that others cannot access my account settings without my password. Help me please!? x

6 Atta 05.28.09 at 9:54 pm

Hi

As a root user I want to reset lost of passwords and want to set each users password with a single command i.e. not have to be asked to type passwords afterwords. So the command needs to include the new password and not require the old one.

Help would be greatly appreciated

7 Varun 09.10.09 at 8:02 am

How can I change the root password while I’m only a user of it? Please reply me, as fast as can be.

8 AeSix 09.11.09 at 4:50 am

Varun use sudo su
use your user pass
then run passwd
if your user account dont have privlages enough to run as su, your sol.

9 UnixOS 09.12.09 at 11:24 am

AeSix, Don’t you know how can I get or reset password of another user if i am user with limited privilages?! help please….

10 abbakus 10.08.09 at 5:54 pm

Hi,
how can i set an UNSECURE password? During installation process i’m able to set an unsecure password, but it isn’t possible once the system is installed. I know it’s a bad
practice, but i really need to do it.

Anyone?

Thanks.

11 deepak mishra 11.16.09 at 8:39 am

i ,m forget passwd then i can do

12 Talib 11.18.09 at 10:09 am

I am using Cant OS 5.2 with DC & BDC, pls advise if any tool available to monitor it easily from nework.

13 lokesh 12.05.09 at 5:20 am

hello,can u help me out to find out hw to change the passwd wen previous passwd has been forgotten ??????? u have suggested somebody to go to the rescue mode what dose it mean ,plz describe whole procedure in detail! thanks in anticipation!~

14 Charlie Seah Kam Fei 01.28.10 at 9:26 am

is there anyway to READ the password of user instead of reset it if I have root access?

15 Charlie 01.28.10 at 9:27 am

Any files in Linux support that? Thanks in advance

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All