The theory of large deviations has been applied successfully in the last 30 years or so to study the properties of equilibrium systems and to put the foundations of equilibrium statistical mechanics on a clearer and more rigorous footing. A similar approach has been followed more recently for nonequilibrium systems, especially in the context of interacting particle systems. We review here the basis of this approach, emphasizing the similarities and differences that exist between the application of large deviation theory for studying equilibrium systems on the one hand and nonequilibrium systems on the other. Of particular importance are the notions of macroscopic, hydrodynamic, and long-time limits, which are analogues of the equilibrium thermodynamic limit, and the notion of statistical ensembles which can be generalized to nonequilibrium systems. For the purpose of illustrating our discussion, we focus on applications to Markov processes, in particular to simple random walks.