Category: Linux

  • Get timing details with curl command

    It is sometimes useful to get the timing details of a curl request, for analysis, investigation or just monitoring. Thanks to curl implementation, there’s an easy way to get timing details. This can be done with two ways: a formatting file or directly on command line. We will explore both solutions below. Formatting file: You’ll…

  • Display log file with timestamp in human-readable format

    By default, some logs (like squid logs) will be recorded with unix timestamp, stored as <unixtimestamp>.<centisecond> which are hard to read for analysis. You would have for example this kind of logs: In order to display them in human readable format, you can just use that simple command: You will then have such result:

  • Check expiration dates for local certificates

    This script does allow a quick check of the local certificates, in order to make sure none of them is expired: The output will look like:

  • Find parent PID of a running process in Linux

    When a process is starting sub-processes on a linux system, you would have to stop every single child processes in order to stop them all. Instead of that, you can easily kill the parent process so it can stop spawning new process. You can find the parent process with the following command (replace the CHILDPID…

  • Kill all sub-processes of a bash script with SIGINT (CTRL-C)

    If you have a bash script running with a very long loop (or infinite one) and starting multiple background processes, you will notice that when you stop the main process, all the child processes will continue to live until you restart the machine or you kill them one by one. So that you can easily…

  • Install pip packages offline

    Sometimes you might need to download some pip packages offline on a device with no Internet access. This is entirely feasible through multiple ways. Install a single package: You first need to download that package on a device with Internet access (using pip package as an example) Then you push that file to the device…

  • Issue with sudo – sudo:auth could not identify password for [user]

    If you get the following error when trying to execute a sudo command, despite the fact that you configured your sudoers or sudoers.d config file properly: Then, you might need to have a look at the PAM configuration on your device.Ensure that you have this line enabled in your /etc/pam.d/sudo file: Once you changed this…

  • Use rsyslog omprog with a Python script

    If you want to filter some specific logs and redirect them to another server or to another file, you can use the module provided with rsyslog called “omprog”. Thanks to that module, you can just ask rsyslog to execute a script on every logs you have from a specific application and process it with your…

  • Disable FIPS mode on CentOS 7

    FIPS (Federal Information Processing Standard) can be enabled (by default or not) on linux kernels to enable the FIPS kernel cryptographic features.But in some case, this can also lead to some issues with openssl, or any cryptographic tool that you can use within any code. You can check if FIPS is enabled with that command:…

  • Add timestamp on each line of bash output

    When analyzing the output of a bash script, it can be useful to prepend timestamp before each line to see how long it’s taking to do a specific action. For this, you can use the ‘ts‘ command: # echo -e “this\nis\na\ntest” | ts ‘[%Y-%m-%d %H:%M:%S]’ [2019-05-13 09:14:28] this [2019-05-13 09:14:28] is [2019-05-13 09:14:28] a [2019-05-13…