List of opened files Linux

Hello guys,

is there any option to list all opened files in Linux without using lsof?

Thank you very much!

Regards

Jiri
LVL 1
Jiří BenešIT SupportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Seth SimmonsSr. Systems AdministratorCommented:
you could try by process

https://www.cyberciti.biz/faq/howto-linux-get-list-of-open-files/

what is wrong with lsof?
0
Jiří BenešIT SupportAuthor Commented:
Well when we use lsof it gives back a lot of duplicities we would like to get only list opened files
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Use lsof with grep or pass lsof options to prune output.

You can dig around in /proc + this is how lsof works, so you'll end up trying to duplicate a good big of lsof code.

Simple solution...

lsof | egrep " REG "

Open in new window


Add additional grep commands in your pipeline to prune additional data, till you have exactly what you're looking for.

You can also did into lsof + use lsof syntax (options) to do the same thing + I find lsof + grep pipelines way easier to read + understand.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

arnoldCommented:
to see all files, one have to have elevated/root rights.
lsof /

the question does not reflect that everything on a linux system is seen as a "file"
an open socket is a "file" reference.
A definition of types of flies you are interested in seeing as David and Seth referenced.

Commonly, a question such as this suggests there is a discrepancy of drive space issues.
df -k points that a partion has all its space consumed (usage 100%)
while du -ks  on that partition reflects 40% of available space.
using lsof on the partiton will reveal the discrepancy as a running process that has a file handle in that location, but the file is no longer reflected within the file system listing, i.e. a logrotation, or other process was not set right, deleting the file entry without the notification to the process of the change. A low data process could take years to have this issue/impact show up.

lsof can run on per partition basis, per process basis, it all depends on what it is you are looking to achieve.

Qualifying your need might offer open opportunities one might not have considered before.
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Arnold's comment is correct. If you're logged in as root at the machine level, you'll (for the most part) see all files + all files in all containers.

If you're inside a container, you'll only see files owned by that container.

Same with a non-root user (machine or container level).

You will only see files you have privilege to see.

Also, as Arnold suggested, provide the output of lsof + explain what's missing or how you'd like the output modified to be more useful + likely someone can assist.
0
Gerwin Jansen, EE MVETopic Advisor Commented:
You can filter what you see with lsof by using -c to specify a process name. You cannot filter for REGular files using an option, but you can filter using awk for example:

lsof -c bash | awk ' $5 == "REG" { print } '

This would show you all files opened by bash shell(s), filtering the output on the fifth column where it has "REG".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.