Category: Linux CLI

x11 logo

x11 logo

Persistent Server VNC

I have a home server I call a NAS but it also does some other stuff. Occasionally I find the need to do some GUI things, and I don’t want to be bothered with a physical keyboard and mouse as that’s quite inconvenient due to the physical setup. I require use of the real graphics card for this, so, using virtual desktops is not an option, so to that end I will use x11vnc since it shares existing X displays.

I suppose there is a more elegant solution to this problem but this is fine for me. I am running Debian 10, with the LXDE desktop environment. Bog standard Debian desktop install.

I’m going to make lightdm log me in my non-root user automatically:

[email protected]:~# nano /etc/lightdm/lightdm.conf

Add your user under Seat:*

autologin-user= MadRush

~/.xsessionrc runs stuff as soon as you are logged in to X. It’s a perfect spot to make x11vnc start up:

[email protected]:~$ cat .xsessionrc 
/usr/bin/x11vnc -forever -display :0 -auth guess -rfbauth /home/MadRush/.vnc/passwd & disown

Okay so next time you log in, x11vnc will be started. And -forever means it will stay open after you disconnect. Going forward lightdm will automatically log you in, et voila, there’s your persistent x11vnc session. Restart lightdm:

[email protected]:~# systemctl restart lightdm

Good to go! Now I can log in at the physical console if I want, and then pick up where I left off should I want to use VNC instead.

Foxit PDF Read on Linux with Wine

I don’t very much like Evince or other FOSS PDF readers on Linux. I do however like using Foxit on windows. They do actually provide packages for Linux packages but there is a long standing rendering bug where everything is super stretched out vertically. There does not seem to be an solution to the bug in sight. However, while perusing the support forums someone mentioned they had good success using the Windows version in Wine. Ok! Fine.

I want this to be separate from the Wine root in my home directory so it is self contained and can be copied from one machine to another. I’m lazy.

mkdir -p /opt/foxitwine/wineroot
cd /opt/foxitwine/
<wget your foxit installer .exe in here>
WINEPREFIX=/opt/foxitwine/wineroot wine FoxitReader97_Setup_Prom_IS.exe

Now install Foxit Reader, I put it in c:\FoxitReader for brevity.

Thing is, you want this to integrate nicely with your Linux desktop, so, here’s a FoxitReaderWine.desktop file:

[Desktop Entry]
Name=Foxit Reader Wine
Comment=View pdf documents
Exec=/usr/bin/env bash -c "printf 'z:%%q\\n' %F | WINEPREFIX='/opt/foxitwine/wineroot' xargs wine 'C:\\FoxitReader\\FoxitReader.exe'"

I was having an issue with getting the file argument successfully passed to wine so I mined this discussion for a handy solution.

mv FoxitReaderWine.desktop /usr/share/applications/

All done.


Firewall script without service

Sometimes on Linux systems for one reason or another it is not practical to use the built-in iptables-services or iptables-persistent to handle your firewall rules. For example, cPanel/WHM manages its own firewall rule set and does not care what is in the normal iptables rules file.

A very straight forward solution to this is run a script in cron to check if your rules exist presently and if not, add them.

# This script is run with cron to make sure iptables rules to block Portmap are present

function addrules {
  iptables -I INPUT -m tcp -p tcp --dport 111 -j DROP -m comment --comment "Portmapper Vulnerability"
  iptables -I INPUT -m udp -p udp --dport 111 -j DROP -m comment --comment "Portmapper Vulnerability"

numrulesfound=$(iptables -nL |grep -c "Portmapper Vulnerability")

if [ $numrulesfound -eq 0 ]; then
  echo "Portmapper iptables rules NOT found, adding"
elif [ $numrulesfound -gt 0 ]; then
  echo "$numrulesfound Portmapper iptables rules found, exiting"

And some kind of cron to run it periodically:

0 * * * * /root/ > /dev/null 2>&1
, , , ,
MariaDB logo

MariaDB logo

Moving MariaDB Data Drama

For those of you who work with MySQL on CentOS or RedHat servers on a regular basis, running out of room for large MySQL databases on the root partition is pretty common.¬† The default options in the OS installer suggest a 30GB root partition which has probably been the default value for at least ten years.¬† Normally, this is easy to remedy. However, I was trying this on a server with MariaDB …

Trying this both via editing my.cnf and by simply a symlink produces failure:

Sep 14 16:49:06 mysqld[22796]: 2017-09-14 16:49:06 140313610287360 [Note] /usr/sbin/mysqld (mysqld 10.1.26-MariaDB) starting as process 22796 …
Sep 14 16:49:06 mysqld[22796]: 2017-09-14 16:49:06 140313610287360 [Warning] Can’t create test file /var/lib/mysql/id27131.lower-test64 ID=15680 PROTO=UDP SPT=53 DPT=60246 LEN=192 UID=25 GID=25

Looks like it may be due to a bug with mariadb!

A tutorial on DO says you need to specify the socket for the MySQL client.. i didnt even try that as mysqld fails to start!
Seems like this would have to be done by changing  the variable basedir not datadir, I have yet to try that.


Less Syntax Highlighting on Ubuntu 16.04 and Debian 8

Looking at shell scripts or just about anything without highlighting is painful. I use less a lot to page through long stuff, so why not have some color?

sudo apt install source-highlight

then add the following to your .bashrc:

export LESSOPEN="| /usr/share/source-highlight/ %s"
export LESS=" -R "

This is modified from a script on GitHub. That script is specific to CentOS