How does a cell know what type it is?

There are many different kinds of cells in living organisms: nerve cells, red blood cells, muscle cells, fat cells etc.
But how does a cell know what type it is? Where is this information stored or passed? I mean it can’t be DNA since it is the same for every cell…

The DNA sequence is (mostly) the same for all cells in an organism. However, as cells differentiate during embryogenesis, different segments of the DNA are inactivated off due to modification of the DNA (methylation) and of DNA associated proteins (Histones) that determine which DNA sequences can be actively transcribed (chromatin remodelling). So, if the DNA sequence represents the archive of all information needed in a whole organism, in individual cells some of the drawers in this archive are locked by these epigenetic changes, depending on the specialization of the individual cells. Regulatory processes dynamically lock and unlock different drawers by directing DNA and histone modifying enzymes to specific location on the DNA.

Red blood cells should be listed as an exception not “yet another type”.
Red blood cells do not have DNA, due to their short life and hence rapid production rate, evolution had a sufficient incentive to reduce the waste of DNA by not including DNA in red blood cells.

The red blood cell certainly cannot change its type, its only got the RNA and other machinary to be a red blood cell, with no DNA it doesnt even know how to make anything else (they wouldn’t be able to lengthen their short life time ?? )

You’re essentially asking for the entire field of development and differentiation to be explained to you. There are enough papers and textbooks on the subject to fill a library.

A quick and dirty answer is that signals from each cell’s local microenvironment are ultimately translated into a pattern of genetic regulation - some genes are activated, others are inactivated. The exact pattern is what distinguishes, say, a liver cell from a bone cell.

As a simple example, in male fruit flies, the sperm stem cells live at the very tip of the testis. Well, almost at the very tip. At the very very tip are a group of cells called hub cells. The stem cells surround the hub cells. Every time the stem cells divide, one of the two daughter cells remains a stem cell, and the other one goes off to become a bunch of sperm cells. It turns out that the cell division always leaves one cell close to the hub, and the other one farther away. The one close to the hub is the one that stays a stem cell, and this is because the hub cells are secreting specific proteins that tell nearby cells to stay as stem cells. The daughter cell that’s farther away doesn’t get this signal, so it differentiates into the sperm cell lineage. This is easier to understand with a drawing, but oh well.

Differentiation is partly determined by gradients of different signaling chemicals but also by voltage gradients that are only now being decoded.

Red blood cells in non-mammalian animal species (ie, most of them), do have nucleated red blood cells (and even complete platelet-cells, call thrombocytes, instead of the fragments we call platelets).

Also, despite it’s “short” life time, red blood cells in some species can live longer than many other cells. Many circulating white blood cells, despite having DNA, have a shorter life span than the red blood cells.