8 Pratical Examples of Linux “Touch” Command

If you have any questions or problems regarding this article and want help within 24 Hours? Ask Now

Support TecMint: Did you find this tutorial helpful?. Please help to keep it alive by donating. Every cent counts! - Donate Now

Ravi Saive

Simple Word a Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

13 Responses

  1. Matt-Boy says:

    This may be behavior specific to the Apple/Mac implementation of TOUCH, but I figured one additional thing out. The touch command does not have an option to update the CREATION date of a file. However, if you use touch to update the modification date, and that date is before/earlier than the creation date, the creation date will be updated as well.

  2. Marc G says:

    At 6. Explicitly Set the Access and Modification times you write for the format:
    [# touch -c -t YYDDHHMM leena]
    Should it not be: YYMMDDHH ?
    Two digits for the year (the last two) is fine, but followed by DD which should
    mean the DAY doesn’t make sense.
    The info (MAN) page for “touch” says “-t [[CC]YY]MMDDHHMM[.SS]”.
    I’m here because I’m getting a “touch: invalid date format ‘15062500’”, after doing
    “touch -c -t 15062500 my-file.txt”. That’s June 25, 2015, 00h(00).
    Trying to figure it out.

    • Ravi Saive says:

      Do this way..

      tecmint@tecmint ~/renamefiles $ touch -c -t 1506250000 my-file.txt
      tecmint@tecmint ~/renamefiles $ ls -l
      total 0
      -rw-r--r-- 1 tecmint tecmint 0 Jun 25 00:00 my-file.txt
      • Marc G. says:

        Yes, thank you, I got it. I was omitting the dot before the seconds and
        doing as if the minutes were optional. They are not. It’s the seconds
        that are optional.

        But really you should edit your original post and replace YYDDHHMM
        with MMDDHHMM. That was a misprint. You cannot have day following

        Thanks again.

  3. venkat says:

    Thank you for these tips/
    The basics of the command “touch” are covered very well, in a simple manner.


  4. Abhishek Yadav says:

    Nice tutorials…covers basics of ‘touch’ fair enough !!

  5. Hej

    I use Ubuntu 14.04, when I use touch like this:

    touch -t 195312100101 sekt-0001.jpg

    Then the file icon i filer have a clock on it why?

    I can still use the picture

  6. Lucas says:

    Out of curiosity, any idea how the touch command got its name?

    • Matt-Boy says:

      I think the idea is that you are just “touching” the file so it records that it was accessed/modified, but you are not actually changing the file in any other way. Note that there are no options to modify the content of the file itself.

      • Ravi Saive says:

        Yes, you correct and I totally agree with your point, we are only touching the file, no modifications, but it records as accessed/modified time.

  7. MykeC says:

    How does one update the modification timestamp of a file to become its current value plus one second?

    I would like to write a shell script which does this easily to any group of files as needed.

  8. Santhosh says:

    Nice post & it’s very useful.

    One small correction here. I think the following command will update the time-stamp of file meena with the time-stamp of leena file.

    $ touch -r leena meena

    Will you check it.


    • Ravi Saive says:

      Dear Vijay,

      Thanks for the findings, no one noticed that post was 1.2 year old and the only you who noticed. Thanks again, corrected in the write up..:)

Leave a Reply

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

Join Over 95000+ Linux Users
  1. 57,739
  2. 3,201
  3. 25,639

Enter your email to get latest Linux Howto's