How to change all /bin/bash at /etc/passwd to /sbin/nologin?

up at 3.am up at 3.am
Mon Oct 9 13:23:15 PDT 2006


I would not recommend using vipw or sed to change your users' shells.

I'd just create a file of users:

cat /etc/passwd | cut -f1 -d":" > userlist

(Edit out any users you don't want to include):

then a scipt using pw to change their shells

#!/bin/sh

user=`awk '{print $1}' ./userlist`
for user in $user
  do
    pw usermod $user -s /sbin/nologin
  done

James Smallacombe		      PlantageNet, Inc. CEO and Janitor
up at 3.am							    http://3.am
=========================================================================




More information about the freebsd-questions mailing list