Candida albicansis a benign member of gut microbiota, but also causes life-threatening disseminated infections, suggesting that this fungus commensalism has evolved with retention of virulence traits. Here we reveal that N-acetylglucosamine (GlcNAc) enablesC. albicansto balance between commensalism and pathogenesis. Although GlcNAc catabolism is beneficial for commensal growth ofC. albicans, deleting GlcNAc sensor-transducer Ngs1 confers enhanced fitness, indicating that GlcNAc signaling is detrimental to commensalism. Interestingly, addition of GlcNAc attenuates commensal fitness of gut-evolvedC. albicansbut retains its disease-causing potential. We further demonstrate that GlcNAc is a major inducer of hypha-associated transcription in the gut, which represents the key determinant for commensal-pathogenic equilibrium. In addition to yeast-to-hypha morphogenesis, we also identify other factors, including Sod5 and Ofi1, that contribute to the balance. Thus,C. albicansuses GlcNAc to build up a tradeoff between fungal programs supporting commensalism and virulence, which may explain its success as a commensal and pathogen.