should i publish this book for free or ask for a little fee?
You can find my books for free if you do a bit of digging or ask me. Otherwise just publish a large percentage of the book as free, and sell full copies.
And don't believe that people who have a free copy will never buy a formal edition. Two books I have right here on my shelf in physical form, which I also downloaded free versions of are Steven Smith's Guide to Signal Processing for Scientists and Engineers - awesome beginners DSP text I still recommend to first year students, and Ross Anderson's Security Engineering, most of which is downloadable from his website.
I do a mix of both. Whenever I publish a new book, I give them away for free for a week or two, but I still get paid sales as well. Recently I started adding discounted prices for my earlier books along with new releases, so that's another option if you plan to write more books.
Some businesses are one step, others two step, or many steps.
Two (or more) steps, mean, that business strategy based on assumption, that very large share of clients (95% or more), will after 1st transaction return and buy something other, so first transaction could been subsided by second or by third, etc.
Even more - in multistep businesses, on first transaction, business could pay client money for taking product or for using service, planning that on next step(s), client will return all money.
Most known example, jet printers, which sold unprofitable, but profits on ink sale returns all investments.
Similar business where Kodak (sell cheap cameras, profits on film and on services); Xerox (give copy machines basically for free, collect payments on each copy).
I have been disappointed too many times buying a fully locked down book to discover it's not as useful as thought.
Obviously there are some well known/recommended books that overcome this, but it's chicken and egg for a new book.