Create files and directories

Linux Command Line Quick Reference

1 min read

Published Aug 18 2026


19
0
0
0

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 private

mkdir -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.txt

Be careful with > because an existing file is truncated before new output is written.

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact
Linux Command Line Quick Reference | Create files and directories | SimpleSteps.guide