• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Set and reset user password by bash script

June 8, 2011 by Sharad Chhetri Leave a Comment

In this post learn how to set and reset user password by bash script on Linux systems. It is quite good for Linux System Admin who wants to know how to set and reset user account password with bash script. We have used the standard input (stdin) with passwd command.

Advantage:
1. Get the list of users and reset/set their password at one time without password prompt. You do not have to type the passwd command over and over in system.
2. By doing some more trick, you can randomly generate the password, set the password to user and send email at last with their credentials details.

Example 1: In this eg. we will create new user and set the passwd.
UserName : test
Passwd : test123

#!/bin/bash
useradd test;echo test123|passwd test --stdin

Example 2: In this example we will reset the passwd.

Username: linuxtribe
Passwd : sort_1t_out

#!/bin/bash
echo sort_1t_out|passwd linuxtribe --stdin

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. ghost blog reset password and activate user from sqlite
  2. postgres database backup script using database user password inside
  3. Linux: Set user password by using encrypted password in command
  4. Forgot root password ,Reset it in Run level 1
  5. CentOS 7 / RHEL 7 : Reset / Recover forgotten root password
  6. bash scripting : Prompt user yes / no for confirmation
  7. How to Use Expect In Bash Script
  8. How To Use case in Bash Script, Example
  9. How To Use opt In Bash Script
  10. send email after mysql backup through bash script in simple way

Filed Under: Linux Tagged With: bash script

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

Find exit status code of last executed command on Linux and Unix

How To Get SSH Public Key Fingerprint Information

What is Linux/Unix Internal And External Command

Linux command to find modified and access date of file/dir/filesystem

How to set motd in linux

Install libjpegtran by using yum command in CentOS 6.x

sed command to display text between two strings or keywords

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

Allow wget and yum in iptable

How to install pam_mysql in CentOS or Red Hat

Replace keyword with its filename without extension : bash script

error command ‘gcc’ failed with exit status 1 in Ubuntu

Convert hyphen to underscore in between all filenames shell script

Could not find make anywhere!!! Please edit the config section to include the path to make. at ./install.pl line 2101

Convert video file into gif file through command line in linux

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy