Create A File
Part of the Fundamentals section of Coddy's Terminal journey — lesson 10 of 82.
The touch command is used to create a new empty file in your current directory.
Simply type touch followed by the name of the file you want to create:
touch hello.txtThis creates a new empty file called hello.txt. You can confirm it was created by running ls:
ls
hello.txtCreating multiple files at once:
You can create several files in a single command by listing them separated by spaces:
touch file1.txt file2.txt file3.txtCreating a file inside a folder:
You can create a file directly inside another directory without navigating into it first:
touch documents/notes.txtNote: If the file already exists, touch will not overwrite it — it simply updates the file's last modified timestamp.
Challenge
BeginnerCreate a new file called hello.txt in your current directory, then use ls to confirm it was created.
Hint: Use the
touchcommand followed by the filename.
Cheat sheet
The touch command creates a new empty file:
touch hello.txtCreate multiple files at once by separating filenames with spaces:
touch file1.txt file2.txt file3.txtCreate a file inside a specific directory:
touch documents/notes.txtNote: If the file already exists, touch updates its last modified timestamp without overwriting it.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data Pipeline