ప్రధాన కంటెంట్‌కు వెళ్లండి
eLearner.app
మాడ్యూల్ 2 · 3లో పాఠం 1కోర్సులో 3/11~10 min
మాడ్యూల్ పాఠాలు (1/3)

వనరులను సృష్టించడం (mkdir మరియు టచ్)

Beyond navigating, you will frequently need to organize your workspace by creating new folders (directories) and empty files in the terminal.


Creating Folders: mkdir

To create a new folder, use the command:

Bash
mkdir [folder_name]

This command stands for Make Directory. For instance, mkdir documents will create a folder named documents in your current directory.

Creating Nested Paths with -p

If you try to create a folder inside a directory that does not exist yet (e.g. projects/javascript/2026), the command will fail and display an error.

To instruct Linux to automatically create any missing intermediate parent directories, use the -p option:

Bash
mkdir -p projects/javascript/2026

Creating Empty Files: touch

To create an empty file, or to update the modification timestamp of an existing file, use the command:

Bash
touch [file_name]

For example, typing touch app.js creates a blank text file with that name in the current folder.


Usage Examples and Common Errors

If you try to create a file using touch inside a folder that does not exist yet, you will receive an error:

Bash
touch ghost_folder/index.html
# Output:
# touch: cannot touch 'ghost_folder/index.html': No such file or directory

In this case, you must first create the directory structure and then create the file:

Bash
mkdir ghost_folder
touch ghost_folder/index.html

If a folder already exists, running mkdir without -p will generate an error:

Bash
mkdir projects
# Output:
# mkdir: cannot create directory 'projects': File exists

Try it yourself

Exercise 1: Create a projects folder

వ్యాయామం#linux.m2.l1.e1
ప్రయత్నాలు: 0లోడ్ అవుతోంది...

Create a new folder named 'projects' in the current directory.

ఎడిటర్ లోడ్ అవుతోంది…
సూచనను చూపించు

Use the mkdir command followed by the folder name 'projects'.

3 ప్రయత్నాల తర్వాత పరిష్కారం లభిస్తుంది

Exercise 2: Nested structure

వ్యాయామం#linux.m2.l1.e2
ప్రయత్నాలు: 0లోడ్ అవుతోంది...

Create a nested directory tree 'workspace/src' in a single command, making sure to create any necessary parent directories.

ఎడిటర్ లోడ్ అవుతోంది…
సూచనను చూపించు

Use the -p option with the mkdir command to build out nested paths.

3 ప్రయత్నాల తర్వాత పరిష్కారం లభిస్తుంది

Exercise 3: Create an empty file

వ్యాయామం#linux.m2.l1.e3
ప్రయత్నాలు: 0లోడ్ అవుతోంది...

Create an empty file named 'index.html' in the current directory.

ఎడిటర్ లోడ్ అవుతోంది…
సూచనను చూపించు

Use the touch command followed by the name of the file to create.

3 ప్రయత్నాల తర్వాత పరిష్కారం లభిస్తుంది