Cephalexin is used to prevent or treat infection. It is a first - generation cephalosporin antibiotic and can be used after surgical procedures such as a hair transplant. It works by interfering with bacteria's cell wall formation. You should not take cephalexin if you are allergic to cefaclor (Ceclor), cefadroxil (Duricef), cefdinir (Omnicef), cefditoren (Spectracef), cefixime (Suprax), cefprozil (Cefzil), ceftazidime (Fortaz) or cefuroxime (Ceftin). You should notify your doctor if you have kidney disease, liver disease, a stomach or intestinal disorder such as colitis, diabetes; or if you are malnourished.