Entries tagged linux | Hugonweb Annotated Link Bibliography

Pressure Stall Information

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/Documentation/accounting/psi.rst?h=v6.15.3

Found in /proc/pressure/ are cpu, memory, and io, text files that contain info on the fraction of processes "stalled" due to contention for the given resource.

Other links:

https://facebookmicrosites.github.io/psi/docs/overview

https://lwn.net/Articles/759781/

Linux dd vs cp

https://unix.stackexchange.com/questions/558262/why-use-dd-instead-of-cp-to-create-bootable-disk

Tutorials and instructions usually recommend dd over cp for copying disc images to devices (like USB sticks). It seems that this is mostly superstition.

The main benefit is that dd lets you specify the block size used for copying, but cp automatically selects the block size at least as well as I would.

The other benefit of dd is a progress display. Piping the output of the pv command to the destination disc may be a better option.

Cron vs SystemD timers

https://unix.stackexchange.com/a/688512

A really nice explanation of how to use SystemD timers to replace cron.

Find and replace in a codebase

https://will-keleher.com/posts/5-Useful-Bash-Patterns.html

I never really have figured this out before. Here is a way:

grep -l pattern | xargs sed -ri 's|pat(tern)|\1s are birds|g'

The -l option to grep (and ripgrep) makes it just output filenames containing matches. The sed option -r enables extended regex (-E may alternatively be used like in grep), and -i replaces in place.

If any filenames contain spaces, newlines, or quotes, then xargs can get messed up. Terminating lines with null characters fixes that:

grep -lZ pattern | xargs -0 sed -ri 's|pat(tern)|\1s are birds|g'

or

rg -l0 pattern | xargs -0 sed -ri 's|pat(tern)|\1s are birds|g'

Linux is built for control but not for people

https://fireborn.mataroa.blog/blog/i-want-to-love-linux-it-doesnt-love-me-back-post-1-built-for-control-but-not-for-people/

A story about using Linux blind. It makes me sad that accessibility in Linux has severely declined over the last 15 or so years!

fdfind

https://github.com/sharkdp/fd

Intuitive to use version of the find program.

fdfind -e py # finds all Python files in current directory
fdfind pattern -t d # finds all directories matching pattern

ncdu: NCurses Disk Usage

https://dev.yorhel.nl/ncdu

ncurses-based disk usage program. It seems fast and easy to use.

Watchexec

https://github.com/watchexec/watchexec

watchexec can rerun a command when a set of files is modified and is designed for ease of use. Two examples from the README are:

$ watchexec -e js,css,html npm run build

$ watchexec -r -e py -- python server.py

Frustratingly, it's not a Debian package. Installation with cargo install --locked watchexec-cli isn't hard, but you don't have much control over 300+ dependencies.

tldr pages

https://tldr.sh

The tldr pages are a community effort to simplify the beloved man pages with practical examples.

They are a really nice set of examples. I especially like the ones for git commands, like git rebase.

Using chroot for Linux system recovery

https://superuser.com/questions/111152/whats-the-proper-way-to-prepare-chroot-to-recover-a-broken-linux-installation

This technique lets you boot your broken installation with a live USB disc, then use chroot to switch the running Linux over to the broken installation. You can then run package manager commands, etc.

arch-chroot is a script that does all of the steps for you and is even available on Debian.

systemd-nspawn can be used in a similar way:

systemd-nspawn --directory /tmp/target-rescue --boot -- --unit rescue.target

It is usually used as a light weight host virtualization technique, and is new to me!

Picking glibc versions at runtime

https://blogsystem5.substack.com/p/glibc-versions-runtime

How do you test code against a different version of libc than the system default one? You can't reliably use an alternate libc by putting it in LD_LIBRARY_PATH. It will often crash.

You might think that the kernel is somehow responsible for dealing with dynamic libraries, but that’s not the case. Dynamic libraries are a user-space concept and this is precisely where the [ELF] interpreter [ld-linux.so] comes into play.

To summarize, glibc ships both the ld-linux.so dynamic linker and the libc.so.6 shared library. The two are closely coupled. Running a binary against the C library without also using a matching dynamic linker can lead to crashes. But running a binary directly with a specific dynamic linker ensures that the binary picks up the matching C library.

At compile time, you can include the interpreter ld-linux with:

bash gcc -o myexe -Wl,--dynamic-linker=/wherever/ld-linux-x86-64.so.2 mycode.c

At runtime, you can use patchelf to replace the reference to the interpreter in the binary:

bash patchelf --set-interpreter /wherever/ld-linux-x86-64.so.2 myexe

Keep in mind that glibc backwards compatibility means a newer glibc will work with code compiled with an older version, but not the other way around.

PaperWM

https://github.com/paperwm/PaperWM

PaperWM is a scrolling window manager for the GNOME Shell. It's similar to tiling window managers like dwm and XMonad, but instead of tiling windows within the desktop, windows scroll to the right as they are created. So you just navigate left and right to various windows.

I like the conceptual idiom a lot better than normal tiling. I'm not sure if it works for me in practice. I've tried it in Debian 12/GNOME Shell 43.9 and installed the extension from extensions.gnome.org here on my laptop. I usually use each window in full screen on my laptop and alt-tab between them, so I'm not sure how useful the scrolling is for me. After an hour or so of use, it does seem to encourage me to have more than one window at a time on the desktop.

The default keybinding for switch window is super+tab, but I like alt+tab a lot better, so had to add that. The instructions on moving around and re-sizing windows are a bit confusing to me. I'm yet to really figure it-out.

Borg Backup Software

https://www.borgbackup.org

Borg seems like the best open source backup solution right now. It deduplicates chunks of data within files across multiple backups, saving a lot of space. Encryption and compression are also supported.

It only works locally or over SSH, and doesn't work on Windows. I wish it had support for parity so it could recover from a bit of storage corruption.

rclone

https://rclone.org

File copy/sync/move to and from the cloud, and even between clouds.

It works with S3 and similar, but also OneDrive, Dropbox, Google Drive, FTP, and SFTP.

Rsync for the cloud sounds useful, as well as copy and move. Two-way sync, bisync, sounds like a mess waiting to happen.