Can you change shell for multiple users?

QuestionsQuestions8 SkillsProDec, 23 2025
0100

Yes, you can! While the usermod command itself usually handles one user at a time, there are a few ways to change the shell for multiple users efficiently:

1. Using a Loop (The Scripting Way)

If you have a list of users, you can use a simple for loop in your terminal. For example, to change the shell to bash for users bob, joker, and alice:

for user in bob joker alice; do
    sudo usermod -s /bin/bash $user
done

2. Using chsh (Change Shell)

The chsh command is another way to change shells. To change it for others, you still need sudo. It works similarly to usermod:

sudo chsh -s /bin/bash username

3. Using chsh with multiple users (Advanced)

Some administrators use the chpasswd or newusers tools for bulk updates, but usually, a loop is the safest and most common method for a small group of users.

You could technically edit the /etc/passwd file directly using sudo vipw. This opens the user database in a text editor where you could manually change /bin/sh to /bin/bash for many rows. However, this is risky because a typo can break your system's ability to log users in!

Summary: The loop method is the best way to handle multiple users quickly and safely. Do you have a specific list of users you are trying to update?

0 Comments

no data
Be the first to share your comment!