(Fortune) -- Facebook founder Mark Zuckerberg is known as a precocious visionary, but as a college-age CEO he was as rebellious and irreverent as the next kid. In his forthcoming book The Facebook Effect: the Inside Story of the Company That Is Connecting the World, author David Kirkpatrick gives an unprecedented look at the rambunctious nerds who created a multibillion-dollar media giant. An adapted excerpt is below.
In the first week of his sophomore year at Harvard, Mark Zuckerberg cobbled together an internet software program he called Course Match. The idea was to help students pick classes based on who else was taking them. If a cute girl sat next to you in Topology, you could look up next semester's Differential Geometry course to see if she had enrolled in that as well. Hundreds of students immediately started using it.
His next project, in October, he called Facemash. Its purpose: figure out who was the hottest person on campus. He invited users to compare two different faces of the same sex and say which one was hotter. A journal he kept at the time, which for some reason he posted along with the software, suggests Zuckerberg got into this jag while upset about a girl. "______ is a bitch. I need to think of something to take my mind off her," he wrote, adding, "I'm a little intoxicated, not gonna lie." By the time the program launched, he had dropped the idea of also comparing students to farm animals. "Another Beck's is in order," Zuckerberg wrote as he continued his Facemash chronicles. By the time he returned to his room from a meeting the next day, his laptop was so bogged down with Facemash users that it was freezing up.
When he launched Facebook the following February (initially called thefacebook.com), it was a rudimentary site, but flirting on Facebook quickly became a sort of art form. One feature -- the poke -- made doing so absurdly easy. Poking was a particular fascination in those days, even among the supposedly sophisticated students of Harvard. What did a poke mean? Its indeterminate message was one of its appeals. Zuckerberg posted an insouciant answer on the site: "We thought it would be fun to make a feature that has no specific purpose... So mess around with it, because you're not getting an explanation from us."
At the end of the school year, Zuckerberg and his cohort moved their fledgling operation to a four-bedroom sublet house in Palo Alto, Calif., which became a combination home and office. Zuckerberg slept later than most -- he seldom got to work in the equipment-jammed dining room before afternoon. His typical garb in the office was pajama bottoms and a T-shirt. When the software code-writing got intense, he was a taskmaster. If someone got hungry and wanted to go out for fast food, recalls a frequent visitor, "Mark would, like, pound the table and just say, 'No! We're in lockdown! No one leaves the table until we're done with this thing." Zuckerberg was determined to keep this ship moving forward, and he was more than happy to be the captain.
Not infrequently, he acted like he was captain of a pirate ship. Among the few possessions he had brought to Silicon Valley with him were his fencing paraphernalia, which he left lying in a pile. Often he'd grab his foil and start swinging it through the air. "Okay, we've got to talk about this," he would declare, one hand held behind his back, lunging forward with this foil. Often the sword would get uncomfortably close to people's faces. "I'm the personality type where that would get me sometimes," says co-founder Dustin Moskovitz. "It was a pretty small room." Later Moskovitz and the others banned fencing from the house.
The house at 819 La Jennifer Way, with a resident population of seven guys, felt like a dorm. Some people -- female and male -- stopped by for days and just hung around. Stanford University was only a mile away, so the housemates would announce parties using a Facebook feature that enabled them to target specific schools. They were mobbed by Stanford students and townies. Hanging out by the pool was a major activity, and broken glass would simply be swept into the water. One housemate strung a wire from the top of the chimney to a spot on a telephone pole beyond the pool. With a pulley, he turned it into a zip line, so partiers could ride down the wire and drop into the pool with a massive splash. (When the owners finally returned in the fall, they were shocked. In a later court case, the owners described the house as "in total disarray and very dirty.")
The house's cultural mascot was Tom Cruise, who had camp appeal because he was "not a very cool character," recalls a housemate. Pretty soon the resident nerds were naming their computer servers after characters in Tom Cruise movies: "'Where's that script running?' 'It's running on Maverick.' 'Well, run it instead on Iceman, I need Maverick to test this feature.'" Zuckerberg, who had loved studying the classics, had a way of punctuating a conversation by suddenly pronouncing, "Now you know who you're fighting!" It was a quote from one of his favorite movies, Troy, which he had seen on his 20th birthday.
Incongruous movie quotes gave Zuckerberg, who could otherwise lapse into long periods of silence, tremendous pleasure. He also inserted them in the site. Whenever you searched for something in those days there was a little box below the results that had tiny type that said, "I don't even know what a quail looks like." It's a throwaway line from The Wedding Crashers. Another quote that appeared there was a Tom Cruise line from Top Gun: "Too close for missiles. Switching to guns." The quotes came to encapsulate, in the fashion of schoolboy in-jokes, the spirit of the company -- playful, combative, and despite the technical sophistication, a bit juvenile. Students at colleges around the U.S. spent hours arguing about the significance of these inscrutable epigrams.
As the Facebook boys started dealing increasingly with real business professionals, a reputation for rambunctiousness spread throughout the valley. "It's Lord of the Flies over there," one executive told an executive recruiter. Zuckerberg had to be careful which business card he handed out at meetings. He had two sets. One simply identified him as "CEO." The other: "I'm CEO...bitch!"
One of the crew's edgiest pranks in those days was a presentation made to the blue-chip venture-capital firm Sequoia Capital, known in the Valley for a certain humorlessness. Sequoia éminence grise and consummate power player Michael Moritz had been on Plaxo's board. Sean Parker, one of Zuckerberg's first Silicon Valley advisers, had been been fired from Plaxo by its board, and he saw Moritz as having contributed to his downfall. "There was no way we were ever going to take money from Sequoia, given what they'd done to me," says Parker. The firm wanted to invest in Facebook, so as a joke the boys offered to pitch the partners a Zuckerberg side project called Wirehog, a peer-to-peer file-sharing program.
Zuckerberg and another partner showed up deliberately late for an 8 a.m. meeting, in their pajamas. They didn't even make a pitch for Wirehog. Zuckerberg showed a PowerPoint presentation David Letterman-style: "The Top Ten Reasons You Should Not Invest in Wirehog." It started out almost seriously. "The number 10 reason not to invest in Wirehog: we have no revenue." Number 9: "We will probably get sued by the music industry." By the final few points it was unashamedly rude. Number 3: "We showed up at your office late in our pajamas." Number 2: "Because Sean Parker is involved." And the number one reason Sequoia should not invest in Wirehog: "We're only here because [a Sequoia partner] told us to come." The partners seemed to listen respectfully, recalls Zuckerberg, who says he now regrets the incident. "I assume we really offended them and now I feel really bad about that."
Facebook's final fling of sophomoric adventures came in late 2006, when the company was starting to get billion-dollar takeover offers from major corporations. For its holiday party that December, the entire company, now about 150 people, took buses to the Great America Theme Park in nearby Santa Clara. From the minute people got on the buses they started drinking. By the time they arrived at the park many were already drunk. Facebook's employees celebrated a successful year on the park's thrill rides that spun, dropped, twisted and inverted them. On the way home an employee threw up in an air vent of one of the buses. The company had to pay several thousand dollars to repair the damage.