As a Linux user or administrator, you often need to track file changes—whether to debug an application, monitor system activity, or investigate a security breach. The find command is a powerful tool for this, and one of its useful options is -ctime n, which helps locate files modified within a specific timeframe.
Understanding find -ctime n
The find command in Linux is used to search for files based on various criteria. The -ctime n flag filters files by their status change time, which includes:
- File modifications (content changes)
- Permission changes
- Ownership changes
When to Use find -ctime n
This command is invaluable for:
- Troubleshooting – Quickly identify altered files after system changes
- Security audits – Detect unauthorized file modifications
- Development – Track recent edits in project files
- Forensics – Investigate suspicious system activity
The -ctime parameter helps you pinpoint exactly when changes occurred, making it essential for both routine maintenance and critical investigations.
Common Examples
Here are practical ways to combine -ctime with paths, file types, and actions in Linux.
- Changed in the last 24 hours. Run
find /var/log -ctime 0to locate log files with metadata updates within the past day. - Changed within the last 7 days. Run
find ~/Documents -ctime -7to find any files in your documents folder altered in the past week. - Changed more than 30 days ago. Run
find /tmp -type f -ctime +30to identify old regular files in the temporary directory. - Changed between 2 and 5 days ago. Run
find /etc -ctime +1 -ctime -5to narrow results to a specific multi-day window.