do all plants are leguminous and if they are not then how do they obtain nitrogen?
No, all plants are not leguminous. Those plants which are non-leguminous take nitrogen from the soil as soil can be naturally enriched of nitrogen by dead and decaying matter or it can be also manually enriched by adding fertilizers.