• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Commands

Setting Passwords for User Accounts in Linux

June 21, 2024
in Commands, Linux, Linux Command Tutorial, Linux Commands
A A
0
11
SHARES
100
VIEWS
Share on FacebookShare on Twitter

The useradd command in Linux is used to create new user accounts. One of the important options available for this command is -p or --password PASSWORD, which allows setting passwords for the newly created user accounts.

Here are several examples of using useradd with the -p option:

Example 1: Create a new user john and set the password immediately.

$ sudo useradd -p 'password123' john
        

This command creates a user account named john with the password set to password123.

To verify if the user was successfully created, you can use:

$ grep john /etc/passwd
        

If john is listed in the output, the user account was created.

Example 2: Create a user alice and set her password using an encrypted password string.

$ sudo useradd -p '$6$3.4Fajk$Gy5dZf4Bkp1l1puM4vWb2LWf1xCM72BY1.sE6D0B/7OIGTb9NArS.eUvw0B2m3.u6Onz5sBwFtD/ghJvDAg9u/' alice
        

In this command, the password is set using an encrypted password string, ensuring stronger security.

Example 3: Create a user smith and set the password using an MD5 hash.

$ sudo useradd -p '$1$av7iwD7b$Asnkj234.DXG0RlsN8h7Y1' smith
        

This command demonstrates setting a password using an MD5 hash for the user smith.

Example 4: Set password for an existing user jane using the passwd command after creation.

$ sudo useradd jane
$ sudo passwd jane
        

This sequence first creates the user jane and then prompts to set a password interactively.

Example 5: Create a user guest and set an empty password.

$ sudo useradd -p '' guest
        

Setting an empty password can be useful in some scenarios but is generally discouraged for security reasons.

These examples illustrate different ways to use the useradd command with the -p option to set passwords for user accounts in Linux. Each method offers flexibility depending on the security requirements and administrative needs of the system.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Allowing Non-Unique User IDs with Useradd Command

Next Post

Creating System Accounts with Useradd Command

Related You may like!

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024

Find Files by Group Name with -group in find Command

August 21, 2024

Locate Files by Group ID Using -gid in find Command

August 21, 2024

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Use -false to Test Conditional Expressions in find Command

August 21, 2024
Next Post
howto

Creating System Accounts with Useradd Command

howto

Using Chroot Directories with Useradd Command

howto

Setting Prefix Directories for Useradd Command

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Dumping BLOBs in Hexadecimal Format with mysqldump

    16 shares
    Share 6 Tweet 4
  • Using BTRFS Subvolume for User Home Directory in Linux

    24 shares
    Share 10 Tweet 6
  • Suppressing CREATE DATABASE Statements in mysqldump

    11 shares
    Share 4 Tweet 3
  • Managing Kubernetes Certificates with kubectl certificate

    20 shares
    Share 8 Tweet 5
  • How to Create and Run a New Container in Kubernetes?

    11 shares
    Share 4 Tweet 3
  • Initializing and Reinitializing Git Repositories

    13 shares
    Share 5 Tweet 3
  • Searching Git Repositories with Grep

    12 shares
    Share 5 Tweet 3
  • Running Docker Images on Kubernetes with kubectl run

    13 shares
    Share 5 Tweet 3
  • Disabling Keys in mysqldump Output

    12 shares
    Share 5 Tweet 3
  • Managing Docker Image Manifests and Lists

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.