How to Create a File in the Terminal (touch)
You just made your project folder. Nice work, seriously. But right now it is completely empty, and a folder with nothing inside is not much of a project yet. Time to add your first file, the right way.
Good news: you do not need to open any app or click through menus. In this lesson you will learn how to create a file in the terminal with a single, short command.
To create a file in the terminal, type touch followed by the file name, like touch index.html. This makes a brand new, completely empty file in the folder you are currently in.
How do I create a file in the terminal?
The command is called touch. Yes, that is really its name. It does one simple job: it creates a new, empty file.
Here is how it reads, broken down:
touchis the command that creates the file.- Right after it, with a space, you type the file name you want.
So a full command looks like this:
touch index.html
That makes one blank file called index.html. The dot and the part after it (here, html) tell us the file is a web page. If you are still fuzzy on that, our lesson on what a file type is walks through it.
Why would I want an empty file?
It feels odd to make a file with nothing in it. But think of it like opening a fresh notebook. You flip to a clean, blank page. Nothing is on it yet, but it is ready for you to write.
Every great project begins as a blank page. Empty today, full of your code tomorrow. Creating the file first gives your work a home to live in.
How do I try it right now?
Make sure you are inside your project folder, then type:
touch index.html
Press Enter. Nothing dramatic happens on screen, and that is normal. To see proof the file is there, run the list command:
ls
You should see your file listed:
index.html
There it is, your very first file. Once you are comfortable, you can create files of any kind the same way, such as touch notes.txt or touch app.js.
What comes next after creating files?
Creating files is one of the small, everyday moves that make the terminal feel like home. The natural next step is learning to remove files safely when you no longer need them, so your project stays tidy.
This lesson is part of the free Zero to AI Hero course, where we take you from “what is a file?” all the way to building real apps and AI agents, step by step, in plain Hindi and English.
Key takeaways
- How to create a file in the terminal: type
touchthen a space then the file name, liketouch index.html. - The
touchcommand makes a brand new, completely empty file in your current folder. - Nothing visible happens after you press Enter, and that is expected.
- Run
lsto confirm the file was created. - An empty file is a fresh blank page, ready for your code tomorrow.
🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.
Want to actually learn this?
151 free 2-minute lessons — from "what's a file?" to building with AI.
▶ Start the free course