Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallThe Linux touch command is the quick-and-reliable way to create files and change timestamps. It’s small, fast, and shows up everywhere—from shell scripts and build systems to quick log and artifact management.
This guide breaks down what touch does, how it interacts with file access/modification times, and when each option is the right tool. You’ll also get practical examples you can paste into your terminal and adapt to your workflow.
As an Amazon Associate I earn from qualifying purchases.
What the Linux touch Command Does
touch has two main jobs:
- Create an empty file if the target file doesn’t exist.
- Update timestamps on existing files—by default, it updates the modification time (mtime) to the current time (and often also impacts access time depending on flags and filesystem behavior).
In practice, that makes touch useful for “marking” a file as recently changed, forcing rebuilds in some workflows, or initializing placeholder files before writing content.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
How touch Works Under the Hood
Every regular file typically has timestamps such as:
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
- atime: last access time (read)
- mtime: last modification time (content changes)
- ctime: inode metadata change time (permissions, ownership, renames, etc.)
touch primarily manipulates atime and mtime. The exact behavior can vary based on how your system and filesystem handle atime updates (many Linux setups mount filesystems with relatime or similar settings to reduce atime writes).
When you run touch somefile on an existing file, you’re not changing contents—you’re updating timestamps. That’s why it’s common in build tools and scripts that decide whether work needs to run.
Syntax and Core Options
The general form is:
touch [OPTION]... FILE...
Commonly used options you’ll see in scripts:
| Option | What it does |
|---|---|
-a |
Change access time (atime) only |
-m |
Change modification time (mtime) only |
-c or --no-create |
Don’t create the file if it doesn’t exist |
-t [[CC]YY]MMDDhhmm[.ss] |
Set timestamp using a specific format |
-d DATE |
Parse a human-readable date string and set it |
-r FILE |
Use the timestamps of another file |
-h |
On some implementations: affect the symbolic link itself (not the target) |
Available flags can vary slightly across implementations. On most mainstream Linux distros, touch is provided by GNU coreutils and supports the options above.
Practical Usage Examples
Below are real-world, paste-ready examples. To verify results, you can inspect timestamps with stat or ls --time.
Example verification command:
stat -c '%n %x %y' yourfile
Create an empty file
If the file doesn’t exist, touch creates it as an empty file (size 0 bytes):
touch placeholder.txt
To confirm:
ls -l placeholder.txt
Update modification time (mtime) to now
The default behavior updates timestamps to the current time. For mtime specifically, the clearest explicit command is:
touch -m report.log
Use this when you want the file to look “new” for tools that check modification times.
Update access time (atime) to now
If you care about access time (atime) rather than modification time:
touch -a document.pdf
Note that atime behavior can be influenced by mount options such as relatime.
Set a specific timestamp (YYYY-MM-DD or full date-time)
GNU touch supports human-readable dates via -d:
touch -d '2026-05-01 09:30:00' report.log
You can also use relative times:
touch -d '2 days ago' report.log
Set timestamps using epoch seconds
If you have a Unix epoch value (seconds since 1970-01-01), convert it into a format touch can parse or pass directly using supported formats.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Common pattern:
touch -d '@1714500000' report.log
The @ tells many GNU utilities to interpret the value as epoch seconds.
Create a file only if it does not exist
There’s no direct “create-if-missing, don’t update timestamps otherwise” switch, but you can achieve the goal with a conditional:
[ -e config.env ] || touch config.env
If you also want to avoid errors when permissions are restricted, keep the test and touch separate like above.
Update timestamp on multiple files at once
touch accepts multiple filenames in a single command:
touch src/*.c
Be mindful: if the glob matches nothing, some shells leave the literal pattern unchanged. To avoid surprises, consider enabling nullglob behavior or using safer wrappers in scripts.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Touch with a pattern via the shell
For example, create/update timestamp for all JSON files in a folder:
touch -m *.json
If a folder might be empty, you can add a guard:
compgen -G '.json' > /dev/null && touch -m .json
compgen checks whether the glob expands without creating files.
Use touch for batch workflows (build artifacts, logs)
Make a “build stamp” file that other parts of your automation check:
touch build.stamp
Then your scripts can compare build.stamp against source files using find or timestamp comparisons.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Example: run a command only when sources are newer than the stamp:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
find src -type f -newer build.stamp -print -quit | grep -q . && make
Use -r to copy timestamps from another file
You can copy both access and modification times from a reference file:
touch -r reference.txt cloned.txt
This is handy when you’re syncing directory structures, creating backups, or preserving metadata-like behavior in workflows.
Choosing the Right Flags (Common Recipes)
Most real tasks boil down to a few patterns. Here are the ones you’ll use most frequently.
“Create missing file, otherwise update mtime”
Default touch behavior is already close:
touch cache.db
On missing file, it creates. On existing, it updates timestamps to now.
“Only update mtime; never create”
Use -m plus -c:
touch -c -m config.yml
If config.yml doesn’t exist, touch does nothing.
“Set a timestamp and create if missing”
Use -d (or -t) without -c:
touch -d '2026-05-13 00:00:00' archive.zip
“Copy timestamps from another file”
touch -r master.dat follower.dat
“Set atime only (rare, but sometimes needed)”
touch -a -d '2026-05-01 09:30:00' /var/cache/index
If your filesystem mount prevents atime updates, you might not see atime change with stat.
Common Mistakes and Gotchas
- Confusing mtime with atime: tools that rebuild often rely on mtime, not atime. Use
-mwhen you mean it. - Assuming timestamps always change: some filesystems or mount options may limit atime updates. Modification time changes are usually reliable for regular files.
- Using
-tformat incorrectly:-t [[CC]YY]MMDDhhmm[.ss]is strict. If your string doesn’t match, the command can error or interpret values unexpectedly. - Touching symlinks when you meant targets: depending on your
touchimplementation and platform, behavior may differ for symbolic links. If you need deterministic behavior, test on your system or usereadlink/statto confirm. - Globs that match nothing:
touch *.logcan behave unexpectedly if there are no matches (the literal pattern might be passed). Add guards in scripts. - Permissions: creating or updating timestamps requires appropriate permissions. Without write permission on the directory or the file itself,
touchfails.
Troubleshooting touch Failures
When touch doesn’t behave as expected, here’s what to check in order.
“Permission denied”
If you see an error like touch: cannot touch 'file': Permission denied, check:
- You have write permission on the directory for creating files.
- You have permission to modify metadata for existing files.
- The filesystem is mounted read-only (try
mount | grep ' / 'or checkdmesgfor errors).
Timestamp didn’t change
Verify what timestamp actually changed:
stat -c '%n atime=%x mtime=%y' yourfile
Then check these typical causes:
- atime limited by mount options: relatime may prevent atime from updating on every access.
- touch ran on a different path: shell expansions or symlinks may lead to a target you didn’t expect.
- Sub-second precision differences: some tools show timestamps with limited precision. If you set a timestamp equal to the existing value, changes might not be visible.
Command errors with -t
If touch -t fails, re-check your format. For example, to set May 13, 2026 at 14:05:30:
touch -t 202605131405.30 file.txt
Make sure the digits match CCYYMMDDhhmm[.ss] exactly.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
“No such file or directory” when using globs
This often means the glob didn’t match and is being treated as a literal argument, or you’re referencing a missing directory. In scripts, use a guard before touching:
Free tools Windows power users keep installed
One-click scans. No signup required.
shopt -s nullglob; files=(/path/*.log); (( ${#files[@]} )) && touch -m "${files[@]}"
This is a bash approach; adapt for your shell.
Checking your touch version (behavior differences)
GNU coreutils touch has long been stable, but different environments (BusyBox, BSD variants) can differ. Check:
touch --version
If you don’t have a version flag, use which touch and verify the package providing it.
touch vs Alternatives (stat, time, printf, cp, install)
touch is a timestamp tool, not a content tool. Here’s when alternatives make more sense.
Recommended Free Tools
Use stat for inspection, not modification
stat shows timestamps so you can confirm your changes:
stat -c '%n %x %y %z' file
touch changes timestamps; stat helps you validate.
Use printf or echo for content changes
If you need to create a file and write content (which will update mtime), do this instead:
printf '%s
' 'hello' > file.txt
That changes file size and content, which many workflows care about more than timestamps alone.
Use cp -p for copying metadata (when you actually want preservation)
If your goal is to duplicate a file while preserving timestamps, prefer:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchescp -p source.txt dest.txt
touch won’t copy file content; it only updates timestamps.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Use install for setting permissions plus creation
When you need to create a file and set mode/ownership atomically (common in system scripts):
install -m 0644 /path/template.conf /etc/app.conf
Then timestamps and permissions are set as part of the installation step.
FAQ: touch Command
Does touch change the file size?
No. If the file exists, touch doesn’t alter content, so size stays the same. If it creates a new file, that file starts at 0 bytes.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Why do I see atime not changing?
Many Linux systems mount filesystems with policies like relatime to reduce atime updates. This can make atime changes less frequent or dependent on other timing rules.
Can touch update multiple timestamp fields at once?
Yes. The default behavior typically updates both access and modification times unless you restrict it with -a or -m. For precision, use -a or -m.
How do I set the timestamp to exactly now but keep formatting consistent?
Use relative time strings or omit -d entirely. For example, touch file sets timestamps to the current time in the implementation’s default way.
Is touch safe to use in scripts?
Yes, with standard precautions: quote filenames, guard globs, and handle permissions. When you’re using -d with user input, validate dates or restrict allowed formats to avoid surprising results.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11What’s the difference between touch and changing timestamps with chmod/chown?
chmod and chown change metadata, which can update ctime. touch updates atime and/or mtime. They’re related but not the same.
Bottom Line
touch is the go-to Linux command for creating files and changing timestamps with minimal fuss. Once you understand which timestamp you’re changing (-a, -m, or defaults) and how your filesystem treats atime, it becomes a reliable tool in both interactive work and automation.
Use -c to avoid accidental creation, -d or -t to set precise times, and -r when you want timestamp cloning from a reference file.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




