brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: strace -f -e trace=openat shows which files a linux program opens

Linux
~/tips/tip-linux-strace-openat-files

strace -f -e trace=openat -o /tmp/open.txt myprogram --serve

Records every file a program tries to open, including the ones that do not exist.

When a program ignores its config file, I would rather watch what it opens than guess.

strace -f -e trace=openat -o /tmp/open.txt myprogram --serve
grep ENOENT /tmp/open.txt

-f follows child processes and threads, -e trace=openat limits the output to the system call that opens files, and -o writes it to a file so the program’s own output stays readable. Lines ending in ENOENT are paths the program looked for and did not find, which usually points straight at the wrong directory or a missing file. strace slows the target down a lot, and on hardened systems attaching to someone else’s process needs root.

Further reading: strace manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link