Touch

From LQWiki
Jump to navigation Jump to search

Touch, by default, changes the timestamp for an existing file to the current date and time or, if the file named does not exist, creates it in the current directory. For example:

$ ls -l foo
-rw-------    1 user        users          32 Mar 18 22:07 foo
$ touch foo
$ ls -l foo
-rw-------    1 user        users          32 Mar 21 12:28 foo

sets the timestamp to the current time.

As another example, if .hushlogin did not exist:

$ cd
$ touch .hushlogin

creates a .hushlogin file in one's home directory, which suppresses the display of /etc/motd on login.

Among other options, a particular time may be specified with the -t option and file creation may be suppressed with the -c option.

Provided by

Most (all?) Linux distributions incorporate this from the GNU Coreutils: man page

Related Commands

  • chgrp- Changes group ownership of a file
  • chown- Changes user/group ownership of a file
  • chmod - Changes the user/group permissions of a file/directory
  • ls - Lists files