Avatar

Links

  • Recently came across a scenario, where curl was able to connect to localhost but not 127.0.0.1. When I tried curl 127.0.0.1:80, it just hung there. While curl localhost:80 returns the expected output.

    My first instinct was to check apache config to see if it was only serving to localhost and not the IP address. But that seemed unlikely because /etc/hosts had the correct entry.

    My next big clue was when I tried curl -v localhost:80, this was the output -

  • Scenario: You SSH into an Ubuntu server. How do you know if you just logged in inside a docker container, or just a regular VM?

    Turns out there are no straight answers.

    Docker provides virtualization based on Linux Containers (LXC). LXC is a technology to provide operating system virtualization for processes on Linux. This means, that processes can be executed in isolation without starting a real and heavy virtual machine. All processes will be executed on the same Linux kernel, but will still have their own namespaces, users and file system.

  • In the previous post we figured out how to find the process which is writing an open file. And we also saw that we can kill the process and it’ll stop it from writing to that file. But what if we are not supposed to kill the process? But we still need to close the file.

    First we need to figure out the file descriptor for that file for that process.

  • Scenario: Imagine you login to a server and you find that the disk is filling up rapidly. Either by using df -h or du -h -d1 /<dir> or getting errors like no more disk space left etc. How do you figure out who is filling up the file?

    Solution: Let’s say the file in question is /var/log/badd.log and it’s rapidly filling up.

    First step is to use lsof to figure out which process has that file open. To write to a file, any process has to first open that file. So the process will show up in lsof, which is a program to “list open files”. With any luck your output will show up like this -