• 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

Linux: Set user password by using encrypted password in command

January 4, 2014 by Sharad Chhetri Leave a Comment

In this tutorial we will learn about how to set user password by using encrypted password in command line.We assume you already know about how to simply set/reset password of user by using command (passwd username). In this tutorial,first we will encrypt the password in python interpreter then we use the output in one liner command.
You can use this method in scripts and as per scenarios.

Set user password by using encrypted password in command,follow the given below steps

Step 1: Login with root or become a super user

sudo su -

Step 2: Create a user.If you already have user then skip this step

useradd user-name

Example

useradd sharad

Step 3: Now we will get encrypted password by using python interpreter

=> Run the command python and you will get python interpreter

=> Now type below given line and replace give-your-password with your new password

import crypt; print crypt.crypt("","")

After this you will get the output. Copy the output and save it in some file.

=> To exit from python interpreter ,press CTRL+D to exit

Encrypted password

Step 4: Now paste the output in below given command

usermod -p "Encrypted-Password-OUTPUT" user-name

Example.

usermod -p "

set encrypted password

Now try login with username whose password you have changed.

Share this:

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

Related posts:

  1. How to show user account password expiration detail on Linux
  2. Force linux user to change password upon login
  3. How to delete password of user in Linux
  4. Set and reset user password by bash script
  5. How to set user postgres password in postgresql 9.1
  6. postgres database backup script using database user password inside
  7. Password prompt in single user mode is not secure : CentOS/Red Hat
  8. ghost blog reset password and activate user from sqlite
  9. How to increase Password Expire date without resetting the password
  10. How to lock and unlock user account in linux

Filed Under: Linux, Linux Commands Tagged With: encrypted passwd, linux command

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

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

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

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

master admin password openerp 7.x

Change default editor of crontab in Ubuntu

Forgot root password ,Reset it in Run level 1

Print double hyphen sign simultaneously in post of Octopress

How to set JAVA environment variables in Linux

Install and optimize the png file by using optipng

Keep logs of user after sudo su – : Secondary Logging

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

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