Skip to content

Instantly share code, notes, and snippets.

JPvRiel

  • South Africa, Johannesburg
Block or report user

Report or block JPvRiel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SysRq magic keys.md

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
JPvRiel / inspect_raid.md
Last active Jan 7, 2019
Linux MD software raid inspection
View inspect_raid.md

inspect_raid.sh

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.

Usage

View ps_command_examples.md

Show top 10 processes by resident memory set size

ps -eo pid,user,rsz,vsz,comm,args --sort -rss --cols 160 | head -n11
@JPvRiel
JPvRiel / spice-guest-tools Windows 10 BSOD.md
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 BSOD.md

Synopsis

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.

Error

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:

View git_workflow.md

Merging

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
JPvRiel / decrypt_directory_of_pdfs_bash_qpdf.md
Created Nov 12, 2017
Decrypt a directory of PDFs using bash, basename and qpdf
View decrypt_directory_of_pdfs_bash_qpdf.md

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
JPvRiel / Find out which process has created an X window.md
Created Mar 24, 2017
Find out which process has created an X window
View Find out which process has created an X window.md

Overview

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
JPvRiel / journalctl_enable_persistent_storage.md
Last active Sep 3, 2019
Enable persistent storage for the systemd journal log
View journalctl_enable_persistent_storage.md

Enable persistent storage for the systemd journal log

Overview

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.

Considerations:

  • 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
JPvRiel / deb_apt_dpkg_locked.md
Created Feb 16, 2017
Troubleshoot "Could not get lock /var/lib/dpkg/lock" errors when trying to update or install debian packages
View deb_apt_dpkg_locked.md

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
JPvRiel / gnome_proxy_to_env.md
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
View gnome_proxy_to_env.md

Why?

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.