os/linux/ BasicCliUserManagement


See usermod manpage and useradd manpage This is pretty much all I use.

adduser terry # has a simple question and answer interface, slightly higher level than useradd
usermod -a -G www-data,mr,flibble,turnips terry # add terry to the groups www-data, mr, flibble and turnips (note commas and no spaces)

The useradd command is slightly more low level than adduser.

# -m causes creation of home folder, using /etc/skel
# -G www-data means angel is in the group www-data in addition to the angel group
sudo useradd -m -G www-data angel ; sudo passwd angel

The /etc/skel is the default location for the skeleton. Stuff in here is copied to a new users home folder. I often use multiple user accounts to separate concerns (e.g. one user per project). This means I get a separate set of tmux sessions for each user, and can use a combination of tmux sessions and windows to divide up terminal tasks. (I have a lot of editors and other things running, and like tmux since it isn't tied to a particular desktop login.)

Passwords

You can change passwords with

passwd       # change for current user
passwd bob   # change bob's password (must be root)

for batch changing, there are chpasswd and chgpasswd. For example

sudo chpasswd <<END
percy:percyslunch123
angel:angelspoon123
END

though do be careful with this one.