Skip to content

Instantly share code, notes, and snippets.


  • South Africa, Johannesburg
View GitHub Profile
View SysRq magic

sysrq magic keys

This is useful for trying to recover from an unresponsive system. However, by default, Ubuntu disables the key to gain raw keyboard access.\

Sometimes part of the issue is that X/Wayland display servers have crashed due to bad graphics drivers and keyboard input isn't processed anymore, whereby changing to another console, e.g. ctrl + alt + F1 doesn't work. Since the default disables keyboard control, alt + sysrq + r, can't help salvage the situation. Hence the suggestion to at least enable system request raw keyboard control when trying to recover a system.

Ubuntu doesn't enable control of keyboard by default

Ubuntu 16.04 LTS default value:

JPvRiel /
Last active Jan 7, 2019
Linux MD software raid inspection

A bash script that collects some useful commands to check Linux MD software arrays and component devices for some issues, e.g.

  • RAID component device has a SMART warnings or errors.
  • A RAID with HDD and SSD mixed doesn't have the HDD components set to write-mostly or the SSD is set to write-mostly.

It can also display info. Set env var SHOW_INFO='y' or anything else, e.g. 'n' (default) to just report issues.



Show top 10 processes by resident memory set size

ps -eo pid,user,rsz,vsz,comm,args --sort -rss --cols 160 | head -n11
JPvRiel / spice-guest-tools Windows 10
Last active Sep 4, 2018
Fixing "page fault in nonpaged area" Windows 10 BSOD caused by installing spice-guest-tools
View spice-guest-tools Windows 10


Boot failure was caused by installing spice-guest-tools which, if you read details about it, also includes the QXL driver and the install broke my Windows 10 build 17134 guest somehow. This occured on Ubuntu 16.04 LTS with QEMU emulator version 2.5.0.


BSOD with "page fault in nonpaged area" occurs after installing spice-guest-tools-latest.exe. It possibly clobbers other stable/good versions of drivers.

Automatic boot repair fails. After going through advanced options and getting to a command prompt, inspect the boot repair logs:



Merge master into branch

A good idea if upstream has had commits and, to catch up, you need to test your feature branch with changes from upstream included

git checkout feature
git pull origin master
JPvRiel /
Created Nov 12, 2017
Decrypt a directory of PDFs using bash, basename and qpdf

Given a working directory and a folder c with encrypted PDFs, use qpdf, basename and a bash loop:

for f in c/*.pdf; do qpdf --password=<password> --decrypt $f "$(basename -s .pdf $f).pdf"; done
JPvRiel / Find out which process has created an X
Created Mar 24, 2017
Find out which process has created an X window
View Find out which process has created an X


W window has a _NET_WM_PID property set by the applicaiton. To really validate if the application has set this correctly is more work (see reference).

Simple Example

Run command and click the window

$ xprop _NET_WM_PID
JPvRiel /
Last active Jul 3, 2020
Enable persistent storage for the systemd journal log

Enable persistent storage for the systemd journal log


The assumed default setting in /etc/systemd/journald.conf is Storage=auto which implies that systemd journaling will only persist the journal if the expected storage location is available. Otherwise, the journal data is stored in memory and lost between reboots. On Ubuntu 16.04, /var/log/journal does not exist by default. Create it to keep and query events from previous boots.


  • Syslog still provides the persistant log records for Ubuntu 16.04, so enabling persistant systemd journal logging does cause a level of duplicaiton.
  • There are sane defaults:
JPvRiel /
Created Feb 16, 2017
Troubleshoot "Could not get lock /var/lib/dpkg/lock" errors when trying to update or install debian packages

Troubleshoot "Could not get lock /var/lib/dpkg/lock" errors when trying to update or install debian packages

Error Message

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

JPvRiel /
Last active May 15, 2019
a shell wrapper to pull org.gnome.proxy settings into env, e.g. http_proxy, which is useful for .desktop files


Useful for:

  • updating current terminal's shell env proxy settings, or
  • wrapping exec in .desktop files to inject env proxy settings

GNOME proxy settings should normally get propergated into the shell (bash) environment via gnome-terminal, e.g. http_proxy and no_proxy. However:

  • I noticed that applications exectuted via .desktop entries sometimes don't work. This happens when an app ignores org.gnome.proxy settings but can often use proxy env vars from the shell.
  • If you're proxy settings change, existing shell processes will still have the old proxy enviroment variables, so this can help refresh them whithout having to create a new shell.
You can’t perform that action at this time.