We have explored existing directories. Before creating files, let us build a separate practice area so later commands have a clear home. Folder and directory refer to the same concept here.
Create a small tree
cd
mkdir netopsiyon-dersleri
cd netopsiyon-dersleri
mkdir belgeler gorseller
mkdir -p arsiv/2026/aralik
mkdir "Ders Notlari"
ls
Plain cd returns home. Mkdir creates netopsiyon-dersleri there. The name means make directory. Creating a directory does not enter it, which is why the next line uses cd.
The two unquoted names belgeler and gorseller are separate targets. The quoted name “Ders Notlari” is one target containing a space.
Make mkdir and mkdir -p behave differently
If the parent already exists, an easy first example can hide the distinction. Start inside the course directory and create a new comparison folder that has no rapor entry:
mkdir mkdir-karsilastirma
cd mkdir-karsilastirma
mkdir rapor/2026
The last command is expected to fail. Plain mkdir tries to create the requested final directory; it does not also create the missing rapor parent. A missing-path error refers to that absent route, not an invalid name for 2026.
You could explicitly create each level:
mkdir rapor
mkdir rapor/2026
Now both levels exist. Use a different name for the next experiment so we do not confuse creating something with accepting an existing tree:
mkdir -p arsiv/2026/aralik
ls -d arsiv arsiv/2026 arsiv/2026/aralik
The -p option creates missing parents as needed. The verification names all three levels, showing that the required route really exists rather than relying on silence from mkdir.
An existing directory is another important difference
mkdir rapor/2026
mkdir -p rapor/2026
The first reports an existing destination. The second succeeds when the target is already a directory. Thus -p both creates missing parents and avoids treating an existing directory as an error. Its long spelling is --parents.
This is useful for repeatable setup steps: ensuring a log directory exists should not necessarily fail just because an earlier run created it. But -p is not a universal repair option.
A regular file remains an obstacle
touch engel
mkdir -p engel/alt
Inside this disposable comparison folder, touch creates an empty file named engel. The next command must fail because a regular file cannot contain a child directory. The option neither deletes the file nor converts it into a directory. It also does not bypass filesystem permissions.
| Initial state | mkdir a/b | mkdir -p a/b |
|---|---|---|
| a is absent | Fails. | Creates a and b. |
| a exists, b is absent | Creates b. | Creates b. |
| a/b already is a directory | Reports an existing target. | Succeeds, preserving it. |
| a is a regular file | Fails. | Fails; no conversion occurs. |
Show creation with -v
mkdir -pv deneme/alt/son
The -v option reports directories being created. It answers an output question, while -p controls the creation behavior. On a repeat run there may be no creation messages because nothing new was required. Return to the main practice directory afterwards so later files are not accidentally created inside the comparison folder.
Verify the location
Use pwd to confirm you are inside netopsiyon-dersleri, then inspect the results with ls -l and ls -l arsiv/2026. If this is a remote terminal, remember that the folders exist on the remote machine, not automatically on your Windows desktop.
Create denemeler/birinci with -p, enter it with cd and check with pwd. Creation, navigation and verification are separate operations; identify the command responsible for each.
References: GNU / Linux