title: How to write a shell script creating users and generating random password for them
body: <p>I am trying to create 3 users with random password each. I am new to shell scripting and nt sure if I have written the best script to achieve this. Kindly help me check. Thank you</p>
  <pre><code>#!/bin/bash
    
  function create_user() {
      user_name=$1
      password=$(pwgen 5 1)
  
      sudo apt install pwgen
      sudo useradd $user_name
      sudo pwgen 5 1
      sudo chmod u+x homework.sh
      sudo grep -i $user_name /etc/passwd
  
      echo &quot;User $user_name created with password $password&quot;
  
  }
  
  create_user adam
  create_user bety
  create_user carl
  </code></pre>