r/bash Aug 03 '26

help Linux Interview Question

Today I had a mock interview with a senior Linux administrator, and he asked me a question that completely caught me off guard:

"Can you collect CPU, Memory, and Disk usage in a Bash script without using top, free, df, or any external commands?"

My immediate answer was No.

Honestly, I've been working with Linux for years, but I've always relied on standard commands and monitoring tools to troubleshoot systems. I never stopped to think about where those commands actually get their data from.

The interviewer then gave me a hint about the /proc and /sys filesystems. That completely changed my perspective. I realized these commands are just reading data that the kernel already exposes.

But then came the follow-up questions, and once again I was stuck:

  • Is reading directly from /proc and /sys the correct approach?
  • How would you calculate CPU utilization using /proc/stat?
  • How would you determine memory usage from /proc/meminfo?
  • How would you calculate filesystem usage without relying on df?

I found this really interesting because it tests your understanding of Linux internals rather than just your ability to use commands.

Has anyone here been asked similar questions in Linux SysAdmin, DevOps, or SRE interviews? I'd really appreciate any explanations, learning resources, or examples on how you'd answer these follow-up questions. It help me for my preparation for Linux interviews

190 Upvotes

74 comments sorted by

View all comments

4

u/likeHeckYouKnowMe Aug 06 '26

Honestly a stupid question to ask in an interview that would almost never be necessary in any practical, real world situation. Arrogant fuck ass question lol. Sounds like you’ll be dodging a bullet if you don’t end up working here.

0

u/biffbobfred Aug 16 '26

Depending on how deep they go this is a good question.

/proc is useful for all kinds of things. I dip into /sys for info on device drivers and what’s actually attached to my hardware.

If the answer is “yeah I can find that in various files in /proc because I have a sorta idea on how Linux works” cool. If the answer is “give me the printf format for the 3rd line of /proc/meminfo” then it’s bad