Every year, millions of commencement speeches are given. While some are quickly forgotten, others contain pearls of wisdom that students remember throughout their lives.

It’s tough to nail down the qualities that make a graduation speech memorable; each is great in its own unique way. But in many, the speaker makes the story both personal and relevant to the students—and the times they live in. Here are just a few memorable moments from recent commencement speeches.

Randy Pausch: "Be good at something. It makes you valuable."

Every year at graduation, Carnegie Mellon asks a professor to give a “Last Lecture.” The concept is: if you could only give one more lecture in your life, what would you talk about? Randy Pausch was asked to give it in 2007—and recently afterward, he found out he had advanced pancreatic cancer and only months to live. In his speech, he encouraged students to follow their dreams with practical, funny advice and anecdotes from his life.

P.J. O’Rourke: "Don’t be an idealist; make money; stay away from politics; the world isn’t fair."

P.J. O’Rourke is a satire writer who originally published this speech in Change Magazine’s May/June 2008 issue. The piece gives advice that’s anything from warm and fuzzy; he breaks down old graduation-speech clichés by encouraging students to ignore the traditional advice to “do what you love” and “try to change the world.” Instead, he suggested students become successful and wealthy—giving them a better platform from which to effect change and pursue their dreams.

John McCain: "the passive life is not worth forgoing the deep satisfaction, the self -respect, that comes from employing all the blessings God bestowed on you to leave the world better for your presence in it."

John McCain gave the commencement speech at the University of Pennsylvania’s graduating class of 2001. In his speech, he told graduates that all of them would eventually face a choice between passively reaping the benefits of living in America and working to contribute meaningfully to its advancement. He encouraged students to use their good fortune to make a difference in the lives of others and in their country.

Will Ferrell: "You're about to enter into a world filled with hypocrisy and doublespeak, a world in which your limo to the airport is often a half-hour late."

No article on graduation speeches would be complete without Will Ferrell’s infamous speech to the Harvard Class of 2003. The speech was satirical and quickly became famous on YouTube; but although it was funny, it contained a gem of wisdom: the world will not be as kind as you think. Don’t expect to be coddled. Don’t expect things to turn out the way you think they will.

J.K. Rowling: "We do not need magic to transform the world. We carry all the power we need inside ourselves already. We have power to imagine better."

J.K. Rowling, author of the enormously successful Harry Potter series, was asked to give the commencement speech to Harvard’s graduating class of 2008. Rowling emphasized that students should not be afraid of failure in life—something that as Harvard graduates, the students may not be familiar with—and that as humans, our imaginations are our greatest gifts.

Rick Wagoner: "Don’t over-plan your life."

Rick Wagoner, the CEO of GM, gave the graduation speech at Duke in 2007. In his speech, he encouraged students not to plan their lives too rigidly, emphasizing that students are most likely to find meaning, fulfillment and a sense of purpose when unexpected failures and opportunities present themselves.

Barack Obama: "You will be tested. You won't always succeed. But know that you have it within your power to try."

Barack Obama gave the commencement speech at Knox College in 2005. His speech drew on the history of the American people to bring about positive change to illustrate that each individual graduate could make change as well. He also encouraged students not to spend their talents not simply in enriching themselves, but also to bring positive change to the country.

David Foster Wallace: “The really important kind of freedom involves…being able truly to care about other people and to sacrifice for them over and over in myriad petty, unsexy ways every day."

David Foster Wallace gave a commencement speech at Kenyon University in 2005. His funny, slightly sarcastic speech encouraged students not to get lost in the mindless, mundane routines of adult life and to remain aware, compassionate, and socially conscious. He stressed that true freedom is the freedom to love others and love the world every minute of every day, and to make choices that contribute to the world and to others in a positive way.