Selling ships don't usually give much credits due to taxes. Black market is where it is at, but it will make patrols wary of you and give cause to penalize your rep with the faction. D-mods also lower its value.
You can make profit if you can sneak into black markets to buy low and sell high.
The main source of money comes from missions and bounties (system bounty, commission pay, or target bounties).
Trade missions often require buying the stuff before turning them in, while contract bounties you find in bars require that you need enough room to carry them.
Exploration missions require you knowing how to plan and efficiently use fuel and supplies to accept multiple missions in a single route and clear them all for big money. Normally for more navigation-based players because you can bump into something nasty and get caught like a deer in headlights.
Bounties if you want the action and skill, loot their supplies and fuel, and all that fun stuff. Good if you don't care about the outlaws. That being said, those pirate fleets can be nasty, especially when you decide to do in the middle of a pirate raid where you'll meet large armadas and hope you have a faction patrol fleet to at least assist in their efforts.
There is also founding your own colony, but that presents a challenge in of itself, because that is a kind of topic that requires a more thorough discussion. In other words, a can of worms.