Skip to content

Instantly share code, notes, and snippets.

@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

@ruario
ruario / 1-signal-linux-manual-unpack.md
Last active November 6, 2025 10:21
Steps to fetch and run Signal on a Linux desktop that is not deb or apt based

The following is a quick guide on how to manually download, extract and run Signal for Linux on a non-(deb)apt based distro (and includes a shell script that automates the entire process). This is for use when no suitable, native (re)package is available. It also includes some additional instructions on how to integrate with your desktop environment. Almost any recent distro (configured for desktop use) will likely have all the dependencies already installed—especially so if you already have any other Electron apps or a Chromium based browser installed, since they will require the same things.

[Note: Triple-click to easily select any of the lines below for copy and pasting into the terminal]

Fetch, extract and launch

  • Switch to a directory you think is suitable for housing Signal (for example ~/opt)
mkdir -p ~/opt && cd ~/opt
@ruario
ruario / dtime.sh
Created October 16, 2023 13:29
Show the current Decimal time or convert from "Standard time" to Decimal time
#!/bin/sh -eu
# Check for -s as an argument and if so convert decimal time to 'standard time'
if [ "${1-}" = '-s' ]; then
if [ -n "${2-}" ]; then
TIME_IN_SECS="$(echo 864*$(echo "$2" | tr -d :)/10 | bc)"
if [ "$(uname -s)" = Darwin ]; then
date -j -f "%s" "$(expr $(date -j -f '%H:%M:%S' '00:00:00' '+%s') + $TIME_IN_SECS)" '+%H:%M'
exit 0
else
date --date="0 today + $TIME_IN_SECS seconds" '+%H:%M'