≡ Menu

passwd command

Redhat Linux: Change User Password

How do I change password under Redhat Enterprise Linux?
[click to continue…]

UNIX Create User Account

How do I create a user account under UNIX operating system and assign a password to user account so that he / she can login into server or UNIX workstation?
Answer to “UNIX Create User Account”

Linux Change Default User Home Directory While Adding A New User

By default base directory for the system user is set to /home directory. I’d like to add user to /iscsi/home/${user} directory instead of the default /home. How do I force useradd command to add user to /iscsi/home under CentOS / RHEL / Fedora Linux server?
[click to continue…]

Solaris UNIX: Change Default Shell

How do I change default ksh shell to bash shell under Solaris / OpenSolaris UNIX operating system using command line options?
[click to continue…]

Linux: Resetting a user’s password

Q. How do I reset a user’s password under any Linux distribution from command prompt?

A. To reset a user’s password, use passwd command. You have to change it to a different password.

Login as the root user

Open terminal or shell prompt

Type the following command:
# passwd username
For example, reset a tom’s password, enter:
# passwd tom
Type a new password twice.

Linux Create User Account

Q. How do I create create a new Linux user account ? How do update or modify default Linux new user information? Using the command prompt (shell) tools, how do I add a user to the system? What are command line options for adding a user?
[click to continue…]

Linux deny or block user login

Q. How do I deny or block user login for user id tom? I’m using CentOS 5 Linux server OS.

A.. You need to use passwd command.

Deny user login by locking out account

Pass -l option to passwd command. It is used to lock the specified account and it is available to root only. The locking is performed by rendering the encrypted password into an invalid string and by prefixing the encrypted string with an !.


passwd -l {username}

Unlock account or allow login

To allow login use passwd command as follows:
passwd -u {username}

This is the reverse of the -l option – it will unlock the account password by removing the ! prefix.

/sbin/nologin shell

/sbin/nologin displays a message that an account is not available and exits non-zero. It is intended as a replacement shell field for accounts that have been disabled or login is blocked.

Example: Deny login for tom user

Type the command as follows (login as root user):
# passwd -l tom
You can also change shell to /sbin/nologin:
# usermod -s /sbin/nologin tom

Example: Allog login for tom user

Type the command as follows (login as root user):
# passwd -u tom
You can also need change back shell from /sbin/nologin to /bin/bash:
# usermod -s /bin/bash tom

For more information and other options read passwd command man page.

Freebsd changing password

Q. How do I change a password under FreeBSD or Linux (UNIX) operating systems?

A. The FreeBSD passwd utility changes the user’s local, Kerberos, or NIS password. If the user is not the super-user, passwd first prompts for the current password and will not continue unless the correct password is entered.

Choosing a good password

It is a good idea to change password once a month or week. Make sure you change the password when admin gives you first time account information including a password to log on.

  1. The new password should be at least six characters long and not purely alphabetic.
  2. Its total length must be less 128 characters.
  3. The new password should contain a mixture of upper and lower case characters
  4. In all other situations, numbers, upper case letters and meta characters are encouraged.
  5. It should not be similar to the login id
  6. Please note that all UNIX / BSD / Linux password are case sensitive

Changing your own password

Just type passwd and hit [Enter] key:
$ passwd
So before the password can be changed, the current password must be supplied. When entering the new password, the characters entered do not echo, in order to avoid the password being seen by a passer-by. The passwd utility prompts for the new password twice in order to detect typing errors.

Changing other users password

You must login as the root user. To change password for user tom, enter:
# passwd tom

A note about passwd command

passwd command works with all UNIX, Linux, BSD and UNIX like oses. For more information read passwd man page:
man passwd

Linux Set or Change User Password

How do I set or change Linux system password for any user account?
[click to continue…]

Linux reset forgotten root password

Q. I forgot my root password, how can I get into my system?

A. You can reset forgotten root password under Linux by booting system into single user mode or emergency mode (also known as rescue mode).

My boot loader is GRUB (see LILO boot loader below)

)Following is the procedure to reset root password if you are using GRUB as a boot loader:

  1. Select the kernel
  2. Press the e key to edit the entry
  3. Select second line (the line starting with the word kernel)
  4. Press the e key to edit kernel entry so that you can append single user mode
  5. Append the letter S (or word Single) to the end of the (kernel) line
  6. Press ENTER key
  7. Now press the b key to boot the Linux kernel into single user mode
  8. At prompt type passwd command to reset password:

You need to mount at least / and other partitions:
# mount -t proc proc /proc
# mount -o remount,rw /

Change the root password, enter:
# passwd
Finally reboot system:
# sync
# reboot

My boot loader is LILO

At LILO boot loader type linux single and press [ENTER] key:
Boot: linux single
When you get the # prompt you will need to type passwd root to reset password:
# passwd
Reboot system:
# sync
# reboot

See also: