You only say it when you are familiar with the person. You use it as a form of hello but you just don't say it to anyone. You say it to people who are the same age as you. However, you don't say it...
The salute is the greeting among the military. The junior rank/enlisted is required to render the salute first and hold it until the officer drops his salute. Cadets have not taken the oath of office...