Question d’entretien chez Zeta

How does 'ls' command works in OS level? How does ping know the server is present or not before sending the packet?