Skip to content

Instantly share code, notes, and snippets.

@camthesaxman
Last active June 27, 2023 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camthesaxman/70b84df731435f80c4155d2544b7460d to your computer and use it in GitHub Desktop.
Save camthesaxman/70b84df731435f80c4155d2544b7460d to your computer and use it in GitHub Desktop.
Misc. Linux Tweaks

This is a collection of various Linux system tweaks I've accumulated over the years.

Better UI font rendering on screens.

Freetype, since version 2.7 in 2016, enables the v40 interpreter by default, which does less hinting. While more accurate, fonts no longer snap to the pixel grid and appear smudgy. We can enable the old interpreter that has sharper font rendering by using the FREETYPE_PROPERTIES environment variable. Put this in a .sh script within /etc/profile.d to enable globally

export FREETYPE_PROPERTIES="truetype:interpreter-version=35"

The DejaVu and Ubuntu fonts work very well with this setting and are a good choice for your GUI.

Dealing with limited memory

By default, Linux gives memory to processes much like how a bank gives money. Processes can ask for as much memory as they could ever dream of, and Linux will happily tell them that the memory is available for use, even if it ends up exceeding the total virtual memory (physical RAM and swap) in the system. When enough processes try to do this, the system grinds to a halt becoming completely unresponsive for several minutes until the OOM killer kills the process that is hogging memory. So, instead of malloc failing when not enough memory is available, it will always succeed, and your process will get killed at some arbitrary, inconvenient time. To prevent this and use the sane behavior where memory allocations can fail, add these two lines to /etc/sysctl.conf

vm.overcommit_memory = 2
vm.overcommit_ratio = 100

Installing software from source just for one user

You will often come across some piece of software that isn't available in your distro's package manager and must be installed from source. /usr/local is a common place to install such software, but I personally install such programs to the ~/.local directory and add export PATH="$HOME/.local/bin:$PATH" to my .bashrc file. Installing software here does not require root and will never mess up packages installed through your package manager.

Check which files are being used by a process

lsof -p PID

or

lsof -p $(pgrep PROCESS_NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment