Linux hacks for the command-line

Intermittently needed cheat codes

April 27, 2015 — April 9, 2020

computers are awful
POSIX

Things I forget how to do in Linux (Linux in particular, not unix-style command lines in general).

Some of these commands are supposed to be run as sudo root, and any of them might turn your computer bad, and set it to obsessively stalking you and sewing shellfish into your curtains, or some other even worse consequence. I take no responsibility for that.

Figure 1: Kung Fury

1 Open a file in the GUI from the command line

xdg-open filename.ext

Of course! Why did I not realize that open is spelled xdg-open? For the curious, xdg stands for “Expect Delays Googling”, because that is how you work out these unintuitive and unhelpful command names.

2 SysRq

Linux Magic System Request Key Commands are commands you can run in the kernel via a key combination. They seem useful, and also like a massive security risk. I am not clear if they are enabled by default on typical machines.

3 What is stealing my keypress?

Annoying keyboard shortcut problems with your X application?

Troels Arvin says:

Using xlsclients -la, I found a list of X apps, including those running in the background. I started killing them; some of the process terminations made my Gnome session break down, but I eventually found that shutting down the skypeforlinux process made CTRL+ALT+SHIFT+D work for me.

4 Must secure boot be disabled?

Apparently not. But it is onerous beyond plausible usefulness, without Microsoft signing kernel modules for you, unless you are working for some secret agency; in which case, call IT support.

5 Rebuild all DKMS kernel modules

Missing some modules for some kernel version? Here is how to rebuild for all kernel versions:

ls /var/lib/initramfs-tools | \
    sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start

6 Pinning kernel version because the drivers/modules

I needed this a couple of times although AFAICT I should not have. I think compatible versions of something I do not want to know about didn’t match with my manually selected versions of some other thing I don’t want to need to care about. Sidestepping the issue by pinning grub default to boot the good kernel seemed to work.

7 Filesystem hacks

See Linux FS hacks.

8 Linux audio

I am so sorry. Read Linux audio.

9 Debian/Ubuntu package file ownership

Two options:

dpkg -S file
dlocate /path/to/file