Cell wall

A cell wall is the wall of a cell in plants,  bacteria, fungi, algae, and some archaea. Animal cells do not have cell walls, nor do protozoa. Cell walls protect the cells from damage. It is also there to make the cell strong, to keep its shape, and to control the growing of the cell and plant.

The cell wall is the tough, usually flexible but sometimes fairly rigid layer that surrounds some types of cells. It is outside the cell membrane and gives these cells support and protection, as well as acting as a filter. The cell wall also acts as a pressure vessel, preventing over-expansion when water enters the cell by osmosis. 

The material in the cell wall varies. In plants and algae, the cell wall is made of long molecules of cellulose, pectin, and hemicellulose. The cell wall has channels which let some proteins in and keeps others out. Water and small molecules can go through the cell wall and the cell membrane.

Functions

Strength 
The cell wall has mechanical strength, and supports cell shape. This mechanical strength is its main function:
"Think of the cell wall as a wicker basket in which a balloon has been inflated so that it exerts pressure from the inside. Such a basket is very rigid and resistant to mechanical damage. Thus the [organisms] cell that have a cell wall) gain strength from a flexible plasma membrane pressing against a rigid cell wall".
Although the plant cell wall is strong, it is not rigid or stiff. The flexibility of the cell walls is seen when plants wilt, so that the stems and leaves begin to droop.

Some plants add stiffening material to some of their cell walls. A secondary cell wall is an additional layer of cellulose which increases wall rigidity. More layers may be added containing lignin in xylem cell walls, or containing suberin in cork cell walls.  These compounds are rigid and waterproof. They make the secondary wall stiff. Both wood and bark cells of trees have secondary walls. Other parts of plants such as the leaf stalk may get reinforcement to resist the strain of physical forces.

Permeability 
Small molecules, including small proteins, can easily get through the primary plant cell wall. Water and carbon dioxide are distributed throughout the plant. The pH is an important factor in the transport of molecules through cell walls.

Bacterial cell wall 

Around the outside of the cell membrane is the bacterial cell wall. Bacterial cell walls are made of peptidoglycan, which is made from polysaccharide chains cross-linked by unusual peptides containing D-amino acids. Bacterial cell walls are different from the cell walls of plants and fungi which are made of cellulose and chitin, respectively.

The cell wall of bacteria is also distinct from that of Archaea, which do not contain peptidoglycan. The cell wall is essential to the survival of many bacteria.  The antibiotic penicillin is able to kill bacteria by preventing the cross-linking of peptidoglycan and this causes the cell wall to weaken and lyse. The lysozyme enzyme can also damage bacterial cell walls.

Middle lamella
The middle lamella gives the cell shape, support, and strength. It is made of calcium and magnesium. Even though it is called middle lanella, it is the outer part of the cell. The middle lamella is the first wall of the cell to give protection.

Animal cell membrane 
Animal cells do not have cell walls. They have microfilaments (the thinnest filaments of the cytoskeleton).

References

Cell biology
Plant anatomy