Saturday, October 7, 2023

How To Install Squid To Configure Proxy Server On Rocky Linux 8.5

 in This Tutorial you will Learn " How To Install and configure Squid proxy server On Rocky Linux 8.5"

Squid is a web proxy application with a variety of configurations and uses. Squid has a large number of access controls and supports different protocols, such as HTTP, HTTPS, FTP, and SSL.

Rocky Linux is an open-source enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux®.
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      |    IP -192.168.1.20        |     Hostname - www.primaryhost.com
_________________________________________________________________________________________
cat /etc/system-release ; sestatus ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf -y install squid
gedit  /etc/squid/squid.conf &>/dev/null
acl my_localnet src 192.168.1.20/24                                                                        -line 29
http_access deny to_localhost                                                                                - 46
#http_access allow localnet                                                                                     -55
http_access allow my_localnet   # line 57 : add                                                     -57
request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
forwarded_for off
systemctl enable --now squid ; systemctl start squid
firewall-cmd --add-service=squid ; firewall-cmd --runtime-to-permanent
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Proxy Client -
cat /etc/system-release ; hostname -I ; dnf groupinstall "Development Tools" -y
192.168.1.20 3128  

curl -x http://192.168.1.20:3128 -I http://google.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Friday, July 21, 2023

How To Install and Configure Apache Spark on Oracle Linux 9

in This Tutorial you will Learn " How To Install and Configure Apache Spark on Oracle Linux 9"
Apache Spark is a multi-language engine for executing data engineering, data science, and machine learning on single-node machines or clusters.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y

sudo dnf update -y ; sudo yum install java-17-openjdk java-17-openjdk-devel -y
sudo dnf -y install wget curl -y
curl -L -b "oraclelicense=a" -O https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
sudo rpm -Uvh jdk-17_linux-x64_bin.rpm
java -version


sudo tee /etc/profile.d/java17.sh <<EOF
export JAVA_HOME=\$(dirname \$(dirname \$(readlink \$(readlink \$(which javac)))))
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar
EOF


source /etc/profile.d/java17.sh
echo $JAVA_HOME
echo $PATH
echo $CLASSPATH

curl -s https://api.github.com/repos/lampepfl/dotty/releases/latest| grep browser_download_url  | egrep '.tar.gz' | cut -d '"' -f 4 | wget -i -
tar -xf scala3-*.tar.gz
mv scala3-*/ /usr/local/share/scala


sudo tee  -a ~/.bashrc <<EOF
export SCALA_HOME=/usr/local/share/scala
export PATH=\$PATH:\$SCALA_HOME/bin
EOF


source ~/.bashrc
scala -version
cd ~/

Offcial web - https://spark.apache.org/downloads.html
curl -O https://dlcdn.apache.org/spark/spark-3.3.2/spark-3.3.2-bin-hadoop3.tgz
tar xvf spark-3.3.2-bin-hadoop3.tgz
mv spark-3.3.2-bin-hadoop3/ /usr/local/spark

sudo nano ~/.bashrc
#add this line
export PATH=$PATH:/usr/local/spark/bin

source ~/.bashrc


spark-shell
sc.version
spark.version
http://<server_ip_address>:4040
firewall-cmd --zone=public --add-port=4040/tcp --permanent ; firewall-cmd --reload
__________________________________________________________________________________________________________________________________

Monday, May 15, 2023

How To Install and Configure Apache Solr on Oracle Linux 9

 in This Tutorial you will Learn " How To Install and Configure Apache Solr on Oracle Linux 9"
Apache Solr is an open source search platform built upon a Java library called Lucene.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
sudo dnf update -y ; sudo dnf -y install curl wget

sudo dnf install lsof java-17-openjdk  java-17-openjdk-devel -y
java -version
sudo alternatives --config java
 java -version

sudo nano  /etc/profile
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk"
export PATH=$JAVA_HOME/bin:$PATH

source /etc/profile ; echo $JAVA_HOME

wget  https://www.apache.org/dyn/closer.lua/solr/solr/9.2.0/solr-9.2.0.tgz?action=download -O solr-9.2.0.tgz
tar -zxvf solr-9.2.0.tgz
cd /root/solr-9.2.0/bin
sudo ./install_solr_service.sh ~/solr-9.2.0.tgz

sudo service solr start ; sudo service solr status
sudo firewall-cmd  --permanent --add-port=8983/tcp ; sudo firewall-cmd --reload
localhost:8983
__________________________________________________________________________________________________________________________________


Tuesday, April 11, 2023

Ruby Hello World Example- How To Write and Execute Ruby Program on Ubuntu 20.04

 Ruby is an interpreted, high-level, general-purpose programming language which supports multiple programming paradigms.

apt update ; apt-get install ruby -y
whereis ruby
which ruby

nano helloworld.rb
#!/usr/bin/ruby

# Hello world ruby program

puts "Hello World!";

ruby helloworld.rb
( or )
chmod u+x helloworld.rb
./helloworld.rb

Executing Ruby one liner - ruby -e 'puts "Hello World!\n"'

_____________________________________________________________________________________

Tuesday, April 4, 2023

How To Install Flask with Gunicorn and Nginx on Oracle Linux 9

 in This Tutorial you will Learn " How To Install Flask with Gunicorn and Nginx on Oracle Linux 9"
Flask is a web application framework written in Python.
Gunicorn is a WSGI server.
NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
sudo dnf update ;  sudo dnf install epel-release -y
sudo dnf install python3-pip python3-devel gcc -y
dnf install nginx -y
nginx -version


dnf install --assumeyes python3-pip
pip3 install virtualenv
sudo update-crypto-policies --set LEGACY
sudo reboot
sudo mkdir /sample_project && cd /sample_project
sudo chmod 777 /sample_project
virtualenv projectenv
source projectenv/bin/activate

pip3 install gunicorn flask
pip install --upgrade pip
nano  /sample_project/helloworld.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return "<h1 style='color:red'>Hello, World!</h1>"

if __name__ == '__main__':
    app.run(host='0.0.0.0')


sudo firewall-cmd --add-port=5000/tcp --permanent ; sudo firewall-cmd --reload

python helloworld.py
http://127.0.0.1:5000


nano /sample_project/wsgi.py
from helloworld import app

if __name__ == "__main__":
    app.run()

firewall-cmd --add-port=8000/tcp --permanent ; firewall-cmd --reload
python helloworld.py
http://0.0.0.0:8000
deactivate
gunicorn --bind 0.0.0.0:8000 wsgi:app
_________________________________________________________________________________________________________________________________

Tuesday, March 28, 2023

How to install KVM on Oracle Linux 9

 in This Tutorial you will Learn " How to install KVM on Oracle Linux 9 "
Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux®. Specifically, KVM lets you turn Linux into a hypervisor that allows a host machine to run multiple, isolated virtual environments called guests or virtual machines (VMs).
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; dnf groupinstall "Development Tools" -y

lscpu | grep Virtualization
sudo dnf update ; sudo dnf install qemu-kvm qemu-img libvirt virt-manager virt-install virt-viewer libvirt-client
sudo systemctl start libvirtd ; sudo systemctl enable libvirtd ; sudo systemctl status libvirtd
sudo virt-manager
__________________________________________________________________________________________________________________________________

Thursday, March 23, 2023

How To Install Docker on Oracle Linux Server 9

 
Docker is a container engine that uses the Linux Kernel to create the containers on top of an operating system. Which is used to create, deploy and run the applications.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf update
sudo dnf install -y docker-ce docker-ce-cli containerd.io
docker --version
sudo systemctl enable docker ; sudo systemctl start docker ; sudo systemctl status docker
sudo usermod -aG docker yourname
id testbox
docker run hello-world
docker pull ubuntu
docker images
docker run -it ubuntu
__________________________________________________________________________________________________________________________________

Tuesday, March 21, 2023

Configure Storage Server with iSCSI.

 in This Tutorial you will Learn " How To Configure Storage Server with iSCSI On Oracle Linux 9
Configure Storage Server with iSCSI.
Storage server with iSCSI on network is called iSCSI Target, Client Host that connects to iSCSI Target is called iSCSI Initiator.
+----------------------+          |          +----------------------+
| [   iSCSI Target   ] |192.168.1.50 | 192.168.1.40| [ iSCSI Initiator  ] |
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
Configure iSCSI Target (Targetcli) -  

cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf -y install targetcli
mkdir /var/lib/iscsi_disks
targetcli
cd backstores/fileio
create disk01 /var/lib/iscsi_disks/disk01.img 10G
cd /iscsi
create iqn.2023-03.server.testbox:dlp.target01
cd iqn.2023-03.server.testbox:dlp.target01/tpg1/luns
create /backstores/fileio/disk01
cd ../acls
create iqn.2023-03.server.testbox:node01.initiator01
cd iqn.2023-03.server.testbox:node01.initiator01
set auth userid=username
set auth password=password
exit
ss -napt | grep 3260
systemctl enable target
firewall-cmd --add-service=iscsi-target ; firewall-cmd --runtime-to-permanent
__________________________________________________________________________________________________________________________________
Configure iSCSI Initiator  -
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf -y install iscsi-initiator-utils
nano /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2023-03.server.testbox:node01.initiator01

nano /etc/iscsi/iscsid.conf
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password

iscsiadm -m discovery -t sendtargets -p 192.168.1.50                   
iscsiadm -m node -o show
systemctl restart iscsid
iscsiadm -m node --login
iscsiadm -m session -o show
cat /proc/partitions

parted --script /dev/sdc "mklabel gpt"
parted --script /dev/sdc "mkpart primary 0% 100%"
mkfs.xfs -i size=1024 -s size=4096 /dev/sdc1
mount /dev/sdc1 /mnt
df -hT
__________________________________________________________________________________________________________________________________

Sunday, March 12, 2023

Configure NTP Server in Oracle Linux 9

 _______________________________________________________________________________________
NTP stands for Network Time Protocol.
It is used to synchronize the time on your Linux system with a centralized NTP server.
A local NTP server on the network can be synchronized with an external timing source to keep all the servers in your organization in-sync with an accurate time.
________________________________________________________________________________________
chronyc sources

dnf -y install chrony
nano  /etc/chrony.conf
change servers to synchronize (replace to your own timezone NTP server)
# need NTP server itself to sync time with other NTP server
#pool 2.centos.pool.ntp.org iburst
pool ntp.nict.jp iburst


# add network range to allow to receive time synchronization requests from NTP Clients
# specify your local network and so on
# if not specified, only localhost is allowed
allow 192.168.1.50/24

systemctl enable --now chronyd ; systemctl restart chronyd ; systemctl status chronyd
firewall-cmd --add-service=ntp ; firewall-cmd --runtime-to-permanent
chronyc sources

________________________________________________________________________________________

Friday, February 24, 2023

How To Install Squid Proxy Server with Squid Basic Authentication On Rocky Linux 8.5

in This Tutorial you will Learn " How To Install Squid Proxy Server with Squid Basic Authentication On Rocky Linux 8.5"

Squid is a web proxy application with a variety of configurations and uses. Squid has a large number of access controls and supports different protocols, such as HTTP, HTTPS, FTP, and SSL.

Rocky Linux is an open-source enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux®.
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      |    IP -192.168.1.20        |     Hostname - www.primaryhost.com
_________________________________________________________________________________________
cat /etc/system-release ; sestatus ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf -y install squid httpd-tools
gedit  /etc/squid/squid.conf &>/dev/null
acl my_localnet src 192.168.1.20/24                                                                         -29
http_access deny to_localhost                                                                                - 46
#http_access allow localnet                                                                                      -55
http_access allow my_localnet   # line 57 : add                                                       -57

request_header_access Referer deny all
request_header_access X-Forwarded-For deny all
request_header_access Via deny all
request_header_access Cache-Control deny all
forwarded_for off

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/.htpasswd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 5 hours
acl password proxy_auth REQUIRED
http_access allow password

systemctl enable --now squid ; systemctl start squid
firewall-cmd --add-service=squid ; firewall-cmd --runtime-to-permanent

htpasswd -c /etc/squid/.htpasswd rocky
systemctl daemon-reload ; systemctl restart squid.service
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Proxy Client -
cat /etc/system-release ; hostname -I ; dnf groupinstall "Development Tools" -y
192.168.1.20 3128  

curl -x http://192.168.1.20:3128 -I http://google.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Monday, February 13, 2023

How To Install Node.js npm ( Creating Sample app ) on Oracle Linux 9

 Node.js is a JavaScript runtime for server-side programming. It allows developers to create scalable backend functionality using JavaScript, a language many are already familiar with from browser-based web development.
NPM is an acronym for Node Package Manager, which is the default package manager for Node.JS and the richest repository for Node.JS packages.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; dnf groupinstall "Development Tools" -y
curl -sL https://rpm.nodesource.com/setup_16.x | bash -
dnf install nodejs -y
node --version ; npm --version

Creating Sample app on Node.js
nano myapp.js
const http = require('http');

const hostname = '0.0.0.0';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World, running on NodeJS 1x');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

node myapp.js
http://127.0.0.1:3000
_________________________________________________________________________________________________________________________________


Tuesday, February 7, 2023

How To Install Java JDK and JRE on Oracle Linux Server 9

 Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
OpenJDK or Oracle Java
OpenJDK is an open-source implementation of the Oracle Java SE platform edition. Oracle develops Oracle Java SE, whereas the OpenJDK is developed by Oracle Corporation, OpenJDK and Java Community, Red Hat, Azul Systems, IBM, Apple Inc, and SAP SE.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; dnf groupinstall "Development Tools" -y

Method - 1
dnf update
sudo dnf install java-11-openjdk java-11-openjdk-devel
java -version


Method - 2
Install Java OpenJDK 16 Manually from TAR.GZ File-
wget https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_linux-x64_bin.tar.gz
tar -xf openjdk-16.0.2_linux-x64_bin.tar.gz
mkdir -p /usr/lib/jvm ; mv jdk-16.0.2 /usr/lib/jvm

alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-16.0.2/bin/java" 0
alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-16.0.2/bin/javac" 0
alternatives --list
sudo alternatives --config java
sudo alternatives --config javac
java --version ; javac --version

Setup JAVA_HOME Environment Variable-
cd /etc/profile.d/ ; nano java.sh

JAVA_HOME="/usr/lib/jvm/jdk-16.0.2"
source /etc/profile.d/java.sh
echo $JAVA_HOME
__________________________________________________________________________________________________________________________________

Test Java Installation-
nano HelloWorld.java
public class helloworld {
  public static void main(String[] args) {
    System.out.println("Hello Java World from india!");
  }
}
java HelloWorld.java
__________________________________________________________________________________________________________________________________

Thursday, February 2, 2023

How To Install Apache, MariaDB, PHP (LAMP) on Oracle Linux 9

 LAMP stands for Linux, Apache, MySQL, and PHP. Together, they provide a proven set of software for delivering high-performance web applications.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; sestatus ; dnf groupinstall "Development Tools" -y
dnf update -y
dnf install epel-release -y
dnf install php php-cli php-fpm php-gd php-mysqlnd php-json php-curl php-intl php-pdo php-mbstring php-dom php-xml unzip httpd mariadb-server httpd -y
systemctl start httpd mariadb ; systemctl enable httpd mariadb
mysql_secure_installation

chown --recursive  apache:apache /var/www/html/ ; chmod -R 777 /var/www/html/
nano /etc/httpd/conf.d/testbox.conf
<VirtualHost *:80>
    ServerName server.testbox.com
    DocumentRoot /var/www/html/
    <Directory /var/www/html/public>
        AllowOverride All
        Require all granted
    </Directory>
    RewriteEngine on
    CustomLog /var/log/httpd/testbox.access.log common
    ErrorLog  /var/log/httpd/testbox.error.log

</VirtualHost>

apachectl configtest
nano /etc/hosts
192.168.1.50    server.testbox.com
systemctl restart httpd
__________________________________________________________________________________________________________________________________






Saturday, January 14, 2023

How To Install & Configure JupyterLab Environment On Rocky Linux 9

 JupyterLab is a next-generation web-based development environment for Project Jupyter. Project Jupyter was developed with the goal to develop open-source, open standards, and services for interactive computing across multiple programming languages. JupyterLab offers a flexible interface that allows developers to work with documents and activities such as Jupyter notebooks, text editors, terminals, and custom components in a flexible, integrated, and extensible manner. JupyterLab is the next generation of Jupyter Notebook and is supposed to eventually replace it. It supports over 40 programming languages, including R, Python, Scala, and Julia.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; dnf groupinstall "Development Tools" -y
dnf install wget curl nano unzip yum-utils -y
firewall-cmd --add-service=http --permanent ; firewall-cmd --add-service=https --permanent ; firewall-cmd --reload

nano /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

dnf install nginx -y
systemctl enable nginx --now ; systemctl status nginx

python -V
dnf install python3-pip -y
mkdir jupyterlab ; cd ~/jupyterlab
python3 -m venv --system-site-packages jupyterlab_env
source jupyterlab_env/bin/activate
pip install --upgrade pip
pip install jupyterlab

python3 -c "from jupyter_server.auth import passwd; print(passwd('YOUR_PASSWORD'))"
jupyter lab --generate-config
nano ~/.jupyter/jupyter_lab_config.py
c.ServerApp.allow_remote_access = True
c.ServerApp.password = 'YOUR_PASSWORD'
=8$jAJtckno+4fUhJ7nXWbR+w$kaMe/LaitfDs7vRKLEVRrb08WNiMZEAhXHGjfIbgtkU

firewall-cmd --add-port=8888/tcp --permanent ; firewall-cmd --reload
jupyter lab --ip 0.0.0.0 --allow-root
http://127.0.0.1:8888/
deactivate
__________________________________________________________________________________________________________________________________

Sunday, January 8, 2023

How To Install and Secure MongoDB on Oracle Linux Server 9

 MongoDB is an object-oriented, schema-less, NoSQL database server used in developing modern dynamic apps.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y

nano /etc/yum.repos.d/mongodb-org-4.4.repo     [ Latest Repo - https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/ ]
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

dnf install mongodb-org -y
systemctl start mongod ; systemctl enable mongod ; mongod --version

Configure MongoDB -
nano /etc/mongod.conf
security:
 authorization: enabled
systemctl restart mongod

Create an Admin User for MongoDB -
mongosh    Or mongosh "mongodb://localhost:27017"
use admin

db.createUser(
{
user: "mongoadmin",
pwd: passwordPrompt(),
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)

exit
systemctl restart mongod
mongosh --port 27017 --authenticationDatabase "admin" -u "mongoadmin" -p



Create a Database in MongoDB- --
use wpdb
db.person.insertOne(
  { "Anant" : "31",
   "Test" : "8",
   "Test Two" : "18"
  }
)
db
show collections
db.person.find()
use admin
db.getUsers()
__________________________________________________________________________________________________________________________________

rm -rf mongod.lock rm -rf /tmp/mongodb-27017.sock