Overview¶
Linux systems maintain logs and history files that record system activity, user actions, and events. Understanding how to:
-
View logs
-
Securely delete files
-
Manage command history
is important for system administration and cybersecurity operations.
Linux Log Files¶
Log Directory¶
Explanation
-
/var/logstores system and application logs -
Used for monitoring, debugging, and auditing
Common Log Files¶
| File | Description |
|---|---|
/var/log/syslog |
General system logs |
/var/log/auth.log |
Authentication logs |
/var/log/kern.log |
Kernel logs |
/var/log/dmesg |
Boot and hardware logs |
View Log Files¶
Explanation
-
cat→ prints full content -
less→ scrollable view (recommended for large logs)
Important Note¶
-
Kernel logs (
kern.log) contain sensitive system-level information -
Should be handled carefully
shred — Secure File Deletion¶
Description¶
shred is used to permanently delete files by overwriting their content, making recovery difficult.
Syntax¶
Options Explained¶
-
-v→ verbose (shows progress) -
-f→ force overwrite (change permissions if needed) -
-u→ delete file after overwriting -
-z→ overwrite with zeros at the end
Example¶
Explanation
-
Overwrites file multiple times
-
Deletes file securely
-
Prevents data recovery
Clearing Bash History¶
Bash History File¶
Each user has a history file:
Edit History¶
Explanation
- Allows manual editing of command history
Clear History Completely¶
Explanation
-
Redirects empty output to file
-
Clears all stored commands
Clear Current Session History¶
Explanation
- Clears history from current shell session
Practical Examples¶
View Authentication Logs¶
Securely Delete Sensitive File¶
Clear Bash History¶
Important Notes¶
-
Logs are critical for forensics and troubleshooting
-
Do not delete logs unless necessary
-
shredis more secure thanrm -
Clearing history may be restricted in monitored environments
-
Some filesystems (like SSDs) may not guarantee complete shredding
Summary Table¶
| Command | Purpose |
|---|---|
cd /var/log |
Access log directory |
cat, less |
View logs |
shred |
Secure file deletion |
.bash_history |
Command history file |
history -c |
Clear session history |
Conclusion¶
Managing logs and securely handling files is essential for:
-
System monitoring
-
Data protection
-
Cybersecurity operations
Understanding these commands ensures better control over system activity and sensitive information in Linux environments.