Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What does the command 'touch' when applied to a directory?

dragos@Dragos--XPS-L702X:~$ mkdir test
dragos@Dragos--XPS-L702X:~$ ls -l
total 52
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Desktop
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Documents
drwxr-xr-x 2 dragos dragos 4096 Oct 26 17:16 Downloads
-rw-r--r-- 1 dragos dragos 8445 Oct 25 00:35 examples.desktop
drwxrwxr-x 3 dragos dragos 4096 Oct 25 00:56 facultate
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Music
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Pictures
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Public
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Templates
drwxrwxr-x 2 dragos dragos 4096 Oct 27 18:08 test
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Videos
dragos@Dragos--XPS-L702X:~$ touch test
dragos@Dragos--XPS-L702X:~$ ls -l
total 52
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Desktop
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Documents
drwxr-xr-x 2 dragos dragos 4096 Oct 26 17:16 Downloads
-rw-r--r-- 1 dragos dragos 8445 Oct 25 00:35 examples.desktop
drwxrwxr-x 3 dragos dragos 4096 Oct 25 00:56 facultate
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Music
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Pictures
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Public
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Templates
drwxrwxr-x 2 dragos dragos 4096 Oct 27 18:08 test
drwxr-xr-x 2 dragos dragos 4096 Oct 25 00:42 Videos
share|improve this question

2 Answers 2

up vote 3 down vote accepted

As stated in the manpage, the primary use of touch is this:

Update the access and modification times of each FILE to the current time.

So it updates the access and modification times of the directory.

share|improve this answer

touch is a standard Unix program used to change a file's access and modification timestamps. It is also used to create a new empty file.

The Single Unix Specification (SUS) specifies that touch should change the access times, modification times, or both, for a file. The file is identified by a pathname supplied as a single argument. It also specifies that if the file identified does not exist, the file is created and the access and modification times are set as specified. If no new timestamps are specified, touch uses the current time.

-Wikipedia

You can find more in-depth information on the touch command (or any other command you would like to know about) by using the man command like this:

man touch

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.