# Useful commands

> Useful commands and scripts that simplify technical tasks, like managing logs using Notepad++ with regex or automating DNS checks for domains.

- URL: https://www.allsubjectsmatter.nl/useful-commands/
- Language: en
- Published: 2023-09-11
- Updated: 2024-09-11
- Author: Remco Loup (https://www.allsubjectsmatter.nl/author/remco/)
- Tags: Under the hood
- Translation (nl, translated with AI): https://www.allsubjectsmatter.nl/nl/useful-commands/

## Notepad++ regexp

For example checking your php-fpm access/slow log file. Use mark in notepad++ to mark all lines that are slower then x/y.

```text
10000ms en trager 

^.*\s(\d{5,}\.\d{3}ms).*

5000ms en trager 

^.*\s(5\d{3}\.\d{2,}ms|\d{5,}\.\d{2,}ms).*
```

## DNS tools to automatically check the transfer of your DNS

```bash
sudo apt update
sudo apt install dnsutil

nano check_nameservers.sh
```

```bash
#!/bin/bash

DOMAIN="jouwdomein.com"
EXPECTED_NS1="ns1.cloudflare.com."
EXPECTED_NS2="ns2.cloudflare.com."

# Get the current nameservers
CURRENT_NS=$(dig NS $DOMAIN +short)

# Check if the current nameservers match the expected ones
if [[ $CURRENT_NS == *"$EXPECTED_NS1"* && $CURRENT_NS == *"$EXPECTED_NS2"* ]]; then
    echo "Nameservers are correctly set to Cloudflare."
else
    echo "Nameservers have not yet switched to Cloudflare."
fi
```

```bash
chmod +x check_nameservers.sh

watch -n 1 ./check_nameservers.sh
```
