Skip to content

2024

Install fonts in Linux

Copy the fonts files to ~/.local/share/fonts/. Then, run fc-cache to rebuild fonts cache.

fc-cache -fv

Linux CPU frequency

See current CPU frequency

To display frequencies of all CPU cores every second:

watch -n1 lscpu --all --extended

Change CPU frequency directly

Source: Stackoverflow

Query CPU options

grep . /sys/devices/system/cpu/cpu0/cpufreq/*

Set the maximum CPU frequency

echo 4400000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq

Change CPU frequency using cpufrequtils

Install cpufrequtils

sudo apt install cpufrequtils

Set the maximum CPU frequency

sudo cpufreq-set -u 4Ghz

Recover Nautilus places folders

How to recover Nautilus (File manager in Gnome) places folders.

Check ~/.config/user-dirs.dirs and make sure the following entries exist and properly setup

.config/user-dirs.dirs
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"

After saving the file, run the following command to reload Nautilus settings:

xdg-user-dirs-gtk-update

Python: Read TOML file in one line

Use pathlib to read and tomllib to parse the file. (requires Python >= 3.11)

For example, to extract Julia version from Manifest.toml

import tomllib; from pathlib import Path; print(tomllib.loads(Path("Manifest.toml").read_text())["julia_version"])

And it's easy to run in a bash shell or CI script.

python -c 'import tomllib; from pathlib import Path; print(tomllib.loads(Path("Manifest.toml").read_text())["julia_version"])'

Power limit for nvidia GPUs

You can make GPUs consume less (or more) power by setting the power limit.

Source: Puget systems

To limit power draw to 300W:

sudo nvidia-smi -pl 300

To monitor GPU power draw:

nvidia-smi -q -d POWER -l 1 | grep "Power Draw"