Wednesday, April 15, 2020

How to fill memory on Linux

The easy way to fill memory is to  fill /dev/shm via dd command

1) Fill shm with random data
while true ; do dd if=/dev/zero of=/dev/shm/fill bs=1k count=4024k; sleep 2; done
2) Monitor memory usig free command and you should see memory usage under "used" and "free" changing
while true ; do free -m ;  sleep 2;done
# free -m
              total        used        free      shared  buff/cache   available
Mem:           7822        1937         164        3920        5720        1650
Swap:          3583           0        3583

Monday, March 30, 2020

Grant command changed in MySQL 8

The below command no longer working in MySQL 8.x

msql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost" IDENTIFIED BY "password";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY "password"' at line 1

It seems that MySQL no longer support the one liner version of grant command, it's now requires to create user first and the grant the privileges


mySQL> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'word123';
Query OK, 0 rows affected (0.01 sec)


mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost";

Wednesday, March 25, 2020

Duck DNS free dynamic DNS for your hosts

A few days back I was searching for free DNS server to use for my dynamic IP host

Found DuckDNS from its web it says ...
"Duck DNS is a free service which will point a DNS (sub domains of duckdns.org) to an IP of your choice"

Below are the steps to configure and use DuckDNS service

1) First create a log in the duckdns, by choosing sign in with Google , twitter etc
2) Once logged in take note of the "Token" which will be on the first page
3) Create a subdomain by typing the name in the sub domain box and click "add domain" button.  This would be your DNS hostname in the form of yourdomain.duckdns.org
4) Follow the instructions under the "install" tab to configure duckdns on your dynamic IP host, below is the steps for Linux host with cron installed already

- mkdir duckdns
- cd duckdns
- Now copy this text and put it into the script
vi duck.sh
echo url="https://www.duckdns.org/update?domains=exampledomain&token=a7c4d0ad-114e-40ef-ba1d-d217904a50f2&ip=" | curl -k -o /root/duckdns/duck.log -K -

Replace
exampledomain: with your subdomain name created on duckdns site
a7c4d0ad-114e-40ef-ba1d-d217904a50f2&ip= : with your token from the duckdns site

- Make the script executable
chmod 700 duck.sh
- Next, create a crontab entry for the script to run every 5 minutes
*/5 * * * * /root/duckdns/duck.sh >/dev/null 2>&1

- Test the script
./duck.sh

This should simply return to a prompt, we can also see if the last attempt was successful (OK or bad KO)
cat duck.log

5) Now try ssh into your Linux host using the domain name created
ssh youdomain.duckdns.org

6) Reboot the host or change the IP of the host and then wait 5 minutes, you should be able to ssh using the DNS domain name

Monday, March 16, 2020

Duck DNS

Now it's easy to remember my internet-facing hosts with dynamic IP using DuckDNS