There can be no general answer to your question, you either do this by creating your own software license (which cannot be free, as in the definition of free software , because you restrict commercial use), or you can try to achieve something similar with dual licensing as follows:
Public and freely available software is available under a strong copyleft free software license, such as the GNU Affero General Public License (AGPL) . Any entity using the software must publish the source and change all its users under one license (reverse, ASP loophole closed).
You can even make the software virtually incompatible with mainly any open source software by choosing the Open Software License (OSL) . This is incompatible in this sense with most of the existing open source software (the GPL, which includes the largest share of open source, but also many others) and has a strong copyleft due to its use (it even works), so itβs pretty limits.
In fact, you will signal: do not use the free version - a somewhat morally questionable move.
How (and if) it is not suitable for the type of commercial use you are asking for, then you can offer a second license for commercial use. If someone complains, you can just tell them hey, this is free software. Bad move, but probably working. Ask your lawyer for details, this option may not be what you are looking for, you will not become a member of free software.
Instead, you need to figure out what you really want to do. Limit commercial use or not. After you have done this, talk with a lawyer to create the right software license for your work.
hakre source share