A2oz

How Do I Add a Password to a User in Linux?

Published in Linux User Management 1 min read

You can add a password to a user in Linux using the passwd command.

Here's how:

  1. Open a terminal: You can do this by pressing Ctrl + Alt + T or searching for "Terminal" in your applications menu.
  2. Run the passwd command: Type the following command and press Enter:
    sudo passwd username

    Replace "username" with the actual username of the user you want to add a password to.

  3. Enter the new password: You will be prompted to enter the new password twice for confirmation.
  4. Confirm the password: Enter the new password again when prompted.

Example:

To add a password to the user "john", you would run the following command:

sudo passwd john

Note: You need to have root privileges to use the passwd command. If you are not logged in as root, you will need to use the sudo command to gain root privileges.

Related Articles