Granular materials, like sand, powder or grains present intriguing phenomena. Vibration and shearing can lead to convective motion and segregation. A variation of stress may cause localization phenomena like stress chains or shear bands. Granular systems are thus in a state far from thermodynamic equilibrium, however, we present an attempt for a thermodynamic description by extending the concept of compactivity. In vibrating containers under the influence of gravity, the granular material shows a peculiar density profile. In the weak dissipation / strong agitation limit the density decays exponentially with height, whereas one observes an almost uniform profile in the case of strong dissipation / weak agitation. In the latter regime, the formation of convection cells due to walls or amplitude modulations can be observed. The onset of fluidization can be determined and is in good agreement with experiments. Connected to convection is the effect of rapid segregation, however, comparatively slow segregation can also be observed in the absence of convection. Numerical simulations of flow in hoppers show that the density fluctuations have a power spectrum, allowing for large “events” with finite probability. There is also ample experimental and numerical evidence showing the existence of spontaneous density patterns in granular material flowing through pipes or hoppers. Due to fluctuations of the wall friction, shock waves are created and arches are formed, slowing down the material which follows. In regions of anisotropic stress, the rotational degree of freedom is frustrated parallel to strong stresses, so that ordering akin to anti-ferromagnetic spin coupling may be observed. Pouring two different materials on a flat surface leads to a sandpile with stratification patterns. The mechanisms leading to this segregation of the two types are examined with experiments and numerical simulations. The stress distribution inside a sandpile depends strongly on the contact network. A relatively small polydispersity causes a reorganization of the contact network and leads to the so called stress chains, i.e. the stress at neighboring particles may vary dramatically. Finally, the plastic shear bands occuring in large scale deformations of compactified granular media are investigated by using an explicit Lagrangian technique as well as molecular dynamics simulations with non-spherical particles.