Installing and securing Mongo on CentOS 7

September 8th, 2021

vi /etc/security/limits.d/20-nproc.conf

mongod soft nproc 32000


vi /etc/yum.repos.d/mongodb-org.repo

[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc


yum repolist
yum install mongodb-org
systemctl start mongod


mongosh

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


vi /etc/mongod.conf


security:
authorization: enabled


systemctl restart mongod

mongosh
use admin
db.auth(‘dba’,promptPassword())

VM migration script

April 3rd, 2021

#!/bin/sh

cd /vmfs/volumes/datastore1
scp -r root@192.168.100.27:/vmfs/volumes/datastore1/$1 .
cd $1
vmkfstools -i $1.vmdk -d thin $1-thin.vmdk
rm -f $1.vmdk $1-flat.vmdk
vmkfstools -E $1-thin.vmdk $1.vmdk
vmkfstools -K $1.vmdk
vim-cmd solo/registervm /vmfs/volumes/datastore1/$1/$1.vmx
cd

Adding Timestamp in vmstat / iostat CLI output

June 12th, 2020

vmstat 1 | awk ‘{now=strftime(“%Y-%m-%d %T “); print now $0}’
iostat -x 1 | awk ‘{now=strftime(“%Y-%m-%d %T “); print now $0}’

Enable Wifi on Setup

April 6th, 2020

Generate Encrypted WIFI Password:

Execute

wpa_passphrase HUAWEI-0969-2.4G 00666507

network={
ssid=”HUAWEI-0969-2.4G”
#psk=”00666507″
psk=fdc5d5d87c4bd4b28e46d0c783cf6cc674549ca43ff242243d33dfe60c8895ec
}

copy the network settings and put it in the file /boot/wpa_supplicant.conf

vi /boot/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=HK

network={
ssid=”HUAWEI-0969-2.4G”
#psk=”00666507″
psk=fdc5d5d87c4bd4b28e46d0c783cf6cc674549ca43ff242243d33dfe60c8895ec
}

Enable SSH for Raspberry Pi

March 2nd, 2020

create a blank file ssh under /boot/ partition

touch /boot/ssh

Installing brew on Mac

February 26th, 2020

Installing brew

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Removing brew

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)”

TCPDUMP request and response Header

February 6th, 2020

tcpdump -A -s 10240 ‘tcp port 80 and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0)’ | egrep –line-buffered “^……..(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: ” | sed -r ‘s/^……..(GET |HTTP\/|POST |HEAD )/\n\1/g’

Install Drupal Using composer and drush

January 15th, 2020

sudo su –
yum -y install git
su – www

composer global require zaporylie/composer-drupal-optimizations
composer global require hirak/prestissimo

composer global require drush/drush
echo ‘export PATH=”$HOME/.composer/vendor/bin:$PATH”‘ >> ~/.bashrc
source ~/.bashrc

composer create-project drupal/drupal public_html
cd public_html
drush site:install

CentOS 8 firewall command equivalent

January 14th, 2020

iptables -nL = nft list ruleset
service iptables restart = /bin/firewall-cmd –reload

Updating cron job in QNAP

January 8th, 2020

to run cronjob inside a qnap – you will need to updating the following file.

vi /etc/config/crontab

If you update using crontab -e, the changes won’t be survive after a reboot.