this post was submitted on 05 Jan 2024
25 points (93.1% liked)

Linux

48072 readers
1 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

Anyone know how to see what pid/process has modified a linux routing table (specifically on Ubuntu )? I have an interesting problem where a route that I have created has been deleted over time, but can't figure out what. I've tried rtmon but seems to only show timestamps of the adds/deletes

top 4 comments
sorted by: hot top controversial new old
[–] Deckweiss@lemmy.world 6 points 2 years ago* (last edited 2 years ago)

The better solution:

sudo apt-get install auditd

Set up watch: sudo auditctl -w /path/to/your/file -p wa -k file_change_monitor

Check log: sudo ausearch -k file_change_monitor


Alternative solution:

If you know the file that is being edited you can set up watches with inotifywait and log it to a file. This may possibly not work because lsof might not be quick enough.

sudo apt-get install inotify-tools

then put this script in autostart

#!/bin/bash

FILE_TO_MONITOR="/path/to/your/file"
LOG_FILE="/path/to/logfile.txt"

inotifywait -m -e modify,move,create,delete --format '%w %e %T' --timefmt '%Y-%m-%d %H:%M:%S' "$FILE_TO_MONITOR" |
while read path action time; do
    # Get the PID of the process that last modified the file
    PID=$(lsof -t "$FILE_TO_MONITOR" 2>/dev/null)

    # Get the process name using the PID
    PROCESS_NAME=$(ps -p $PID -o comm= 2>/dev/null)

    # Log details to the file
    echo "$time: File $path was $action by PID $PID ($PROCESS_NAME)" >> "$LOG_FILE"
done

Don't forget to modify the values at the top of the script and make it executable.

[–] Shadow@lemmy.ca 4 points 2 years ago* (last edited 2 years ago)

I don't think any historical data would exist, but you could probably watch changes with ftrace

[–] bizdelnick@lemmy.ml 3 points 2 years ago

I guess it can be NetworkManager if it is used to configure the interface but the route is added manually.

[–] ipsirc@lemmy.ml 2 points 2 years ago