Create File

There are a number of ways to create files in the Linux command line.

View Directory Contents

ls -l
total 0

Create An Empty File

touch empty_file.txt

Create Another Empty File

> another_empty_file.txt

Create File With Some Content

echo 'This is the contents to the file' > hello_world.txt

Quickly Create A File With Some Contents

cat > hello_world.txt

Then type the contents of the file and press ctrl-d

View Directory Contents

ls -l
total 4
-rw-rw-r-- 1 chris chris  0 Jul 22 12:46 another_empty_file.txt
-rw-rw-r-- 1 chris chris  0 Jul 22 12:44 empty_file.txt
-rw-rw-r-- 1 chris chris 10 Jul 22 12:46 hello_world.txt