Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine what files a program is trying to open?

I have a program that I have compiled for a Linux server. It was written in FORTRAN, although I don't think that is particularly relevant to the question.

At some point, the program spits out open: No such file or directory

And then terminates.

The issue is I have no idea what file/directory the program is attempting to open.

It would be really great if there was some kind of program, a bit like ldd (but not quite) which could be run to show what files a binary executable is attempting to open.

Does such a thing exist? If not is there a way to obtain such information from the Linux kernel?

like image 879
FreelanceConsultant Avatar asked Jan 26 '26 15:01

FreelanceConsultant


2 Answers

man strace

In your case strace -e openat $YOURPOGRAM.

like image 77
datenwolf Avatar answered Jan 28 '26 06:01

datenwolf


There is a program called strace which can do this

strace -f -e open <exe>

See https://linux-audit.com/monitor-file-access-by-linux-processes/

like image 29
FreelanceConsultant Avatar answered Jan 28 '26 06:01

FreelanceConsultant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!