This can be done by using -sV parameters

nmap -sV localhost