How to use the touch command: 2-Minute Linux Tips

Hi, this is Sandra Henry-Stocker, author of
the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the touch command that allows you to create
an empty file or update a file’s last updated date/time settings. Let’s try it out and
see how it works. First, to create a new empty file, you would
simply use a touch command like this: Notice that the file listing will indicate
that the file is new (current date/time) and that the file is empty. Why would you want
to do this? You might need to make sure that a particular file exists before some script
or process that requires it runs. If you touch an existing file, the date/time
settings will be updated to the current date/time:
If you want to set the date/time of a file to match those of another file, use the -r
(reference) option: The stat command will the
reflect the new dates and times:
That’s your Linux tip for the touch command. If you have questions or would like to suggest
a topic, please add a comment below. And don’t forget to subscribe to the IDG
Tech(talk) channel on YouTube. If you liked this video, please hit the like
and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and

, , , , , , , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *