The histogram
To work with Levels (Levels if you are using Photoshop in English), it is good to first understand what a histogram shows. This is a graph that represents the distribution of tonal values in a photo. On the left side, we see the dark tones, in the middle the midtones, and on the right side the light tones. The higher the graph at a certain point, the more pixels have that tonal value.
You can thus see how light and dark are distributed across your photo. A photo of a starry sky, for example, has many dark pixels, which means the graph is mostly on the left side. In a snowy landscape, it is often the exact opposite.
It is not the case that a good histogram always has to have a peak in the middle. The shape mainly depends on the subject and the exposure you have in mind. However, a histogram can show that a photo has little contrast. When there is a lot of space left at both ends, the image may not contain any truly dark or light tones. You can adjust that with this function.

Levels
You can find the Levels function in the Adjustments panel of Photoshop. If this is not visible, you can open it via Window > Adjustments. Then click on the icon for this function. Photoshop will then automatically create a adjustment layer.
The advantage of such a layer is that you can change or remove the adjustment later, without altering the original photo. You can also open the correction with Ctrl+L (Command+L on macOS). However, this applies the adjustment directly to the selected image layer. Working with an adjustment layer is therefore usually wiser.
Sliders
Directly below the histogram are three sliders. These are the input levels. The black slider on the left sets the black point, the white slider on the right sets the white point, and the gray slider in the middle affects the midtones.
When you move the black slider to the right, dark tones become even darker. The white slider does the opposite: if you move it to the left, light tones become brighter. By carefully sliding both sliders inward, you can give a photo with low contrast more depth.
The middle gray slider is used to adjust the midtones. If you slide it to the left, they become lighter. To the right, they become darker. This allows you to brighten a dark photo slightly without directly changing the black point or white point.
Below the input levels, there are two sliders for the output levels. With these, you can limit the final tonal range, for example, to make the darkest black slightly lighter.
In practice
Suppose you have taken a photo that looks a bit dull. When you look at the histogram, you see that the graph does not fully extend on the left and right sides. With Levels, you can then try to carefully slide the black and white input sliders towards the existing tonal values. This increases the difference between light and dark areas.
Be careful not to move the sliders too far. This can cause details in the dark or light areas to disappear. We call this clipping. You can check this by holding down the Alt key (Option on macOS) while shifting the black point or white point. Photoshop will then show which areas become completely black or white.
If your photo is mainly too dark but already has enough contrast, you should first try the middle slider. This will lighten the midtones without directly changing the black point or white point.

Levels Preset
You don't always have to manually adjust all the sliders. Photoshop also has automatic corrections and presets that allow you to try out different results.
With the button Auto Photoshop can, for example, suggest a correction itself. This can be a useful starting point, but make sure to check the result carefully. A deliberately dark photo does not necessarily need to be made lighter automatically.
Histogram Distribution
When you look at the histogram, you sometimes see that the graph is divided into several vertical parts. Contrary to what is sometimes thought, each part does not automatically represent one exposure stop.
The histogram shows the distribution of tonal values. In an image with 8 bits per channel, the scale runs from 0 (black) to 255 (white). The shape of the graph mainly tells you which tones are present in your photo, not how much exposure compensation you need to apply.
With this adjustment, you can relatively quickly improve the contrast and brightness of your photo. Start with small adjustments and regularly compare the result with the original. This way, you prevent losing unnecessary details.
- Read also: Learn to read the histogram