WordPress/Linux Bash CLI Notes Engine Facility

I created this process to improve my record keeping while working on a Linux bash shell. It allows for one to take notes while on the command line as well as publish to WordPress for tidy and organized record keeping.


  • Posts logs to WordPress from any Linux hosts.
  • Log all CLI commands to syslog globally.
  • Record literal notes to syslog.
  • Privately post logs to WordPress via CLI.
  • Posting of Subject from CLI to WP posts.
  • Auto insert [hostname] into WordPress post subject.
  • Auto remove undesired data from WP posts.
  • Auto insert [shortcode] into WordPress posts.


  • Auto redact sensitive data on CLI WP post actions.
  • Record file changes to syslog (fork tripwire).
  • Post Categories to WordPress posts from CLI.
  • Post Tags to WordPress posts from CLI.


  • A self-hosted WordPress Installation.
  • The free Twenty Fifteen Theme.
  • FOSS Postie Plugin by Wayne Allen.
  • FOSS SyntaxHilighter Evolved by Alex Mills.
  • A pop3 mailbox (Postie to pull & DELETE emails).
  • Logger via the util-linux package.
  • Mailx via the mail-utils package.
  • Rsyslog via rsyslog package.
  • A bit of troysio microcode.


  • Install WordPress.
  • Activate Twenty Fifteen Theme.
  • Download/Activate SyntaxHilighter Evolved in plugins.
  • Download/Activate Postie within plugins area.
  • Configure Postie to fetch and posts PRIVATELY text only.
  • Install mail-utils and util-linux packages on all Linux hosts.
  • Create your CLI logging syslog service.
  • Drop the following troysio microcode into e.g. /usr/local/bin/yourio and make it executable.
  • #!/bin/sh
    # Troy Perkins
    # https://troys.io
    # Note: Make sure to remove all "\"es from Shortcode lines before executing. I had to place them in order for this code to be published here due to surrounding bash shortcode in this post.
    #Pop3 mailbox;
    { echo $shrtstart; cat $file | cut -d':' --complement -s -f1,2,3,4 | sed 's/\ [^\ ]*$//'; echo $shrtend; } | uniq | mailx -s "[$host] $1" $mailb

To take manual notes type a # sign then your note then hit enter:

root@crm:# # Here is an example of a manual note on the command line.

To send notes to WordPress:

root@crm:# troysio "Here is my subject"

Example Output:

vi /usr/bin/troysio
vi /usr/bin/troysio-redact
troysio "testing new cut"
cat /var/log/commands.log | cut -d':' --complement -s -f1,2,3,4
vi /usr/bin/troysio
vi /usr/bin/troysio-redact
troysio "testing new cut"
troysio uniq
vi /usr/bin/troysio
troysio uniq
troysio | uniq
vi /usr/bin/troysio
vi /usr/bin/troysio-redact
troysio "testing uniq"
vi /usr/bin/troysio
troysio "testing uniq"
cat -A /var/log/commands.log
cp /usr/bin/troysio /usr/bin/troysio-test
vi /usr/bin/troysio-test
troysio-test | cat -A
troysio-test | sub(/\r$/,"") | cat -A
troysio-test | cat -A
# Here is an example of a manual note on the command line.
# Hope you enjoy your note taking helper.
# Cheers.
troysio "here is my subject"
# WordPress post made with above command with title [crm] < host and "here is my subject" on the title of post.
# Joy

To view the actual post, which I’ve changed from Private to Public just for you go here: https://troys.io/crm-here-is-my-subject/

Relocate your WP website

Move your WordPress website anywhere in 10 minutes via an SSH shell with access to your website files directory and database.

Current URL: example.com/wordpress
Where to: example.com

Or, complete URL change, it doesn’t matter using this method.

Export your WordPress database.

mysqldump -u loginID -p example.com_wp > example.com_wp.sql

Now bust out a little sed.

cat example.com_wp.sql | s/example.com\/wordpress/example.com/g > new.sql

Now import your db sed edits.

mysql -u loginID -p example.com_wp < new.sql

Now move your directory files.

cd /var/www/example.com/wordpress/
tar cvf all.tar *
mv all.tar ../
cd ../
tar xvf all.tar
rm ./wordpress
rm all.tar

Done. Visit example.com

Send CLI commands to syslog

Create a CLI command syslog service

echo "local6.*    /var/log/commands.log" >> /etc/rsyslog.d/bash.conf
systemctl restart rsyslog.service

Set global .bashrc shells to log

vi /etc/bash.bashrc

# log all bash shell sessions globally
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"'

To test new configuration:

  • Either log out and log back into your shell.
  • Or source bashrc with the command
    source ~/.bashrc
  • Or start a new shell with the command

Type a few commands… then

tail /var/log/commands.log

Flash OpenWRT to RouterBoard

# No dhcpd or tftpd, no problem. Load OpenWRT firmware on Mikrotik RouterBoards the easy way using dnsmasq. Open two bash shell windows. In the 1st window execute the following and create your loader file:


mkdir -p /var/lib/tftpboot
vi /var/lib/tftpboot/loader.sh

# Create your loader.sh file

ifconfig enp6s0 up
dnsmasq -i enp6s0 --dhcp-range=, \
--dhcp-boot=openwrt-18.06.1-<your supported routerboard-initramfs>-kernel.bin \
--enable-tftp --tftp-root=/var/lib/tftpboot/ -d -u root -p0 -K --log-dhcp --bootp-dynamic

# Make it executable.

chmod 755 /var/lib/tftpboot/loader.sh

# Ensure both your desired initram AND upgrade image files (2 files) have been moved to the above tftpboot directory. If you forget the corresponding upgrade file, on reboot you’ll find RouterOS is back. Once you’re interfacing with OpenWRT, make sure to manually execute the upgrade in order to purge the RouterOS. It will ensure your OpenWRT kernel sticks and survives power cycles.

# Unplug your ethernet cable that connects the Linux host you are currently on from your current internet router. Then connect this loose end into the WAN/Internet port on your MikroTik Routerboard.

# In your second bash window, execute the following commands: First we determine what the main interface name is that’s using your ethernet connection (in my case its enp6s0). Then we create a virtual interface assigning it an IP address that resides on the network.


ifconfig | grep Ethernet | cut -d" " -f1
#enp6s0  <-- e.g. output. You may have more than one listed, its usually the top.
ifconfig enp6s0:0 up

# Now telnet to and login (u:admin p:) assuming this is a new Routerboard. Once logged in execute the following two commands (do not close this window.)

/system routerboard settings set boot-device=try-ethernet-once-then-nand
/system routerboard settings set boot-protocol=dhcp


cd /var/lib/tftpboot/

# Now quickly Unplug the power source from your Routerboard and plug it back in. You should soon see in your FIRST BASH WINDOW dhcp and a tftp directives and the sending of your OpenWRT image to the Routerboard. Give it some time to complete. A sign of completion is you will see OpenWRT dhcp messages in your FIRST BASH WINDOW.

# Once the first flashing is complete, unplug your ethernet cable from the Routerboard WAN port and plug it into its first LAN port. Depending on which Routerboard you have it may vary. You should now be able use a browser and log into OpenWRT via ip address NOTE! you’re NOT FINISHED! Log into OpenWRT and navigate to System> Backup / Flash Firmware. In the Flash new firmware image section click choose file and load the OpenWRT sysupgrade image you stored in /var/lib/tftpboot then click Flash Image. Now your new OpenWRT router will survive reboots.

# Lastly decide to delete, or keep but disable and lock loader.sh until its needed again.

chmod 000 /var/lib/tftpboot/loader.sh
chattr +i /var/lib/tftpboot/loader.sh

# Visual confirmation loader.sh is locked down using lsattr.

# Sample results:
root@host:/var/lib/tftpboot# lsattr
-------------e-- ./openwrt-18.06.1-ramips-mt7621-mikrotik_rbm33g-initramfs-kernel.bin
-------------e-- ./openwrt-18.06.1-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin
-------------e-- ./openwrt-18.06.1-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin
----i--------e-- ./loader.sh
-------------e-- ./openwrt-18.06.1-ramips-mt7621-mikrotik_rbm33g-squashfs-sysupgrade.bin

Linux VR: A whole new world

Safespaces and Linux will lead this space, mark my words.  If you think Facebooks Oculus is cool, this is where not just entertainment is going – but the workplace as well. If you’re upset with today’s society of detached youth in public places staring at their mobile phones, VR Goggles are the next wave. Feeling a fool giving a pair a go, I found the experience quite entertaining. Expecting to see maybe a movie in 3D, it was so much more – playback presented in 180 degree 3D and even 360 degree 3D with HD going higher.