How Do I Give a User a Password in Linux?
Contents

What is the command to give a user a password in Linux?

Both Linux and UNIX-like operating systems use the passwd command to change user password.
…
To change a password on behalf of a user:

  1. First sign on or “su” or “sudo” to the “root” account on Linux, run: sudo -i.
  2. Then type, passwd tom to change a password for tom user.
  3. The system will prompt you to enter a password twice.

How do I lock a user in Linux?

UNIX / Linux : How to lock or disable an user account

  1. Lock the password. To lock a users account use the command usermod -L or passwd -l. …
  2. Expire the user account. The commands passwd -l and usermod -L are ineffcient when it comes to disable/lock user accounts. …
  3. Changing the shell.
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest