Wednesday, August 31, 2022

How to install and run MongoDB GUI on Ubuntu 20.04

The following are the different ways to install mongo-gui.


From npm:


Install the module globally using the command :

npm install -g mongo-gui

Then use the command to run the application

mongo-gui 


From github:


First of all, clone the mongo-gui repository using the command git clone https://github.com/arunbandari/mongo-gui or download the zip file from here.

Change the directory to mongo-gui 

cd mongo-gui

Install all the dependencies npm install

Start the application using either 

npm start or node server.js 


Note: Node.js must be installed on your machine to run this application


From Docker Hub:


Docker compose

version: '3'

services:

  mongo-gui:

    container_name: "mongo-gui"

    image: ugleiton/mongo-gui

    restart: always

    ports:

      - "4321:4321"


    environment:

      - MONGO_URL=mongodb://localhost:27017


Mongo GUI Usage


The commands mongo-gui and npm start or node server.js start the application with the following configuaration:


URL (-u): mongodb://localhost:27017

PORT (-p): 4321

and the application will be accesible at http://localhost:4321

To connect to any other mongodb instance, pass mongo connection string as an argument, eg:


Installed via npm: mongo-gui -u mongodb+srv://<username>:<password>@host/<dbnames>?retryWrites=true&w=majority'


Installed via github: (npm start --/node server.js) -u mongodb+srv://<username>:<password>@host/<dbnames>?retryWrites=true&w=majority'


Available options:


-u: url, mongo-gui tries to connect to this mongodb instance

-p: port, mongo-gui listens on this port

Tuesday, August 30, 2022

Failed to start mongod.service: Unit mongod.service not found Solved !

When I started MongoDB got an error as:

"Failed to start mongod.service: Unit mongod.service not found."


Check port and configuration

sudo nano /etc/mongod.conf

Solution:
sudo systemctl unmask mongod

and re-run

sudo service mongod start


sudo service mongod status

sudo systemctl enable mongod

sudo service mongod restart

service mongod stop
#dont start mongod…instead…

systemctl start mongod
#then mongo command

#then
mongo

How to install composer and use it on Ubuntu

sudo apt update
sudo apt install wget php-cli php-zip unzip
wget -O composer-setup.php https://getcomposer.org/installer
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
sudo php composer-setup.php --install-dir=/path/to/project
sudo composer self-update  
composer require nesbot/carbon

Install multiple PHP version on Ubuntu for Virtualmin

 Enable ondrej/php repository

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && apt-get update
Install additional PHP packages
apt-get install php*-{cgi,cli,fpm,pdo,gd,mbstring,mysqlnd,opcache,xml,zip} 

Note: php* should be replaced with a specific PHP version, i.e. php7.4, unless you really need to install all available additional PHP versions.

Configuring the second PHP Version in Virtualmin

Once you have completed the installation of a second PHP version on your server, you can verify that Virtualmin sees it by logging into Virtualmin, and clicking System Settings → Re-Check Config. You should see something like this:
The following PHP execution modes are available : fpm
The following PHP-FPM versions are available : 8.0.13 (php-fpm) 7.4.30 (php74-php-fpm) 8.2.0 (php82-php-fpm) 

You can configure which one is the default PHP version used on new Virtual Servers. The default is to use the newest available. You can change that default in System Settings → Server Templates → Default → PHP Options page.

Configuring Individual Virtual Servers

You can configure the PHP version being used for a specific Virtual Server by selecting Server Configuration → PHP Options.


Source: https://www.virtualmin.com/documentation/web/multiplephp/


How to Install Apache2 to make Web Server on Ubuntu 20.04

 sudo apt update

sudo apt install apache2

sudo systemctl is-active apache2

sudo systemctl is-enabled apache2

sudo systemctl status apache2

sudo systemctl stop apache2      #stop apache2

sudo systemctl start apache2     #start apache2

sudo systemctl restart apache2   #restart apache2

sudo systemctl reload apache2    #reload apache2

sudo systemctl disable apache2   #disable apache2

sudo systemctl enable apache2    #enable apache2

ls /etc/apache2/*

sudo vim /etc/apache2/apache2.conf 

ServerName webserver1.tecmint.com

sudo apache2ctl configtest

sudo systemctl restart apache2

sudo systemctl status apache2

sudo ufw allow http

sudo ufw allow https

sudo ufw reload

OR

sudo ufw allow 80/tcp

sudo ufw allow 443/tcp

sudo ufw reload


ls /var/www/html/

sudo mkdir -p /var/www/html/olineit.info

sudo chown www-data:www-data -R /var/www/html/olineit.info

sudo chmod 775 -R /var/www/html/olineit.info

sudo vim /var/www/html/olineit.info/index.html

sudo vim /etc/apache2/sites-available/olineit.info.conf

sudo a2ensite olineit.info.conf

sudo systemctl reload apache2


Installing Virtualmin after webmin


Once Webmin is operational you can download and install the Virtualmin modules and theme in either RPM format (for RPM-based Linux distributions), deb format (for deb-based Linux distributions), or wbm format (for any other UNIX or Linux system), and install them using the Webmin Modules module found in Webmin:Webmin Configuration.

https://software.virtualmin.com/vm/6/gpl/wbm/

virtual-server-7.1.gpl-1.wbm.gz

install any MTA like Postfix, Sendmail or Qmail

How to install and use multiple php versions on ubuntu 22.04

sudo apt-get update

sudo apt-get upgrade 


sudo apt-get install php7.0 php7.0-fpm

sudo apt-get install php7.0-mysql php7.0-mbstring php7.0-xml php7.0-gd php7.0-curl


sudo apt-get install php7.1 php7.1-fpm

sudo apt-get install php7.1-mysql php7.1-mbstring php7.1-xml php7.1-gd php7.1-curl


Monday, August 29, 2022

How to install NGINX and configure on Ubuntu 20.04

sudo apt-get update

sudo apt upgrade

sudo apt install nginx

sudo systemctl status nginx

sudo ufw allow http

sudo ufw reload


sudo systemctl status nginx

sudo systemctl stop nginx

sudo systemctl start nginx


sudo systemctl disable nginx

sudo systemctl enable nginx

sudo systemctl restart nginx

sudo systemctl reload nginx



sudo unlink /etc/nginx/sites-enabled/default

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl restart nginx

sudo mkdir /var/www/example.com

How to unzip tar.gz file in linux

sudo apt-get install zip

unzip file.zip -d destination_folder

unzip file.zip

tar -xf archive.tar.gz

Sunday, August 28, 2022

How To Set Up Nginx Virtual Hosts Server Blocks on Ubuntu 20.04

Follow the steps to Set Up Nginx Virtual Hosts Server Blocks on Ubuntu 20.04:


 1. Create New Document Root Directory


sudo mkdir -p /var/www/yourdomain.com/public

sudo chown -R $USER:$USER /var/www/yourdomain.com/public

sudo chmod -R 755 /var/www


2. Creating Pages

nano /var/www/yourdomain.com/public/index.html



3.Creating new site available or server block copied from existing/default domain:

sudo cp /etc/nginx/sites-available/defaultdomain.com /etc/nginx/sites-available/yourdomain.com


4.  Enabling  Server Blocks and Restart Nginx

sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/


5. Restart Nginx

sudo nginx -t

sudo systemctl restart nginx


6. Modify Local hosts file (optional)

sudo nano /etc/hosts


203.0.113.5 yourdomain.com www.yourdomain.com


7. Test website

https://easy2move.fr


Saturday, August 27, 2022

How to Enable SSH Keys Authentication

 cd /etc/ssh

sudo nano sshd_config

Uncomment the following lines

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

Save & exit.


You can follow this topic also:

Fix ssh port 22 connection refused ubuntu

How to create authorized_keys file in linux with ssh folder

How to create authorized_keys file in linux with ssh folder

 ls -a | grep .ssh

mkdir ~/.ssh/

touch ~/.ssh/authorized_keys

sudo nano ~/.ssh/authorized_keys

Fix ssh port 22 connection refused ubuntu

sudo apt install openssh-server

sudo apt list --installed | grep openssh-server

sudo service ssh status

sudo service ssh start

sudo service ssh restart

ssh [username]@[remoteserver IP or hostname]

ssh -p [port_number] [username]@[ip_address]

sudo netstat -ltnp | grep sshd

ssh -p [2244] [username]@[ip_address]

sudo ufw allow port /tcp

sudo ufw allow 2244/tcp

sudo ufw reload

sudo ufw status

sudo apt install arping

ping <ip-address>

Thursday, August 25, 2022

How to add public key to authorized_keys ec2 instance Ubunutu Linux

 Step 1: Login into you AWS account and go to EC2 instances

Step 2: Select your instance and click connect

Step 2: Then click connect button at the bottom right corner

Step 3: Now a new tab will be opened with console as follows

Step 4: Copy your SSH public key then add the key to the following key file

Use this command in Mac/Windows powershell to copy your public key: pbcopy ~/.ssh/id_rsa.pub

nano ~/.ssh/authorized_keys

Step 5: Save and reboot then try to connect again with device from which public key generated.

Tuesday, August 23, 2022

Fix laravel SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock


Cause:

his happens when two processes or more are trying to write to the same database table at the exact same time. Solutions can be complicated. Deadlocks are usually an application problem most of the time can either be solved by:
1. changing the logic of your code (e.g. use transactions) or
2. retrying the operation

      php artisan route:list
      php artisan view:clear
      php artisan cache:clear

Thursday, August 18, 2022

How to add SSH Public key to an existing Droplet or VM?

First copy your Public key using the following command: 

cat ~/.ssh/id_rsa.pub

or 

pbcopy ~/.ssh/id_rsa.pub

Now login into your Droplet or VM and open the following file then paste your public key into authorized_keys file.

nano ~/.ssh/authorized_keys


Save the file and try to login from your local terminal.

Monday, August 15, 2022

Fix Adding new SSL virtual website .. .. certificate authority file is not valid : Data does not start with line -----BEGIN CERTIFICATE-- in virtualmin


Open the file at /etc/webmin/virtual-server/domains/13694005276497

Delete including 4 lines pointing to the 4 certificate files: ssl.cert, ssl.combined, ssl.everything & ssl.key

Then re-add the ssl.

Friday, August 12, 2022

How to generate SSH keys in Windows PowerShell

 Open your PowerShell and follow the steps:

ssh

ssh-keygen -b 4096


C:\Users\WINUSER/.ssh/id_rsa.pub


notepad C:\Users\WINUSER/.ssh/id_rsa.pub

Wednesday, August 10, 2022

How to check TCP, UDP Domain Socket using NetCat

 Install the netcat Using the fllowing command:

$ yum install nc      [On CentOS/RHEL]

$ dnf install nc      [On Fedora 22+ and RHEL 8]

$ sudo apt-get install Netcat      [On Debian/Ubuntu]


NetCat commands:

$ nc -v -w 2 z 192.168.56.1 22     #scan a single port

OR

$ nc -v -w 2 z 192.168.56.1 22 80  #scan multiple ports

OR

$ nc -v -w 2 z 192.168.56.1 20-25  #scan range of ports

Saturday, August 6, 2022

How to hide IP in header from Postal MTA

Remove  text where need using the following file in postalMTA.

For SMTP Server:

lib/postal/smtp_server/client.rb

@receiving_headers = true
received_header_content = "from #{@helo_name} (#{@hostname} [#{@ip_address}]) by #{Postal.config.dns.smtp_server_hostname} with SMTP;

For HTTP:

app/models/outgoing_message_prototype.rb

mail.header['Received'] = "from #{@source_type} (#{self.resolved_hostname} [#{@ip}]) by Postal with HTTP; #{Time.now.utc.rfc2822.to_s}"
mail.message_id = "<#{@message_id}>"

How to view saved password in Outlook 2003, 2007, 2010, 2013, 2016, 2019


Use Unmask Password Tool to reveal hidden behind the asterisk icon.

Windows:

Download from Google Drive

Download from CNET



Mac:


To see if the password is available, first open the “Keychain Access” program on your Mac (click the Go menu in the Finder and choose Applications, then open Utilities and Keychain Access).

Thursday, August 4, 2022

Office 2019 Activation without Product Key using CMD

Put the following code in a TXT file and save as "file.cmd" then run the cmd file as administrator. 

@echo off

title Activate Microsoft Office 2019 ALL versions for FREE!&cls&echo ============================================================================&echo #Project: Activating Microsoft software products for FREE without software&echo ============================================================================&echo.&echo #Supported products:&echo - Microsoft Office Standard 2019&echo - Microsoft Office Professional Plus 2019&echo.&echo.&(if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16")&(if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16")&(for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&(for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&echo.&echo ============================================================================&echo Activating your Office...&cscript //nologo ospp.vbs /unpkey:6MWKP >nul&cscript //nologo ospp.vbs /inpkey:NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP >nul&set i=1

:server

if %i%==1 set KMS_Sev=kms7.MSGuides.com

if %i%==2 set KMS_Sev=kms8.MSGuides.com

if %i%==3 set KMS_Sev=kms9.MSGuides.com

if %i%==4 goto notsupported

cscript //nologo ospp.vbs /sethst:%KMS_Sev% >nul&echo ============================================================================&echo.&echo.

cscript //nologo ospp.vbs /act | find /i "successful" && (echo.&echo ============================================================================&echo.&echo #My official blog: MSGuides.com&echo.&echo #How it works: bit.ly/kms-server&echo.&echo #Please feel free to contact me at msguides.com@gmail.com if you have any questions or concerns.&echo.&echo #Please consider supporting this project: donate.msguides.com&echo #Your support is helping me keep my servers running everyday!&echo.&echo ============================================================================&choice /n /c YN /m "Would you like to visit my blog [Y,N]?" & if errorlevel 2 exit) || (echo The connection to my KMS server failed! Trying to connect to another one... & echo Please wait... & echo. & echo. & set /a i+=1 & goto server)

explorer "http://MSGuides.com"&goto halt

:notsupported

echo.&echo ============================================================================&echo Sorry! Your version is not supported.&echo Please try installing the latest version here: bit.ly/aiomsp

:halt

pause >nul

Extract Domain from email in Excel or Google sheet

  =TEXTAFTER( A2 , "@") or, =MID(A1, FIND("@", A1) + 1, LEN(A1) - FIND("@", A1))