touch

Let’s learn how to make some files. A very simple way is to use the touch command. Touch allows you to the create new empty files.

$ touch mysuperduperfile

And boom, new file!

Touch is also used to change timestamps on existing files and directories. Give it a try, do an ls -l on a file and note the timestamp, then touch that file and it will update the timestamp.

There are many other ways to create files, using redirection or a text editor, and both are coming up shortly: nano later in this section, and redirection in the Text Manipulation section after it.

Exercise

  1. Create a new file
  2. Note the timestamp
  3. Touch the file and check the timestamp once again

Quiz Question

How do you create a file called myfile?

Show answer

touch myfile