Question: I am using debian 10 and I want to create a user with no home directory. the user should only have access to the directories that his or her group owns. that is the user has only to his or her group directories.
This is my command information:

`useradd -g mygroup-G mygroup1,mygroup2 -s /bin/bash -M username`

However when I log into the system via putty and do ls command, I see the home folder and I can `cd` inside it.

I don't understand why this is possible because `-M` should have prevented the creation of the home folder.

Answer: 
1. There are tools to manipulate filesystems as you ask. One such is the [mtools](https://www.gnu.org/software/mtools/) package, which does FAT filesystems. Another is [e2tools](https://e2tools.github.io), which does EXT2 and EXT3 filesystems. Both of these are available in debian linux, and probably many others.
2. These tools will probably not deal with an image in a partition. This should not be a problem. Simply split your template into separate files for the partition table and partition contents (probably ahead of time), add your files into the filesystem images, and then `cat` the pieces together in the right order to produce the final disk image.
I use and recommend [`guestfish`](https://libguestfs.org/guestfish.1.html), which is a part of [libguestfs, library for accessing and modifying VM disk images](https://libguestfs.org/).

I've found OpenStack's documentation includes a useful description of tools that do not require privileges: [Modify images — Virtual Machine Image Guide documentation](https://docs.openstack.org/image-guide/modify-images.html)

Note that if you are making many disjoint changes you may benefit from running a `guestfish` daemon process and using its remote control mode - this saves on the (not insignificant) start-up time.

See [Remote control `guestfish` over a socket](https://libguestfs.org/guestfish.1.html#remote-control-guestfish-over-a-socket) of the `guestfish` manual.