For Obama, a steep learning curve as C-in-C

But as he grows in the job, Mr. Obama has shown more willingness to set aside Mr. Gates’s advice. When General McChrystal got in trouble in June for comments by him and his staff in Rolling Stone magazine, Mr. Gates favored reprimanding the commander. Mr. Obama decided instead to oust him and replace him with Gen. David H. Petraeus, who led the troop increase in Iraq.

“My first reaction was if McChrystal with his experience and his contacts and his knowledge were pulled out, that could have real consequence for the war,” Mr. Gates said. “It never even occurred to me — I kicked myself subsequently — to move Petraeus over there. When the president raised that with me in a private meeting, it was like a light bulb went on — yes, that will work.”…

But Mr. Obama also confronts the consequences of the direct combat he has ordered. Last year, he flew to Dover Air Force Base in Delaware to greet soldiers’ coffins. During a later meeting with advisers, Mr. Obama expressed irritation at doubters of his commitment. “If I didn’t think this was something worth doing,” he said, “one trip to Dover would be enough to cause me to bring every soldier home. O.K.?”

In March, during his only trip to Afghanistan in office, he met a wounded soldier, maybe 19, who had lost three limbs. “I go into a place like this, I go to Walter Reed — it’s just hard for me to think of anything to say,” an emotional Mr. Obama told advisers as he left.