--- title: touch — Linux basic command date: 2026-10-19 time: 12:00 model: admin category: programs author_type: human summary: Creates an empty file or updates the modification timestamp of an existing file. tags: program, Basic Linux commands, touch --- A command that creates empty files or updates the modification time of existing files. ## Basic Information | Command Name | touch | | --- | --- | | One-line Introduction | A command that creates empty files or updates the modification time of existing files. | | Provided By | GNU coreutils (default on all Linux distributions) | | Official Documentation | https://man7.org/linux/man-pages/man1/touch.1.html | | Supported Operating Systems | Linux, macOS, BSD, WSL | | Installation Required | Pre-installed (no separate installation needed) | | Category | Basic Linux Commands (tags: file creation, timestamp, Linux, basic) | ## What Is This Command? touch is a command that creates an empty file if it doesn't exist, and if it does, updates the file's access and modification times to the current time. It's the simplest method for file creation and is frequently used in scripts to create temporary files. You can set a specific time with the -t option, or copy timestamps from another file with the -r option. ## What Problem Does It Solve? - Quickly creates empty files. - Updates a file's modification time. - Uses a timestamp file to mark task completion. - Updates directory access times. ## Key Features ### Empty File Creation Creates an empty file with a filename that doesn't exist. - **Use Case**: When you need to create a file quickly. - **Result**: A 0-byte empty file is created. - **Limitation**: Since it's an empty file, data must be added separately. ### Timestamp Update Changes the modification time of an existing file to the current time. - **Use Case**: When you want to mark a file as 'up-to-date'. - **Result**: The current time will be shown in ls -l. - **Limitation**: The file content remains unchanged. ### Multiple File Creation Specifies multiple filenames to create at once. - **Use Case**: When creating multiple empty files at once. - **Result**: All specified files are created. - **Limitation**: If there are too many names, the command becomes long. ### Time Specification (-t) Sets a specific time with the -t option. - **Use Case**: When manually setting backup or snapshot times. - **Result**: The specified time is recorded in the file's metadata. - **Limitation**: You need to know the exact time format. ## Installation and Execution ### Verify Pre-installation It is included by default on all Linux distributions. ``` which touch touch --version ``` ### Separate Installation (Lightweight Environments) It is generally already installed. ``` sudo apt install coreutils # Debian/Ubuntu ``` ## Practical Examples ### Basic File Creation Creates an empty file. ``` # Create a single file touch empty.txt # Create multiple files at once touch file1.txt file2.txt file3.txt # Verify ls -l empty.txt # -rw-r--r-- 1 user user 0 Oct 18 12:00 empty.txt ``` ### Timestamp Update Changes the timestamp of an existing file. ``` # Update file timestamp to current time touch existing-file.txt # Verify timestamp ls -l existing-file.txt # Update directory timestamp touch /var/www/html/ ``` ### Specifying a Specific Time Specifies the time using the -t option. ``` # Set to January 1, 2026 at 12:00 touch -t 202601011200 file.txt # Copy timestamp from another file touch -r reference.txt new-file.txt # Verify timestamp ls -l --time-style=full-iso file.txt ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/basics/touch.html This file is an auto-generated Markdown twin of the DevHub document.