I went to school for 7 straight years and completed a Ph.D. I took out a total of $8,000 in loans, all for my undergraduate. They were paid off within just a few years of finishing my Ph.D.
I had scholarship money that covered a lot of my undergrad expenses, and I also worked on campus. I only needed loans for 2 of my 3 undergraduate years - my RA job the last year covered all of my room/board costs and the stipend covered the rest of my tuition.
For grad school, I was loaned the money by a family member to purchase a used mobile home. I lived there for about $300 a month, including lot rent and all utilities. My graduate assistantship paid about $700 a month and covered my tuition and fees. When I was done, I sold the mobile home and repaid the loan immediately.
Not everyone can find themselves scholarships, jobs, and asssitantships that will cover so many of their costs. But there are ways of reducing the amount of loans you need to take out.