CoderCo

Share this post

Tech Interview Series (DevOps) Part 1: Linux

blog.coderco.io

Discover more from CoderCo

A newsletter for Software, Systems and DevOps
Over 3,000 subscribers
Continue reading
Sign in

Tech Interview Series (DevOps) Part 1: Linux

A series of technical interview questions brought to you by DevOps Engineers.

Coder Co
Jul 19, 2023
6
Share this post

Tech Interview Series (DevOps) Part 1: Linux

blog.coderco.io
Share

Linux is popular among other individuals in Tech because (in simple terms) it is fast and powerful. If you want to be a well-grounded DevOps/Cloud Engineer or even a Linux System Admin, these are some of the most underrated commands yet so powerful — you can test your Linux skills here. I have lately been conducting many interviews and here are some or close to some of the interview questions I would ask an individual to test their Linux knowledge.

Image creds: omgubuntu.co.uk

Note: I aim to create an ongoing knowledge/technical articles — aiming to begin with questions on hands-on commands rather than open-ended questions. Also, note, there are multiple answers to these questions or methods to solve the problem.

Image creds: e-careers.com

List of Questions:

  1. How to get your current IP address?

  2. How to list all open ports of your machine?

  3. How to list all open files on your machine?

  4. How to list all the network connections?

  5. How to get the version of your kernel or which UNIX distribution you are using?

  6. How to check for free disk space?

  7. How to check the CPU usage of a specific process?

  8. How to check if a Linux service is running?

  9. How to mount a device on your machine?

  10. How can I find out more about a specific command in Linux?

Answers:

  1. How to get your current IP address?

  • Usually, you would use ifconfig , then scroll down through the output and get the inet, inet6 under eth0 for Ubuntu. (Since I’m on OSx, I would look for “en0”)

  • There is also another option you can use, the command is ip.
    ip addr show eth0 or ip addr show en0

Note: The IP command is not available on all machines.

Running the ifconfig command
ifconfig output (scrolled down)

2. How to list all open ports of your machine?

  • To check all open ports on your machine, use the netstat command. The output can be quite long so in order to limit this, we can use a flag, to list the UDP and TCP ports only.

  • For Ubuntu & other Linux distros:netstat-tulpn

  • For other UNIX distros (macOS): netstat -anvp TCP | grep “LISTEN”

Listing all open ports of my Mac

3. How to list all open files (for a process) on your machine?

  • This is quite a simple one but in order to see which files & directories are open, you can run lsof . Running this command will list many open files/directories

  • To be more specific, you may use these flags:

Find processes by name:
lsof -c processsname

finding the open files for “chrome”

Find processes by PID:
lsof -p 819

finding the process by PID

4. How to list all the network connections on your machine?

  • To list all the network connections of your machine, you can use the netstat link command.

5. How to get the version of your kernel or which UNIX distribution you are using?

  • To get the kernel version, you can simply use the uname -a . This will display the details of your OS

running the uname -a command to obtain OS detail
  • Another open-source tool you can use is neofetch

6. How to check for free disk space?

  • You can check all disk space usage using the df command. So that it’se easier to read, you may add the flag -h.

  • So you would run df -h

checking for free disk space — using the -h flag to make it more human-readable

7. How to check the CPU usage of a specific process?

  • you may use the ps aux command to list all the processes — to look for something more specific, pipe it with the grep command. Like so:
    ps aux | grep “process_name”

  • Alternatively, you can use the command topfor a nicer view.

8. How to check if a Linux service is running?

  • Most Linux distros would use an old command which is systemd

  • Another option would be the systemctl command, which is relatively newer.

  • You may use it with these flags: systemctl <option> <service_name>

9. How to mount a device on your machine? & list all the mounts on your device?

  • To list all the mounts on your machine, you would run ls /mnt

  • To mount a device, you may use the mount command

  • For example: mount /dev/sda2 /mnt — where /dev/sda2 would be the device

10. How can I find out more about a specific command in Linux?

  • A very crucial command that is underestimated as not all of us will know what every single Linux command out there can do.

  • So to save yourself the hassle, run man <command_name>

running the “man grep” command — for more details on what “grep” does

Some of these commands are really handy, not just in interviews, but also in real-life debugging scenarios. I really hope you have learnt more about these Linux commands and how powerful they can be. Please do share and support to help me write more articles on this knowledge series.

Until then, keep learning! 😀

6
Share this post

Tech Interview Series (DevOps) Part 1: Linux

blog.coderco.io
Share
Comments
Top
New
Community

No posts

Ready for more?

© 2023 CoderCo
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing