Create files and directories
Linux Command Line Quick Reference
1 min read
This section is 1 min read, full guide is 20 min read
Published Aug 18 2026
19
Show sections list
0
Log in to enable the "Like" button
0
Guide comments
0
Log in to enable the "Save" button
Respond to this guide
Guide Sections
Guide Comments
CLILinuxUbuntu
Use touch to create an empty file, or to update the timestamps of a file that already exists. Use mkdir to create directories.
Create files and directories
bash
touch notes.txttouch file1.txt file2.txtmkdir reportsmkdir -p projects/app/logsmkdir -m 750 privatemkdir -p creates missing parent directories and does not complain if the directory already exists. -m MODE sets permissions as the directory is created.
Shell redirection can also create files. > creates or replaces a file with command output, while >> appends to it.
Create files using redirection
bash
echo "hello" > file.txtecho "another line" >> file.txt> empty.txtBe careful with > because an existing file is truncated before new output is written.