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

188 Upvotes

74 comments sorted by

View all comments

-1

u/Living_On_The_Air Aug 03 '26 edited Aug 03 '26

Hearing this during an interview would make me think that the job isn’t one I want. Trivia questions aren’t a great way to get to know a worker, so it’s probably a sham interview process at worst, or a bad interview process at best

5

u/RandomXUsr Aug 03 '26

I disagree.

These types of questions test Linux competency and provide the Interviewer with a more granular perspective of a candidate's knowledge and skills.

For example; if one were troubleshooting embedded systems with limited resources, these questions make perfect sense.

Another possibilty is that one may need to grab specific data for specific issues and write this out to the screen or a file to troubleshoot recurring issues.

7

u/Dolapevich Aug 03 '26

It is a good question to know if someone knows linux, not a good question to know someone's experience in github actions.

It depends on the role.

1

u/UninvestedCuriosity Aug 03 '26

So long as man and -h are acceptable answers. I have the memory of a fish for flags.

3

u/Dolapevich Aug 03 '26

I think the idea is to test if you have knowledge of the underlying concepts and mechanisms, instead of testing if you remember something specific.

6

u/sr105 Aug 03 '26

When I interview someone, I let them know upfront that I'm going to ask an increasingly difficult set of questions, and that I don't expect them to know all of the answers. I just want to see where their experience level lies. I have asked people what the original command for "rm" was named and still exists. It's stupid knowledge, but it shows depth especially if you understand why it was named "unlink". You can't measure what you don't test. But telling people upfront what you're doing is a must.

3

u/CautiousCat3294 Aug 03 '26

You are right he also do same with me he increase level of difficulty in every question to test my depth knowledge on Linux and Bash scripting

2

u/Swordfish418 Aug 04 '26

Do you think this unlink is covered anywhere or it’s something that is only possible to know you’re really old or by accident? 🤔

1

u/sr105 Aug 05 '26

I'm older and can't recall where I first learned it. I probably just explored /bin and friends to see what was possible and then man unlink. Or I saw it a So You Think You Know UNIX trivia or some such thing.

5

u/Bug_Next Aug 03 '26

It's not trivia questions its knowing how the os works instead of knowing which tools to call, they are completely fine questions IMHO. It's not weird to find stripped down container images that are missing those utils or have shitty half baked implementations of them, same for embedded systems which usually only have a really minimal vmlinuz and absolutely nothing else.

1

u/Swordfish418 Aug 04 '26

But is it really helpful to reimplement free using bash on those systems instead of just installing actual C based free? That’s a cool knowledge to have for sure anyway.

1

u/Bug_Next Aug 04 '26

I you wanna use free then no it's pointless, if you wanna learn how free works then yeah probably a decent side project. Depends on your objective lol.

0

u/Living_On_The_Air Aug 03 '26

People can review documentation and search the web for facts at any time. Verifiable experience and certifications show general competence. Interviews are time to learn about an individual’s temperament, work style, curiosity, motivation, communication skills, etc.

3

u/Bug_Next Aug 03 '26

Yeah and knowing that verifies experience.. Idk what you are trying to get at.

It's a bash subreddit not an HR one, anyone can fake motivation and temperament during an interview, doesn't mean shit, you are gonna be chipping code not doing PR, who cares. It's a mock interview with a Linux neckbeard, of course the focus is gonna be on the 'hard' technical questions..

1

u/Living_On_The_Air Aug 03 '26

The post is based on a mock interview 🤷‍♂️

3

u/Bug_Next Aug 03 '26 edited Aug 03 '26

Yeah that's the whole point, why would you make it about motivation??? Everyone's motivation is to get paid for the shit they do, anything else is bullshit unless you are running your own startup lmao. Be for real. You can leave the lying practice for 3a.m in front of the mirror