If you don’t know the names of your Civil War ancestors, start by examining your family tree. Look for males with a year of birth between 1818-47. This would be the expected dates for those the right age to serve. Top officers with years of military experience were older than the average recruit. For example, Robert E. Lee born 1807.
Keep in mind that some youngsters may have enlisted while underage, perhaps attracted by the adventure of being a soldier. Likewise, someone over the maximum age of 45 could lie about their age to enlist. Apparently no one checked their age.
One sees very young boys serving as drummer boys with units or even as a powder monkey with the Federal Navy. Boys as young as 11, 12 and 13 are known to have served as drummer boys. These boys would have birth dates in the 1850s.
Search the names from your tree in the Civil War Soldiers and Sailors System maintained by the National Park Service. It helps to put in the name of the state where your ancestor lived in the early 1860s.
Lately there’s been research about women who disguised themselves as men to serve in the Civil War armies. I’ve seen an estimate of around 400 who chose this unusual way to serve their country or to remain with their spouse. Since this is a fairly small number and they usually assumed a masculine name, it will be quite difficult to track this. Here’s an article that names some of the better-known women who served as Civil War soldiers.