You need to be more specific. You said a few contradictory things like "using Ubuntu to develop software" and "not distributing any part of Ubuntu".
I believe what you're asking is; can I create a program while using the ubuntu operating system as opposed to windows then distribute and sell it while keeping it closed source. If that's what you're asking than the answer is yes.
There is not now nor has there ever been a restriction on that. You can find literally thousands of different programs that were developed on Linux and written for a Linux flavor that are not free.
It may not be well received by the overall community as it goes against the entire point.
You may find that releasing your program for free with the option of donations may prove more lucrative.
Please note I'm in no way attempting to dissuade you from developing, maintaining, and selling closed source software. Simply giving advice that was given to me many years ago and paid off.
I have created non-feee closed source products and sold them successfully. I've also done what I've said above both worked out.
I will ask you this though. Could you perhaps be a bit more specific as to what you're trying to do? You don't have to tell me what you're trying to create I just need you to clarify what I mentioned above.
If you use any source code from someone else's project that doesn't explicitly state that you can use it for non-free closed source projects then you can't.
The licenses are annoying I know. Lgpl is sketchy so you have to find the terms and really look into it gpl requires open source.
The mit license has no restrictions so you can use anything under an mit license.
There are other licenses but these are the most common.