1. Information

  • Enter the following commands at a Command Line with root privileges.

    fdisk -l
    Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
    Disk model: PM9C1b Samsung 512GB
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: F1485C58-B884-4DB6-9488-E847A726EA40
    
    Device             Start        End   Sectors   Size Type
    /dev/nvme0n1p1      2048    2099199   2097152     1G EFI System
    /dev/nvme0n1p2   2099200    2361343    262144   128M Microsoft reserved
    /dev/nvme0n1p3   2361344  680333311 677971968 323.3G Microsoft basic data
    /dev/nvme0n1p4 994899968  996927487   2027520   990M Windows recovery environment
    /dev/nvme0n1p5 996929536 1000187903   3258368   1.6G Windows recovery environment
    /dev/nvme0n1p6 680333312  978874367 298541056 142.4G Linux filesystem
    /dev/nvme0n1p7 978874368  994899967  16025600   7.6G Linux swap
    
    Partition table entries are not in disk order.

2. Installation

3. Main Configuration

3.1. Base

  • Enter the following commands at a Command Line with root privileges.

    apt-get update
    apt-get upgrade
    apt-get dist-upgrade
    apt-get autoremove
    apt-get autoclean
    
    apt-get install curl wget
    cat /etc/debian_version

3.2. Bash

  • Contents of the /etc/skel/.bash_aliases file.

    # Set default editor.
    export EDITOR=vi
    export VISUAL=vi
    # Enable ansi color output in interactive shells, except for crontab.
    unset NO_COLOR
    # Do not put duplicate lines or lines starting with space in history.
    export HISTCONTROL=ignoreboth
    # Append to history file, do not overwrite it.
    shopt -s histappend
    # Set history length.
    export HISTSIZE=10000
    export HISTFILESIZE=20000
    # Needed for openbox installation.
    export NCURSES_NO_UTF8_ACS=1
    # Disable <Ctrl-d> to prevent accidental log out.
    set -o ignoreeof
    # Don't echo control characters.
    if $(tty -s); then
      stty -echoctl
    fi
    # Show user and hostname in lime, show working directory in blue.
    # The "\[\e]0;\u@\h\a\]" string is used to change the PuTTY window title.
    # It will also get rid of the annoying "Thanks for flying Vim" title.
    PS1='\[\e]0;\u@\h\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    # Show date, time in white, show user and hostname in lime, show working directory in blue.
    # The "\[\e]0;\u@\h\a\]" string is used to change the PuTTY window title.
    # It will also get rid of the annoying "Thanks for flying Vim" title.
    PS1='\[\e]0;\u@\h\a\]${debian_chroot:+($debian_chroot)}\[\033[01;37m\]\D{%Y-%m-%d} \t \[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$ '
    # Alias definitions.
    if [ -f ~/.bashrc_aliases ]; then
      . ~/.bashrc_aliases
    fi
  • Contents of the /etc/skel/.bashrc_aliases file.

    # A trailing space in the alias value causes the next word to be checked
    # for alias substitution when the alias is expanded. E.g. "sudo dir /".
    alias sudo='sudo '
    # Alias for hexadecimal dump.
    alias hex='od -t x1'
    # Aliases for diff that ignore case and white space.
    alias diff-i='diff -i'
    alias diff-w='diff -w'
    alias diff-iw='diff -i -w'
    # Aliases for git.
    #alias git-diff="git difftool -x '/usr/bin/diff' -y"
    #alias git-diff-c="git difftool -x '/usr/bin/diff --color' -y"
    #alias git-diff-i="git difftool -x '/usr/bin/diff -i' -y"
    #alias git-diff-w="git difftool -x '/usr/bin/diff -w' -y"
    #alias git-diff-iw="git difftool -x '/usr/bin/diff -iw' -y"
    #alias git-diff-icw="git difftool -x '/usr/bin/diff --color -iw' -y"
    #alias git-incoming="git fetch && git log ..origin"
    #alias git-log="git log --pretty=format:'%C(yellow)Commit %h%Creset%nAuthor: %an <%ae>%nDate: %ai%nMessage: %s%n'"
    #alias git-outgoing="git fetch && git log origin.."
    #alias git-status="git status -s"
    alias git-diff='git difftool -x "/usr/bin/diff" -y'
    alias git-diff-c='git difftool -x "/usr/bin/diff --color" -y'
    alias git-diff-i='git difftool -x "/usr/bin/diff -i" -y'
    alias git-diff-w='git difftool -x "/usr/bin/diff -w" -y'
    alias git-diff-iw='git difftool -x "/usr/bin/diff -iw" -y'
    alias git-diff-icw='git difftool -x "/usr/bin/diff --color -iw" -y'
    alias git-incoming='git fetch && git log ..origin'
    alias git-log='git log --pretty=format:"%C(yellow)Commit %h%Creset%nAuthor: %an <%ae>%nDate: %ai%nMessage: %s%n"'
    alias git-outgoing='git fetch && git log origin..'
    alias git-status='git status -s'
    # Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries.
    alias jsdiff='diff --exclude=.git --exclude=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js'
    alias jsgrep='grep --exclude-dir=.git --exclude-dir=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js'
    alias jslint='jslint --browser --indent=2 --maxerr=999 --nomen --white --windows'
    alias jshint-all='find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jshint {} \;'
    alias jslint-all='find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jslint --browser --indent=2 --maxerr=999 --nomen --white --windows {} \;'
    # Fix syntax highlighting when editing crontab.
    # See https://unix.stackexchange.com/questions/68972/no-syntax-highlighting-when-editing-crontab
    alias crontab='EDITOR=vi crontab'
    # JSLint customization.
    # Note: Options give problems when added alphabetically.
    alias jslint='jslint --todo --nomen --white --windows --browser --indent=2 --unparam --maxerr=999'
    # Several aliases for list command.
    # The LC_COLLATE=C makes the ls command show hidden files and folders first.
    alias vdir='ls --color=auto --escape --show-control-chars -l'
    alias dir='ls --color=auto --escape --show-control-chars'
    alias ls='LC_COLLATE=C ls --color=auto --show-control-chars'
    alias ll='LC_COLLATE=C ls --color=auto --show-control-chars -l'
    alias l='ls --color=auto --show-control-chars -lA'
    # Some aliases to prevent making mistakes.
    alias cp='cp -i'
    alias mv='mv -i'
    alias rm='rm -i'
    # Some aliases for ANC clients.
    alias iw-scan='iw dev wlan0 scan | grep -Ei "^BSS|freq:|signal:|SSID:" | grep -Eiv "HESSID:"'
    alias iwlist-scan='iwlist wlan0 scan | grep -Ei "Cell|Freq|Qual|SSID"'
  • Enter the following commands at a Command Line with root privileges.

    user="delta"
    file="/root/.bashrc"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then cp -a "${file}" "${file}.org"; fi
    # Copy skeleton files to root account.
    /bin/cp -a /etc/skel/.bash_aliases /root
    /bin/cp -a /etc/skel/.bashrc /root
    /bin/cp -a /etc/skel/.bashrc_aliases /root
    
    file="/home/${user}/.bashrc"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then cp -a "${file}" "${file}.org"; fi
    # Copy skeleton files to user account.
    /bin/cp -a /etc/skel/.bash_aliases "/home/${user}"
    /bin/cp -a /etc/skel/.bashrc "/home/${user}"
    /bin/cp -a /etc/skel/.bashrc_aliases "/home/${user}"
    chown "${user}:${user}" "/home/${user}/.bash_aliases"
    chown "${user}:${user}" "/home/${user}/.bashrc"
    chown "${user}:${user}" "/home/${user}/.bashrc_aliases"
    # Change color of root prompt from lime to red.
    sed -i "s/lime/red/"  /root/.bash_aliases
    sed -i "s/;32m/;31m/" /root/.bash_aliases

3.3. Cron

  • Enter the following commands at a Command Line with root privileges.

    file="/etc/environment"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then cp -a "${file}" "${file}.org"; fi
    # Set NO_COLOR environment variable to prevent ansi color output in cron jobs.
    if ! grep -q "NO_COLOR=" "${file}"; then
      echo "NO_COLOR=true" >> "${file}"
    fi

3.4. Desktop Environment

3.4.1. Cosmic

  • See https://software.opensuse.org/download/package?package=cosmic-osd&project=home%3Anomispaz%3Adebian%3Acosmic-desktop.

  • Enter the following commands at a Command Line with root privileges.

    apt-get install gpg
    apt-get install gnupg
    
    echo 'deb http://download.opensuse.org/repositories/home:/nomispaz:/debian:/cosmic-desktop/Debian_13/ /' |
      tee /etc/apt/sources.list.d/home:nomispaz:debian:cosmic-desktop.list
    curl -fsSL https://download.opensuse.org/repositories/home:nomispaz:debian:cosmic-desktop/Debian_13/Release.key |
      gpg --dearmor | tee /etc/apt/trusted.gpg.d/home_nomispaz_debian_cosmic-desktop.gpg > /dev/null
    apt-get update
    apt-get install cosmic-session
  • Note: When the system suspends the user interface and any SSH sessions become unresponsive.

  • Select COSMIC Settings.

  • Select Power & Battery.

  • Select Automatic suspend | Never.

    Turn off the screen after       15 minutes
    Automatic suspend               Never

3.5. Sudo

  • Enter the following commands at a Command Line with root privileges.

    apt-get install sudo
    
    # Configure sudo.
    file="/etc/sudoers"
    user="delta"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then cp -a "${file}" "${file}.org"; fi
    # Configure sudo to ask for root password.
    if ! grep -iq "Defaults[[:space:]]rootpw" "${file}"; then
      sed -i "/Defaults\tmail_badpass$/a Defaults\trootpw" "${file}"
    fi
    # Allow user account to use sudo.
    if ! grep -q "^sudo.*${user}" /etc/group; then
      usermod --append --groups sudo "${user}"
    fi
    # Remove first time lecture about sudo.
    mkdir -p /var/lib/sudo/lectured
    file="/var/lib/sudo/lectured/${user}"
    touch                "${file}"
    chmod 600            "${file}"
    chown "root:${user}" "${file}"

3.6. Syslog Journal

  • Enter the following commands at a Command Line with root privileges.

    apt-get install rsyslog
    
    if cat /etc/os-release | grep -Eiq "Bullseye|Bookworm|Trixie"; then
      # Disable systemd-journald.
      file="/etc/systemd/journald.conf"
      # Back up original file if backup file is missing.
      if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then cp -a "${file}" "${file}.org"; fi
      sed -i "s/#Storage=.*/Storage=none/" "${file}"
      sed -i "s/#ForwardToSyslog=.*/ForwardToSyslog=yes/" "${file}"
      systemctl restart rsyslog
      systemctl restart systemd-journald
      diff "${file}.org"  "${file}"
    fi
  • Restart the computer.

4. More Configurations

4.1. Git

  • Enter the following commands at a Command Line.

    sudo apt-get install git
    
    mkdir -p ~/GitHub
    cd ~/GitHub
    git clone https://github.com/delta-software-labs/Documentation.git
    git clone https://github.com/delta-software-labs/Linux-Tools.git
    git clone https://github.com/delta-software-labs/Windows-Tools.git

4.2. Mozilla Firefox

  • Enter the following commands at a Command Line.

    sudo apt-get install firefox-esr

4.3. NTFS

  • Enter the following commands at a Command Line.

    sudo mkdir -p /mnt/usb
    sudo mkdir -p /mnt/windows
    sudo apt-get install cryptsetup ntfs-3g
    sudo cryptsetup --version

4.3.1. Drive without BitLocker

  • Enter the following commands at a Command Line.

    sudo blkid
    
    # Mount the drive.
    sudo mount -t vfat /dev/sda1 /mnt/usb
    # Do your thing.
    sudo umount /mnt/usb
    ls -al /mnt/usb
    
    # Mount the drive at boot time.
    file="/etc/fstab"
    line1="# windows was on /dev/nvme0n1p3 during installation"
    line2="dev/nvme0n1p3 /dev/mapper/windows /mnt/windows ntfs-3g rw,uid=1000,gid=1000,dmask=0002,fmask=0003 0 0"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then sudo cp -a "${file}" "${file}.org"; fi
    if ! grep -q "${line2}" "${file}"; then
      echo "${line1}" | sudo tee --append "${file}" > /dev/null
      echo "${line2}" | sudo tee --append "${file}" > /dev/null
    fi
    sudo systemctl daemon-reload
    diff "${file}.org" "${file}"

4.3.2. Drive with BitLocker

  • See https://superuser.com/questions/376533/how-to-access-a-bitlocker-encrypted-drive-in-linux.

  • Enter the following commands at a Command Line.

    sudo blkid | grep BitLocker
    sudo mkdir /etc/cryptsetup-keys.d
    sudo cp -a /mnt/usb/HOMENB-FRL01/HOMENB-FRL01.bek /etc/cryptsetup-keys.d
    sudo chmod 600 /etc/cryptsetup-keys.d/HOMENB-FRL01.bek
    sudo ls -al /etc/cryptsetup-keys.d/HOMENB-FRL01.bek
    
    # Open the BitLocker drive with a recovery key.
    sudo cryptsetup bitlkOpen /dev/nvme0n1p3 windows
    sudo mount /dev/mapper/windows /mnt/windows
    # Do your thing.
    sudo umount /mnt/windows
    sudo cryptsetup close windows
    ls -al /dev/mapper
    ls -al /mnt/windows
    
    # Open the BitLocker drive with a key file.
    sudo cryptsetup open --type=bitlk --key-file=/etc/cryptsetup-keys.d/HOMENB-FRL01.bek /dev/nvme0n1p3 windows
    sudo mount /dev/mapper/windows /mnt/windows
    # Do your thing.
    sudo umount /mnt/windows
    sudo cryptsetup close windows
    ls -al /dev/mapper
    ls -al /mnt/windows
    
    # Open the BitLocker drive at boot time.
    # Todo: Fails at boot. Needs some delay.
    file="/etc/crypttab"
    line="#windows PARTUUID=f5e50210-0a71-49ad-b9b5-1408cfefaa07 /etc/cryptsetup-keys.d/HOMENB-FRL01.bek bitlk"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then sudo cp -a "${file}" "${file}.org"; fi
    if ! grep -q "${line}" "${file}"; then
      echo "${line}" | sudo tee --append "${file}" > /dev/null
    fi
    diff "${file}.org" "${file}"
    
    # Mount the BitLocker drive at boot time.
    # Todo: Fails at boot. Needs some delay.
    file="/etc/fstab"
    line1="# windows was on /dev/nvme0n1p3 during installation"
    line2="#/dev/mapper/windows /mnt/windows ntfs-3g rw,uid=1000,gid=1000,dmask=0002,fmask=0003 0 0"
    # Back up original file if backup file is missing.
    if [ -f "${file}" ] && [ ! -f "${file}.org" ]; then sudo cp -a "${file}" "${file}.org"; fi
    if ! grep -q "${line2}" "${file}"; then
      echo "${line1}" | sudo tee --append "${file}" > /dev/null
      echo "${line2}" | sudo tee --append "${file}" > /dev/null
    fi
    sudo systemctl daemon-reload
    diff "${file}.org" "${file}"
  • Create commands to unlock + mount and umount + lock BitLocker partition.

  • Enter the following commands at a Command Line.

    # Create commands.
    file="/usr/local/sbin/mount-windows"
    sudo touch "${file}"
    sudo chmod +x "${file}"
    # Do not use single quotes around EOF to allow interpreting variables.
    cat << EOF | sed -e "s/^  //" | sudo tee "${file}" > /dev/null
      # Function:   Unlock and mount windows partition.
      # Parameters: None.
      # Returns:    None.
      mount_windows () {
        mkdir -p /mnt/windows
        if [ ! -e /dev/mapper/windows ]; then
          cryptsetup open --type=bitlk --key-file=/etc/cryptsetup-keys.d/HOMENB-FRL01.bek /dev/nvme0n1p3 windows
        fi
        if ! mount | grep -q '/mnt/windows'; then
          mount /dev/mapper/windows /mnt/windows
        fi
      }
      mount_windows
    EOF
    file="/usr/local/sbin/umount-windows"
    sudo touch "${file}"
    sudo chmod +x "${file}"
    cat << EOF | sed -e "s/^  //" | sudo tee "${file}" > /dev/null
      # Function:   Unmount and lock windows partition.
      # Parameters: None.
      # Returns:    None.
      umount_windows () {
        if mount | grep -q '/mnt/windows'; then
          umount /mnt/windows
        fi
        if [ -e /dev/mapper/windows ]; then
          cryptsetup close windows
        fi
      }
      umount_windows
    EOF

4.5. Users

  • Enter the following commands at a Command Line.

    sudo useradd --comment "Douwe Kiestra" --create-home --shell /bin/bash douwe
    sudo passwd douwe

4.6. Vim

  • Enter the following commands at a Command Line.

    sudo apt-get install vim
    
    # Create backup directories.
    sudo mkdir -p /root/.vim/backup
    mkdir -p /home/delta/.vim/backup
    
    # Make vim.basic the default editor.
    sudo update-alternatives --set editor /usr/bin/vim.basic
  • Contents of the /etc/vim/vimrc.local file.

    if exists('${DISPLAY}')
      " Running under X11.
      " Set default background color after detecting terminal background color.
      set background&
    else
      " Running on console.
      set background=dark
    endif
    
    autocmd BufEnter * :syntax sync fromstart
    
    autocmd BufNewFile,BufWinEnter * setlocal cinoptions=
    autocmd BufNewFile,BufWinEnter * setlocal formatoptions-=c
    autocmd BufNewFile,BufWinEnter * setlocal formatoptions-=o
    autocmd BufNewFile,BufWinEnter * setlocal formatoptions-=r
    autocmd BufNewFile,BufWinEnter * setlocal formatoptions-=t
    autocmd BufNewFile,BufWinEnter * setlocal indentkeys=
    autocmd BufNewFile,BufRead     * setlocal mouse=
    autocmd BufNewFile,BufWinEnter * setlocal nocindent
    autocmd BufNewFile,BufWinEnter * setlocal nosmartindent
    
    "colorscheme industry
    
    " Custom asciidoctor syntax highlighting.
    highlight link asciidocListingBlock Type
    highlight link asciidocLiteralBlock Statement
    highlight link asciidocLiteralParafraph Statement
    
    " Fix cursor in Windows Terminal after using vim.
    " Cursor settings:
    " 1 -> blinking block
    " 2 -> solid block
    " 3 -> blinking underscore
    " 4 -> solid underscore
    " 5 -> blinking vertical bar
    " 6 -> solid vertical bar
    let &t_SI = "\<Esc>[1 q"
    let &t_SR = "\<Esc>[1 q"
    let &t_EI = "\<Esc>[1 q"
    
    set encoding=utf-8
    set hlsearch
    set ignorecase
    set modeline
    set noautoindent
    set printoptions=paper:a4
    set title
    set viminfo='100,<500,s10,h
    set wrap
    
    " Save backup, swap and undo files in your home folder.
    " Backups will persist across reboots and only be accessible to you.
    " The double slash (//) tells Vim to use the full path of the file being edited to create the backup filename,
    " which prevents filename collisions when having files with the same name in different directories.
    " Vim will still use /tmp and the current directory as fallback options if the primary folder is not writable.
    set backup
    set backupdir=$HOME/.vim/backup//,/tmp//,.
    set directory=$HOME/.vim/backup//,/tmp//,.
    set undodir=$HOME/.vim/backup//,/tmp//,.

5. Other Configurations

5.1. Dropbox

  • Enter the following commands at a Command Line.

5.2. KeePassXC

  • Enter the following commands at a Command Line.

    sudo apt-get install keepassxc

5.3. VirtualBox

  • Enter the following commands at a Command Line.