Cell envelope
The cell envelope is the cell membrane and cell wall plus an outer membrane, if one is present. Most bacterial cell envelopes fall into two major categories: Gram positive and Gram negative. These are differentiated by their Gram staining characteristics.
As in other organisms, the bacterial cell wall provides structural integrity to the cell. In prokaryotes, the primary function of the cell wall is to protect the cell from internal turgor pressure caused by the much higher concentrations of proteins and other molecules inside the cell compared to its external environment. The bacterial cell wall differs from that of all other organisms by the presence of peptidoglycan (poly-N-acetylglucosamine and N-acetylmuramic acid), which is located immediately outside of the cytoplasmic membrane. Peptidoglycan is responsible for the rigidity of the bacterial cell wall and for the determination of cell shape. It is relatively porous and is not considered to be a permiability barrier for small substrates. While all bacterial cell walls (with a few exceptions e.g. intracellular parasites such as Mycoplasma) contain peptidoglycan, not all cell walls have the same overall structures. This is notably expressed through the classification into Gram positive and Gram negative bacteria.
The Mycobacteria have a cell envelope which is not typical of Gram positives or Gram negatives. The mycobacterial cell envelope does not consist of the outer membrane characteristic of Gram negatives, but has a significant peptidoglycan-arabinogalactan-mycolic acid wall structure which provides an external permeability barrier. Therefore there is thought to be a distinct 'pseudoperiplasm' compartment between the cytoplasmic membrane and this outer barrier. The nature of this compartment is not well understood.

# The Gram positive cell wall
The Gram positive cell wall is characterised by the presence of a very thick peptidoglycan layer, which is responsible for the retention of the crystal violet dyes during the Gram staining procedure. It is found exclusively in organisms belonging to the Actinobacteria (or high %G+C Gram positive organisms) and the Firmicutes (or low %G+C Gram positive organisms). Bacteria within the Deinococcus-Thermus group may also exhibit Gram positive staining behaviour but contain some cell wall structures typical of Gram negative organisms.  Imbedded in the Gram positive cell wall are polyalcohols called teichoic acids, some of which are lipid-linked to form lipoteichoic acids. Because lipoteichoic acids are covalently linked to lipids within the cytoplasmic membrane they are responsible for linking the peptidoglycan to the cytoplasmic membrane. Teichoic acids give the Gram positive cell wall an overall negative charge due to the presence of phosphodiester bonds between teichoic acid monomers.

# The Gram negative cell wall
Unlike the Gram positive cell wall, the Gram negative cell wall contains a thin peptidoglycan layer adjacent to the cytoplasmic membrane, which is responsible for the cell wall's inability to retain the crystal violet stain upon decolourisation with ethanol during Gram staining.  In addition to the peptidoglycan layer the Gram negative cell wall also contains an additional outer membrane composed by phospholipids and lipopolysaccharides which face into the external environment. The highly charged nature of lipopolysaccharides confer an overall negative charge to the Gram negative cell wall. The chemical structure of the outer membrane lipopolysaccharides is often unique to specific bacterial strains (i.e. sub-species) and is responsible for many of the antigenic properties of these strains.
As a phospholipid bilayer, the lipid portion of the outer membrane is largely impermeable to all charged molecules. However, channels called porins are present in the outer membrane that allow for passive transport of many ions, sugars and amino acids across the outer membrane. These molecules are therefore present in the periplasm, the region between the cytoplasmic and outer membranes. The periplasm contains the peptidoglycan layer and many proteins responsible for substrate binding or hydrolysis and reception of extracellular signals.  The periplasm is thought to exist as a gel-like state rather than a liquid due to the high concentration of proteins and peptidoglycan found within it. Because of its location between the cytoplasmic and outer membranes, signals received and substrates bound are available to be transported across the cytoplasmic membrane using transport and signalling proteins imbedded there.