A shared playground on Ubuntu

Saturday February 15, 2014

After setting up a machine, I'd like to set up a bunch of users who can log in and give them a common space in which to do some work. The goal is convenience for demonstration and education.

Assume usernames are in a file called names.txt, one per line. This will create users with those names, put them in the users group, and make their passwords "none". As root:

cat names.txt | while read line
 do
  adduser --gecos "" --disabled-password $line
  adduser $line users
  echo $line:none | chpasswd
 done

Now those users should really log in and change their passwords with passwd. Up next, we make a shared directory that everybody has access to.

mkdir /home/shared
chgrp users /home/shared
chmod g+w /home/shared
chmod g+s /home/shared

That makes the directory, sets the group to users, gives group members write access, and sets the "sticky" bit so that files created in the directory will have the users group.

This post was originally hosted elsewhere.