Basic Linux Dig commands

# dig google.com
# dig google.com +short

MX Record

# dig google.com MX

SOA Record for Domain

# dig google.com SOA

TTL

# dig google.com TTL

Get only Answers

# dig google.com +nocomments +noquestion +noauthority +noadditional +nostats

Get all DNS Records Types

# dig google.com ANY +noall +answer

DNS Reverse Look-up

dig -x 216.58.206.110 +short

Multiple DNS Records

# dig yahoo.com mx +noall +answer redhat.com ns +noall +answer

Create $HOME/.digrc to configure

Useful Linux CLI commands

hostname -I
[root@ftp ~]# groups
[root@ftp ~]# groups root
[root@ftp ~]# grep root /etc/group

Symbolic Links

Hard Link

ln /path/to/file /path/to/hardlink

Soft Link

ln -s /path/to/file /path/to/link

To Prevent Soft Link Overwrite

ln -s -b /path/to/file /path/to/link

List all symbolic links

ls -lt

Unlink a file

unlink linkfile
grep -r SSLCertificateFile /etc/httpd
httpd -S
openssl x509 -in server.crt -noout -subject

All users:

$ getent passwd

All groups:

$ getent group

All groups with a specific user:

$ getent group | grep user

Delete user

userdel user's username

Delete including users home directory

userdel -r user's username

Run shell script in Apache Airflow

Create the script.py inside the ../airflow/dags folder

from builtins import range
from datetime import timedelta

import airflow
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.dummy_operator import DummyOperator

args = {
    'owner': 'airflow',
    'start_date': airflow.utils.dates.days_ago(2),
}

dag = DAG(
    dag_id='dagid1',
    default_args=args,
    schedule_interval='0 0 * * *',
    dagrun_timeout=timedelta(minutes=60),
)

# [START howto_operator_bash]
create_command = """
echo 'Hello world';
echo 'Welcome';"""

run_this = BashOperator(
    task_id='taskid1',
    bash_command=create_command,
    dag=dag,
)

Enabling Modules for ReverseProxy

Update package lists:

apt-get update

Install Apache2 with mod_proxy:

sudo apt-get install libapache2-mod-proxy-html

Install libxml2 module:

apt-get install libxml2-dev

On /etc/apache2/apache2.conf add below code

LoadModule  proxy_module         /usr/lib/apache2/modules/mod_proxy.so
LoadModule  proxy_http_module    /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule  headers_module       /usr/lib/apache2/modules/mod_headers.so
LoadModule  deflate_module       /usr/lib/apache2/modules/mod_deflate.so
LoadFile    /usr/lib/x86_64-linux-gnu/libxml2.so

Add a sample reverse proxy configuration to the same file:

ProxyPass /subfolder http://127.0.0.1:9999/
ProxyPassReverse /subfolder http://127.0.0.1:9999/

Restart Apache2:

systemctl restart apache2

Apache port to subfolder reverse proxy

Config file location

RHEL based distributions

httpd.conf

Debian

sites-available/default

Updating & Installing

Update package lists:

apt-get update

Install Apache2 with mod_proxy:

sudo apt-get install libapache2-mod-proxy-html

Install libxml2 module:

apt-get install libxml2-dev

On /etc/apache2/apache2.conf add below code

LoadModule  proxy_module         /usr/lib/apache2/modules/mod_proxy.so
LoadModule  proxy_http_module    /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule  headers_module       /usr/lib/apache2/modules/mod_headers.so
LoadModule  deflate_module       /usr/lib/apache2/modules/mod_deflate.so
LoadFile    /usr/lib/x86_64-linux-gnu/libxml2.so

Method 1

Add a sample reverse proxy configuration to the same file /etc/apache2/apache2.conf

ProxyPass /subfolder http://127.0.0.1:9999/
ProxyPassReverse /subfolder http://127.0.0.1:9999/

Restart Apache2:

systemctl restart apache2

Method 2

Config file

<VirtualHost *:80>

        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin example@example.com

       <Location /app1>
             ProxyPass http://localhost:4000/
      </Location>

       <Location /app2>
             ProxyPass http://localhost:4001/
      </Location>

</VirtualHost>