Pages from the fire

Linux Notes

Last updated: 2025-11-22

Buffers, splits and tabs in Vi
Bash creature comforts
GNOME
Notes on window managers (Desktops)
Notes on terminal emulators
Synology
Bug reports

System

As a general note, the arch wiki is an absolutely fabulous resource for troubleshooting and just informational reading about all things Linux.

Commandline options kernel was started with

cat /proc/cmdline

Distribution version details

lsb_release -a

Kernel details

uname -a

Machine serial number

sudo dmidecode -s system-serial-number

Machine bios version

sudo dmidecode -s bios-version 

System log (add -no-tail when piping to something)

journalctl --system -S "2024-03-22 14:00"

Get display details

edid-decode /sys/class/drm/card0-eDP-1/edid

Memory (RAM) details

sudo dmidecode -t memory

NVMe SSD details

sudo smartctl -a /dev/nvme0

Block device e.g. disk details

lsblk

CPU details

cat /proc/cpuinfo

e.g. Get CPU frequency

cat /proc/cpuinfo | grep -i mhz

Thermals:

cat /sys/class/thermal/thermal_zone*/temp

/sys/class/hwmon

This is a virtual filesystem interface managed by the Linux kernel’s hardware monitoring system and carries information about various devices.

You can get a list of names

cat /sys/class/hwmon/hwmon*/name

On my Thinkpad I have a thinkpad entry on hwmon6

cat /sys/class/hwmon/hwmon7/fan1_input

The sensors utility from the lm-sensors package will give nicelt formatted system sensor information.

USB bus details

lsusb

Firehose of hardware info

sudo hwinfo

Disk space stats in human friendly format

df -H

Process, CPU and memory information: htop

GPU information: intel_gpu_top

or: nvtop (https://github.com/Syllo/nvtop)

For Intel GPUs setcap may be needed to set enable CAP_PERFMON capabilities on the binary.

sudo setcap cap_perfmon+ep intel_gpu_top

Battery

cat /sys/class/power_supply/BAT0/uevent

Services

Service status

sudo systemctl status <service name>

Enable, start and stop to control services

sudo systemctl enable <service name>
sudo systemctl start <service name>
sudo systemctl stop <service name>

Get laptop display type

Look through /sys/class/drm/ for the devices. Find which one’s /enabled value is “enabled” and then run

cat /sys/class/drm/card1-eDP-1/edid | edid-decode 

Sleep states

cat /sys/power/state
cat /sys/power/mem_sleep

Detailed description of the values are in the kernel docs

Change with

echo s2idle | sudo tee /sys/power/mem_sleep deep

Also see these kernel docs

Printing

List all available printers

lpstat -pa

List current printer jobs

lpstat

Output will be of the form

Brother_HL_L2300-181  kg  165888   Sun 21 Sep 2025 07:48:03 PM EDT

Here the -181 is the job number.

Remove a print job

lprm <job number>

List jobs that are not completed

lpstat -W not-completed

Restart print service (sometimes needed to reconnect to a printer)

sudo systemctl restart cups

Filesystem

Size of directory

du -sh <directory>

Used and free sizes of all mount points

df -H

List directory contents recursively

ls -R

Find and print all empty directories

find . -type d -empty -print

Delete all empty directories

find . -type d -empty -delete`

Find and print all files with given extension

find Takeout -name "*.json" -type f -print

Audio

Spot check microphone: You’ll get a cool bar in your terminal that shows sound level.

arecord -vv -f dat /dev/null

Record 5 seconds of audio at 44 kHz and 16 bit resolution, then play it back.

arecord -d 5 -r 44000 -f S16_LE test.wav
aplay test.wav

Bash

Redirect stdout of cmd to std.out and stderr to `std.err

cmd > std.out 2> std.err

Redirect stdout and stderr to `out.txt

cmd 2> out.txt

Networking

Networking interface configuration

ifconfig

Trace route to host

mtr 8.8.8.8

Measure bandwidth

Use iPerf3.

Start iperf3 server on target machine “hostname”

iperf3 -s

Connect to “hostname” and determine speed of connection

iperf3 -c hostname

Login as different user on a machine and share screen.

Grant “user2” access to your display on the (non-network) local machine

xhost + local:user2

Open a login shell as “user2”

su - user2

PDFs

Resize PDF using ghostscript

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook \
-dNOPAUSE -dQUIET -dBATCH \
-sOutputFile=output.pdf input.pdf

Compression settings are

/screen   = 72dpi
/ebook    = 150 dpi
/printer  = 300 dpi
/prepress = 300 dpi

Stitch files together

Use pdfjam for joining files together, selecting pages, reducing several source pages onto one output page, etc.,

It is a user-friendly layer over the powerful pdfpages package.

pdfjam <input file> <page ranges> -o <output file>

It’s annoying to download the whole tex distribution when all we want to do is convert markdown to a simple pdf using pandoc. We can use the pdfroff package.

pandoc                               \
   *.md                              \
  -f markdown                        \
  --metadata title="My manuscript"   \
  -o ms.pdf                          \
  --pdf-engine=pdfroff

Images

Use ImageMagick

Make a bootable USB from an iso image

(Use it for booting Linux, updating firmware, anything where a bootable iso image is supplied)

  1. Plug in the USB drive
  2. Find which device the drive is labeled as using lsblk. say it’s /dev/sdx
  3. Use dd to create a bootable USB\
dd if=linuxmint-22.1-xfce-64bit.iso of=/dev/sdax bs=8M status=progress &&
 sync

The sync at the end ensures all the data is written to the drive. status=progress is nice to get an indication nothing’s frozen up.

mDNS: Local hostname resolution

Multicast DNS (mDNS) enables machines to resolve devices on the LAN using <hostname>.local scheme. The implementation for Linux is Avahi. Ubuntu installs this automatically, but some other distributions, like openSUsE, do not. The arch wiki page is a great resource for setting it up yourself.

Find devices via mDNS

avahi-browse -a

Find mDNS name for given address

avahi-resolve-address 192.168.8.1
getent hosts 192.168.8.1

ControlMaster: persist ssh connections

ControlMaster can be used to persist/reuse ssh connections e.g. for rsync

Example: add to ~/.ssh/config

ControlMaster auto
ControlPath ~/.ssh/control:%C
ControlPersist 5m

Neovim/Vim

Open file for editing in current window :edit file.txt

Switch to buffer (with autocomplete) :b <tab>

Split pane :vsplit or :split

Go to pane CTRL + W followed by arrow keys. On NeoVim you can also click on the split.

Go to end of file: G

Go to 34% of the file: 34%

Copy large number of lines.

  1. Mark starting line ma
  2. At last line, yank from mark y`a
  3. This can be used to delete too d`a

Open file in new tab :tabedit <filename>

Go to second tab 2gt. On NeoVim you can also click on the tab.

Wrap paragraph gq}

Check if compiled with clipboard support :echo has('clipboard')

For Vim you can do vim --version | grep clipboard but not for NeoVim.

Paste from clipboards (When compiled with +clipboard option

"+p
"*p

Builtin file explorer: netrw

Refs: [1], [2]

Builtin packages feature

I prefer the built in packages feature to any external plugin manager: less complexity to manage. Just git clone the plugin into ~/.config/nvim/pack/<org>/start/ where <org> is some arbitrary name you chose to organize plugins. I use the repo owner’s handle.

LSP configuration

NeoVim has a built in LSP client! Use nvim-lspconfig to get a good default configuration (Follow the instructions there to install it).

Then to your ~/.config/nvim/init.lua add

vim.lsp.enable('gopls')
vim.diagnostic.config({ virtual_text = false, virtual_lines = { current_line = true }, })

The first line enables a particular LSP server, in this case the golang server gopls.

The second line configures how you want the diagnostic messages from the server displayed. This particular configuration shows the message as a “popup” line when your cursor lands on the line with the error:

If you instead use

vim.diagnostic.config({ virtual_text = true, })

The error message is always visible and looks like:

Configuration notes

In .vimrc/init.vim

" Auto save for markdown files in insert mode
" https://stackoverflow.com/a/60095826
" https://stackoverflow.com/a/63589188

autocmd BufNewFile,BufRead *.md :autocmd TextChangedI <buffer> if &readonly == 0 | silent write | endif



" _Esc_ ape from insert mode is slow
" https://vi.stackexchange.com/a/20220

set tttimeoutlen=5

tmux

Open a new tab

<ctrl>+b c

Switch to a tab

<ctrl>+b 0...9

Add setw -g mouse on in ~/.tmux.conf to enable scrollback with mouse scroll.

Software I use

General

sudo apt install git flatpak simple-scan

Flatpaks

flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

flatpak install flathub org.mozilla.firefox
flatpak install flathub io.github.dosbox-staging
flatpak install flathub net.sf.VICE

Flatpack commandlines

flatpak run --filesystem=/home/kghose/RetroComputing/dosbox io.github.dosbox-staging

flatpak run --filesystem=/home/kghose/RetroComputing/c64/ net.sf.VICE

flatpak run org.mozilla.firefox

Examine permissions

flatpak info --show-permissions org.mozilla.firefox

Upgrading firmware (Thinkpads)

fwup is the easiest but may not have the most up to date firmware from the manufacturer. Follow the basic usage flow described on the project page.

fwupdmgr get-updates
fwupdmgr update

Manufacturers may put out a bootable image. You can use dd to create a bootable USB (steps are noted on this page).

Ubuntu: Stop apt from installing snaps

From ask Ubuntu

sudo apt-get autopurge snapd
sudo apt-mark hold snapd

Ubuntu: Install Firefox through apt

Follow the instructions on the Firefox page

dnf: Fedora (Red Hat) package manager

List all the repositories dnf searches through

dnf repolist --enabled

Remove a repository (has to be done “manually”)

rm /etc/yum.repos.d/file_name.repo

Some GNOME settings

Prevent Bluetooth being turned on automatically after wakeups or reboots:

In /etc/bluetooth/main.conf set AutoEnable=false

Personal list of indispensible software

  1. wezterm: Current favorite terminal emulator
  2. NeoVim: Current favorite text editor for code and prose
  3. pandoc
  4. pdfroff
  5. mpv: no-nonsense commandline media player (with a minimal console for playing video). Gives excellent informational messages too, like Displaying cover art. Use --no-audio-display to prevent this.
  6. firefox
  7. pdfjam
  8. Image Magick
  9. simple scan
  10. intel_gpu_top / nvtop
  11. stylua