Skip to content

Instantly share code, notes, and snippets.

@ruario
ruario / related.sh
Last active December 29, 2025 19:48
A simple script to locate files associated with a software install (Linux only as it uses GNU extensions)
@ruario
ruario / linux-rar-arm64.md
Last active December 29, 2025 19:14
Running RAR for Linux on arm64

Running RAR for Linux on arm64

TL;DR This guide shows how to run the x86_64 Linux RAR binary on arm64 using QEMU user-mode or FEX¹, and compares their performance. If you do not want to read further, simply install either of them via your package manager and then run the script included with this gist, to automatically download and configure RAR.

¹ FEX only adds about 13% overhead.

Intro

RAR is a strong archiving option on Linux when you need features other formats do not provide, such as built‑in recovery records, archive‑level deduplication, robust multi‑volume handling, advanced filters, archive content search & manipulation, strong encryption, etc. [Full comparison with other Linux archivers]

@ruario
ruario / TAR-RAR-7‑Zip-Info‑ZIP-linux.md
Last active December 22, 2025 11:59
TAR vs RAR vs 7‑Zip vs Info‑ZIP on Linux

Tar vs Rar vs 7‑Zip vs Info‑ZIP on Linux

TL;DR

  • tar: Full Linux filesystem metadata and special file support.
  • rar: Extensive feature set: permissions, ownership, recovery, deduplication, filtering, archive content manipulation, strong encryption, etc.
  • 7z: Strong encryption where open source is a requirement.
  • zip: Maximum compatibility.

Note: They are actually all widely supported for extraction by common libaries. You will not realistically find a modern system, configured for desktop use, that cannot open all of these but zip will be less confusing to non-technical users and has wider support on legacy, mobile and embedded platforms out of the box.

@ruario
ruario / rar-7z-linux.md
Last active December 22, 2025 11:52
Rar vs 7z on Linux

Rar vs 7z on Linux

TL;DR

  • rar: More feature‑rich for archival integrity and file manipulation. Creation is proprietary and requires a license but it is fully free and open for extraction.
  • 7z: Fully open‑source and free to use for both creation and extraction. It can sometimes have marginally better compression ratios.

Rar is preferable to 7z on Linux when you need features 7‑Zip does not provide, such as built‑in recovery records, archive‑level deduplication, more robust multi‑volume handling, stronger resilience against corruption, advanced filters and preservation of basic UNIX ownership and permissions. If you don't need those, or fully open source is a must, then 7z is a reasonable option.

Note: Both actually have pretty equal support for extraction by a third party. You will not realistically find a system that can open .7z but not .rar, or vice versa.

@ruario
ruario / 7z-UNIX-permissions.md
Last active December 7, 2025 15:21
Archive formats like .7z and .zip often fail to preserve UNIX file metadata such as permissions and ownership. Here are three simple shell one‑liners that generate helper scripts to restore these attributes after extraction

Preserving UNIX (Linux) File Permissions and Ownership in .7z and .zip Archives

When possible, native *nix formats like tar are the best choice for backups. However, there are cases where other formats may be preferable due to their features. For example, specific compression options or non‑solid compression that allow faster access to individual files. In these situations, common tools such as 7‑Zip (with Windows heritage) may not store UNIX meta data correctly. By combining small, easy‑to‑create helper scripts with your backup archives, you can preserve metadata. Here are three short scripts that can be generated via shell one-liners:

  • perms.sh → Restores file permissions only.
  • attribs.sh → Restores both permissions and ownership.
    • Run with no arguments → restores both.
    • Run with -o → ownership only.
    • Run with -p → permissions only.
  • [symlinks.sh](#bonus-handling-symlinks
@ruario
ruario / tar_gzip_commands.txt
Last active December 3, 2025 08:27
A sub selection of commands that would make a tar.gz archive from the contents of folder using GNU tar and gzip (there are more ways than this… there are ALWAYS more 🤣)
tar -a -c -f archive.tar.gz folder
tar -a -c -farchive.tar.gz folder
tar -a -cf archive.tar.gz folder
tar -a -cfarchive.tar.gz folder
tar -ac -f archive.tar.gz folder
tar -ac -farchive.tar.gz folder
tar -acf archive.tar.gz folder
tar -acfarchive.tar.gz folder
tar a -c -f archive.tar.gz folder
tar a -c -farchive.tar.gz folder
@ruario
ruario / mac_keyboard_tweaks.md
Last active October 9, 2025 09:10
Norwegian Macbook Keyboard Tweaks (Ubuntu 24.04)

Norwegian Macbook Keyboard Tweaks (Ubuntu 24.04)

This patch modifies the Norwegian Macintosh keyboard layout on Ubuntu Linux to better match that of a modern Macbook's physical labels and expectations:

  • Replaces | (pipe) with ' (apostrophe) as the primary symbol for the key below esc
  • Promotes $ to Shift+4
  • Introduces as AltGr+4
  • Demotes ¤ (currency) to Shift+AltGr+4 (since this is hardly used these days)
  • Swaps the order of the dead keys of the ´ (acute) and ​`​ (grave) acents on the key to left of backspace
  • Enables access to higher level symbols by setting the right-most Alt ⌥ (Option) key as AltGr
@ruario
ruario / cnvtlag.sh
Last active December 24, 2024 11:12
A script fetch and convert a Lagrange AppImage to a system installable package
#!/bin/sh -eu
# A script convert a Lagrange AppImage to a system installable package
# Determine if a local package should be used or if one should be fetched
if [ -n "${1:-}" ]; then
APPIMAGE="$1"
else
case "$(uname -m)" in
arm*) APPIMAGE_ARCH=armhf ;;
*) APPIMAGE_ARCH="$(uname -m)" ;;
@ruario
ruario / terminal-beats.md
Last active March 24, 2024 13:32
Swatch .beats to centibeat level from the terminal

To print the time in Swatch .beats from the terminal, issue the following:

printf @;TZ=UTC-1 date '+scale=2;((%H*60+%M)*60+%S)/86.4'|bc

You can save this as a shell alias so that you can check the time in .beats whenever you like alias beat="printf @;TZ=UTC-1 date '+scale=2;((%H*60+%M)*60+%S)/86.4'|bc".

Notes:

@ruario
ruario / make_dated_directory.md
Last active March 24, 2024 22:20
This script creates a directory named with the current date, followed by the current Swatch .beat (down to "decibeat" level, which gives ≈ 9 seconds of time resolution)

This is a short shell script to make date named directories.

#!/bin/sh
a=`TZ=UTC-1 date +%y%m%d-%T`;b=${a#*-};c=${b#*:}
mkdir -v ${a%-*}`printf %04d $(echo "((${b%%:*}*60+${c%:*})*60+${c#*:})/8.64"|bc)`|grep -Eo \[0-9]+

Usage