You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sudo grep -i "session opened" /var/log/auth.log # Sessions opened
94
+
sudo awk '/2024-06-04 15:30:00/,/2024-06-05 15:29:59/' /var/log/auth.log # To filter auth logs by a specific date and time range, we can use awk
95
+
sudo grep "$(date --date='2 hours ago''+%b %e %H:')" /var/log/auth.log # To filter entries from the last few hours, we can use tail in combination with grep and date
awk '{print $9}' /var/log/apache2/access.log*| sort | uniq -c | sort -nr # Summarize http status codes from logs
104
+
105
+
106
+
# Auditd
107
+
/etc/audit/audit.rules # Auditd rules conf file
108
+
sudo auditctl -a always,exit -F arch=b64 -S execve -k execve_syscalls # logs every program execution through the execve system call on a 64-bit architecture (arch=b64) and tags these events with the key execve_syscall
109
+
sudo auditctl -w /etc/passwd -p wra -k users # Watches the /etc/passwd file for write, read, and change attributes and tag it as 'users'
110
+
/var/log/audit/audit.log # Audit logs file
111
+
sudo ausearch -k users # Searching for logs with the key we associated our audit logs with in our auditd rules
112
+
sudo ausearch -k execve_syscalls
113
+
sudo ausearch -k users | aureport -f user-logs # Get a report of the logs
114
+
115
+
# JOURNALCTL
116
+
journalctl -f # Follow the journal and show new entries as they are added
117
+
journalctl -k # Show messages from a specific boot.
118
+
journalctl -u apache.service # Filter messages by a specific unit.
119
+
journalctl -p err # filter messages by priority
120
+
journalctl -S "2021-05-24 14:08:01"# Show messages since a specific time.
121
+
journalctl -U "2021-05-24 15:46:01"# Show messages until a specific time.
122
+
journalctl -r # Reverse the output, showing the newest entries first.
123
+
journalctl -n 20 # Limit the number of shown lines.
124
+
journalctl --no-pager # Do not pipe the output into a pager.
0 commit comments