It can be done on foot with a map in hand. But only if you have comfortable shoes on your feet, you are in good shape and you don't have children with you. Otherwise, climbing up and down the mountains will quickly put an end to the desire to see as much as possible.
Bus tour of San Francisco is much more comfortable and costs from 20 USD. The price of the ticket depends on the chosen route and the length of stay in the city. You can buy a tour for several days. Using a tour bus is allowed not only to explore the city, but also to get to the desired place.