2024-11-04

gnu/linux system setup and usage examples

much of this setup has been in use for a decade and still proves its value each day.

screenshots

single monitor

screenshot

two monitors vertically side-by-side

screenshot

boot and login: linux, bash, xserver

linux boots to a login console. after login, a luks partition (or file /home/.{username}) is decrypted and mounted to /home/{username} using pam_mount. since the users shell is configured to be bash, the contents of .bash_profile are executed, where startx is called to run an xserver instance which executes the contents of .xinitrc, where the window manager is started.

window manager: dwm

dwm handles the arrangement of xserver windows and is configured to draw no borders and with a monospace font. dwm-show-info from sph-script displays time and date.

switching between desktops in dwm is particularly fast, uninterrupted, and consistent.

custom, non-standard, keyboard shortcuts:

  • modkey+return - moves the focused window into the main area (layouts usually have one partition for one large window)
  • modkey+q, +werjkl:n - for switching to specific tags from 1-9
  • modkey+a, modkey+s - for decreasing and increasing the currently focused windows size
  • modkey+left-click - for making windows floating and moving floated windows
  • modkey+z - for hiding the status bar
  • other useful shortcuts that i do not usually use: modkey+space for switching layouts, modkey+df for moving backwards or forwards between windows

starting programs: xbindkeys

the most important commands are bound to fn keys.

  • f4 opens dmenu_run, an input field line appearing at the top of the screen where a command can be entered with autocomplete
  • other bindings: f1 web browser, f2 file manager, f3 terminal, f6 screenshot

virtual terminal: st, screen

st started with a screen session for tabs/multiplexing in any environment. st -e screen.

ctrl+a c creates new terminal buffers, ctrl+a p and ctrl+a n switch between them. this is extremely fast and surprisingly easy to physically execute, and works even on remote shells. it shows that virtual terminals do not need tab support (with keybindings for it differing between terminals).

useful custom shell commands

  • fig: search for files containing all of the given keywords
  • search: search for files with lines that contain all the given keywords and display file names
  • searchl: search for files with lines that contain all the given keywords and display lines and file names
  • rate: for moving files and directory structures under numeric rating directories
  • splice: files of the selected directories are moved into the current directory and the selected directories removed. duplicate file names are automatically renamed
  • group: move selected files into a new directory. a dialog pops up where the new directory name can be entered
  • mount-home: mount one or more sources to $HOME/mnt/{automatically-chosen-directory}
  • nargs: execute commands for each newline-separated line read from standard input, xargs
  • repl: createn an input field for any command and keep re-executing it with user supplied arguments
  • see also sph-script

other customizations

  • cursor blinking disabled on the console, the virtual terminal, and programs using the graphical programming frameworks gtk2.0, gtk3.0, and qt. (tty-no-cursor-blink)
  • files are initially created as readable only by the creator, this is achieved by using a default umask of 077. some systems give all users read access to created files
  • xmodmap to make the right shift-key work as the meta key and to disable the shift-lock key
  • custom x11 keyboard layout to use the qgmlwb layout and an additional dead-key (a key that only modifies a subsequent key) for diaresis on shift together with the less-than greater-than key
  • versioned system configuration using git and symlinks
  • user name: nonroot

file manager: thunar

extensive use of thunars easily configurable custom right click commands. for example: splice, rate, group, and move-up.

batch renaming: when multiple files are selected, right-click -> rename will open a featureful batch renamer which can also be started with "thunar -B", "thunar -B *", or "find . | thunar -B".

linux distribution: arch linux

  • it keeps applications as made by upstream, unlike debian, which makes extensive changes to applications to make them debian specific and require debian dependent knowledge (they even add debian logos to some apps)
  • comes installed with small set of applications that is enough to boot to a console
  • always get the current version of packages. the packages went through a public testing phase in a testing repository. avoids having to manually compile things because you need a version that is already six months old and not in the repositories for your distribution version. on ubuntu, you might spent a substantial amount of time searching and compiling newer versions of software yourself, for example new drivers and kernels if you bought a new graphics card. also avoids risky full distro upgrades, they just do not exist with arch because the system updates gradually with each package. manual intervention is rarely required, and if then only on important big changes like the switch to systemd or demanded by upstream developers of the used software
  • the package manager is a relief, in comparison to apt-get/apt-cache/dpkg. finally an efficient to use program that is fast and gives terse and clear output. packages are very easy to create, the only thing needed is basically a bash script that does the compile and installation steps. users can upload packages to the separate arch user repository but it is also trivially easy to create your own packages. official packages are signed
  • on one workstation i have been running the same arch system for 8 years, which started as a 32bit system and was in-place converted to 64bit. arch can also be in-place converted into parabola linux, which is fsf endorsed
  • used as a base system for steamos, the operating of the steam deck

custom shell prompt

the prompt is the basename of the current directory on its own line in magenta

example session:

~
  echo test
test
~
  cd /usr/bin
bin
  ls guile
guile
bin

example configuration files

~/.bash_profile

if test "$(tty)" == /dev/tty1
then
  exec startx
fi

~/.xinitrc

xmodmap /home/nonroot/.xmodmap
xbindkeys &
st -e screen &
dwm

~/.xbindkeysrc.scm

(xbindkey (quote (F1)) "firefox")
(xbindkey (quote (F2)) "thunar")
(xbindkey (quote (F3)) "st -e screen")
(xbindkey (quote (F4)) "dmenu_run")
(xbindkey (quote (F5)) "screenshot")

~/.xmodmap

remove lock = Caps_Lock
remove shift = Shift_R Shift_L
add mod1 = Shift_R
remove mod1 = Alt_L Alt_R

/etc/bash.bashrc

# custom colors for ls
# light
#LS_COLORS='rs=0:di=04;30:ln=01;30:pi=34;01:so=00:do=00:bd=40;33;01:cd=00:or=01;31:su=00:sg=00:tw=00:ow=00;30:st=00:ex=40;37:*.tar=00;33:*.tgz=00;33:*.lzma=00;33:*.zip=00;33:*.z=00;33:*.gz=00;33:*.bz2=00;33:*.bz=00;33:*.tbz2=00;33:*.tz=00;33:*.deb=00;33:*.rpm=00;33:*.jar=00;33:*.rar=00;33:*.cpio=00;33:*.7z=00;33:*.jpg=00;32:*.jpeg=00;32:*.gif=00;32:*.bmp=00;32:*.tif=00;32:*.tiff=00;32:*.png=00;32:*.svg=00;32:*.svgz=00;32:*.xcf=00;32:*.pcx=00;32:*.mov=00;36:*.mpg=00;36:*.mpeg=00;36:*.m2v=00;36:*.mkv=00;36:*.ogm=00;36:*.mp4=00;36:*.m4v=00;36:*.vob=00;36:*.wmv=00;36:*.asf=00;36:*.avi=00;36:*.flv=00;36:*.aac=00;35:*.flac=00;35:*.mid=00;35:*.midi=00;35:*.mka=00;35:*.mp3=00;35:*.mpc=00;35:*.ogg=00;35:*.wav=00;35:*.scm=00;34:*.rb=00;31:*.txt=00;30:*.pdf=00;34:*.doc=00;34:';

# dark
export LS_COLORS='rs=0:di=04;37:ln=01;37:pi=34;01:so=00:do=00:bd=40;33;01:cd=00:or=00;31:su=00:sg=00:tw=00:ow=00;37:st=00:ex=00;37:*.tar=00;33:*.tgz=00;33:*.xz=00;33:*.lzma=00;33:*.zip=00;33:*.tar.zst=00;33:*.z=00;33:*.gz=00;33:*.bz2=00;33:*.bz=00;33:*.tbz2=00;33:*.tz=00;33:*.deb=00;33:*.rpm=00;33:*.jar=00;33:*.rar=00;33:*.cpio=00;33:*.7z=00;33:*.jpg=00;32:*.jpeg=00;32:*.gif=00;32:*.bmp=00;32:*.tif=00;32:*.tiff=00;32:*.png=00;32:*.svg=00;32:*.svgz=00;32:*.xcf=00;32:*.pcx=00;32:*.mov=00;36:*.mpg=00;36:*.mpeg=00;36:*.m2v=00;36:*.mkv=00;36:*.ogm=00;36:*.mp4=00;36:*.m4v=00;36:*.vob=00;36:*.wmv=00;36:*.asf=00;36:*.avi=00;36:*.flv=00;36:*.aac=00;35:*.flac=00;35:*.mid=00;35:*.midi=00;35:*.mka=00;35:*.mp3=00;35:*.mpc=00;35:*.ogg=00;35:*.wav=00;35:*.scm=00;37:*.rb=00;31:*.txt=00;37:*.pdf=00;37:*.doc=00;37:';

export HISTCONTROL='ignoreboth:erasedups'  # ignore duplicate commands from shell history
export TERM=xterm-256color  # make most terminals use 256 colors
export PS1="\e[0;35m\W\e[m\n  "  # set the prompt
export PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}\007"' # terminal window title
export EDITOR=nano
umask 0077  # relatively restrictive default permissions for new files (600)
unset HISTFILE  # disable the .bash_history file. cycling through previous commands of the current session still works

~/.config/gtk-3.0/settings.ini

[Settings]
gtk-theme-name=Windows-10-Dark
gtk-icon-theme-name=HighContrast
gtk-font-name=Cantarell 11
gtk-cursor-theme-name=Adwaita
gtk-cursor-theme-size=0
gtk-cursor-blink = false
gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
gtk-button-images=0
gtk-menu-images=0
gtk-enable-event-sounds=0
gtk-enable-input-feedback-sounds=0
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintmedium

~/.gtkrc-2.0 (can be managed with lxappearance)

gtk-cursor-blink = 0
include "/home/nonroot/.gtkrc-2.0.mine"
gtk-theme-name="Windows-10-Dark"
gtk-icon-theme-name="HighContrast"
gtk-font-name="Cantarell 11"
gtk-cursor-theme-name="Adwaita"
gtk-cursor-theme-size=0
gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
gtk-button-images=0
gtk-menu-images=0
gtk-enable-event-sounds=0
gtk-enable-input-feedback-sounds=0
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle="hintmedium"

~/.config/qt6ct/qt6ct.conf, ~/.config/qt6ct/qt5ct.conf

[Interface]
cursor_flash_time=0

versioned system configuration

stored in a git repository with a file structure like this

data
  {hostname} ...
    {root-relative-full-paths}

symlinked to target destinations with "cp -rst / $PWD/data/hostname/*"