29 January 2021
1 min read

Touch Command in Linux – Options + Examples

The Linux operating system has multiple objects, such as application files, directories, system files, and binary files. These objects contain metadata information along with the files, which include create, access, and modification time. Sometimes, you may need to update these timestamps and the Linux touch command is a way to do it.

In this tutorial, we will learn about the touch command line utility in Linux.

Prerequisites

  • A Linux computer with terminal access.
  • Understanding of Linux command-line interface.
  • Excitement to learn new Linux commands.

Linux Touch Command

The Linux touch command is primarily used to modify a file timestamp. It can also be used to create an empty file. When you work on your Linux computer, you may need to create an empty file so that applications can write to it. Also, certain administrative services may require files to have a certain timestamp. The touch command in Linux can do both of these jobs. This command does not change file contents.

Touch can update the access and modification time of the specified file. However, if the specified file does not exist, then touch creates a new file with the specified name. It creates an empty file and you can add data to it later using any text editor. To update access and modification time, the file must exist on your system.

Before we dive deep into this command, let’s understand what three timestamps in Linux are:

  • Access time (atime) – The last time when some command or application accessed the file.
  • Modify time (mtime) – The last time when the content of the file was modified.
  • Change time (ctime) – The last time when any attribute or content of the file was changed. Change time can be updated without updating the content.

Use the stat command in Linux followed by the file name to display the file timestamps.

Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is the editor-in-chief of Linoxide and has an experienced team of Linux enthusiastic authors who makes this blog awesome. Linoxide is one of the top 20 Linux Blog by whizlabs.

Leave a Reply

Your email address will not be published.

Previous Story

Linux Top Command Explained

Next Story

Linux IP Command – Examples + Options

Latest from Blog

Top 8 Reasons to Use Garuda Linux

Have you been going back and forth between multiple Linux flavors in search of an exciting experience? Or perhaps you are coming from a Windows or MAC environment and want to try

How to Rename Multiple Files in Linux

In a Linux system, you can easily rename a file using mv command. But, if you have multiple files which you want to rename, in this situation you need some extra tools

How to Install TensorFlow on Ubuntu 20.04

Tensorflow is an open-source platform for machine learning and artificial intelligence. It is developed by the Google Brain team. It contains tools, libraries, and community resources for developers to build ML powered
Go toTop