cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

passwd command in suse linux

pnagar
Participant

Accepted Solutions (0)

Answers (1)

Answers (1)

nikhil_prabhu
Employee
Employee

Hi Prashant. You could write a simple BASH shell script to lock the passwords of multiple users. For example, create a new file called lock-users.sh, and add the following content:

#!/usr/bin/env bash

# Loop through usernames in file and lock them
while read user
do
    passwd -l "$user"
done < "user-list.txt"

exit 0

Save this file, and run chmod u+x lock-users.sh. Create a new text file called user-list.txt in the same directory as the shell script. In this file, enter the usernames that you want to lock line by line. For example:

user1
user2
user3

Now, run the script by typing sudo ./lock-users.sh. The users specified in the text file will be locked.