How to set up up group specific writeable folders

Hey all,

We have an idea for a data science application where jupyterhub is central.

The core idea is for users to create projects on our application and work in teams, each project will have a shared folder in jupyterhub. Each project folder should only be accessible/visible to its team members, and each team member can edit files in that folder.

I’m new to JupyterHub but I’ve figured out how to create folders, create ‘groups’, and add users to the group through TLJH API, however, I’m struggling to envisage how to create group-specific folders which are writable to all members.

If anyone has any ideas on how to set this up, I’d love to hear it.

Thanks in advance

1 Like

If you’re using TLJH your Jupyter users are also users on the operating system. You can therefore use standard Linux users, groups and permissions to create directories that are readable/writeable by one group.


Love the simplicity, thank you!

If you have not already found it, take a look at The littlest Jupyter Hub Group Utilities for one implementation.

1 Like

When it rains it pours, I’ve almost finished a script that creates user accounts and groups before allocating relevant permissions. The shell scripts you linked are still useful.

Feel free to point me towards any other useful repositories.

Let me know if you’d prefer I make a new post for this question.

I took the advice given by @manics - using standard linux commands to create groups and permissions. I made a shell script to handle this.

I then added the ability to create users to this shell script.

prefix = "jupyter"
        for user in user_dict:
                    group_list = ','.join(user_dict[user])
                    print(f"Adding {user} who is part of groups {group_list}")
                    username = "-".join((prefix, user))
                    cmd = ["sudo", "useradd", username, "-G", group_list]
                    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                    output, error = p.communicate()
                    output = output.strip().decode("utf-8")
                    error = error.decode("utf-8")
                    if p.returncode != 0:
                        print(f"E: {error}")
                        print(F"{user} was added")

This works, I verified by checking that users were created and assigned to their respective groups.

#check users were created
jupyter-nason_admin@ip-172-xx-xx-xxx:~$ awk -F: '$6 ~ /\/home/ {print}' /etc/passwd

#check users were assigned to groups
jupyter-nason_admin@ip-172-xx-xx-xxx:~$ getent group

My issue is that I can’t log into the users I created in this mannor, I’m guessing its because jupyterhub isnt aware of the new users created on the system. Any ideas how I can rectify this?

JupyterHub has a REST API you could use to create users:

1 Like