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

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
Ubuntu Linux Toolbox: 1000+ Commands

You may also like...

10 Responses

  1. 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.

  2. venkat says:

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


  3. Abhishek Yadav says:

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

  4. 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

  5. Lucas says:

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

  6. 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.

  7. 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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Join Over 80000+ Linux Users
  1. 52882
  2. 2763
  3. 18,639

Enter your email to get latest Linux Howto's