How to Use Shell Scripts to Manipulate Linux File Timestamps and Hide Traces

This guide explains how attackers can use Linux shell commands such as touch, stat, and ls, combined with custom Bash scripts, to record, modify, and restore file timestamps, enabling them to conceal evidence of intrusion and automate timestamp manipulation on compromised servers.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Use Shell Scripts to Manipulate Linux File Timestamps and Hide Traces

Background

File modification timestamps are a common forensic artifact on Linux systems. Attackers can alter these timestamps to hide their activity, and defenders can use the same tools to detect tampering. This article provides a step‑by‑step Bash solution for saving, modifying, and restoring timestamps.

Step 1 – Viewing and Changing Timestamps

The touch command creates a file or updates its access and modification times. Examples: touch file If the file exists, its modification time is set to the current system time. Wildcards can update many files at once: touch * To inspect a file’s timestamps, use stat: stat file Listing files with ls -l also shows timestamps:

ls -l

Custom timestamps can be set with the -d flag: touch -d "2001-01-01 20:00:00" file Verify the change with:

ls -l file
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

timestampBashForensics
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.