1Desired file system layout for personal computer?

  • /boot: 1 GB primary partition (Linux kernel is getting fatter)
  • /usr: 128 GB LVM logical volume
  • /mess: 256 GB LVM logical volume
  • /: 64 GB encrypted LVM logical volume
  • /rescue: 8 GB LVM logical volume, minimal Debian installation

To avoid problems with early boot, we don't symlink.

But if I encrypt all of home, sshd authorizedkeys may not work.1

2<2019-01-08> Debian 10: Turn off bell/beep

https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/turn-off-the-annoying-bell-pc-speaker-in-debian-etch-594405/

Several options:

  • xset b off
  • /etc/inputrc
  • rmmod pcspkr and blacklist it; the nuclear option

3<2018-12-11> Prepare OS upgrade?

3.1What

Move from Ubuntu 14.04 to Debian unstable https://www.reddit.com/r/linux/comments/40peeb/security_debian_vs_ubuntu/

Don't buy any laptop outside this list. https://www.linux-on-laptops.com/

Make moving easy.

Burn a Debian Live CD.

Debian is huge. The Debian community is huge. It's overwhelming. It's unclear where to start. The Debian project needs to delete things. The [Debian front page](https://www.debian.org/) has too much information.

"several Debian developers advise people to not use testing. Why is that?" https://raphaelhertzog.com/2010/10/04/can-debian-offer-a-constantly-usable-testing-distribution/

  • https://www.debian.org/doc/manuals/debian-reference/apa.en.html#_the_debian_maze
    • "The Debian Reference was initiated by me, Osamu Aoki […], as a personal system administration memo."
    • "I hope this […] provides a good starting direction for people in the Debian maze."
  • Debian Documentation Project https://www.debian.org/doc/ddp
    • "The Debian Documentation Project was formed to coordinate and unify all efforts to write more and better documentation for the Debian system."
  • Debian testing gets no security updates. debsecan + Debian unstable + APT pinning?
  • Debian testing freezes some time before stable release and after stable release.
  • Debian unstable + get in touch with Debian community + APT pinning.
  • Do not apt-get upgrade if you have no time to fix problems.

Prerequisites?

  • Understand advanced APT usage.
  • Read the Debian manual.
  • Always read the Release Notes before installing Debian stable. (Where?)

As we get older, we set up rules to simplify our lives. Example of rules:

  • Never sudo make. Only use sudo with the part that comes from Debian.
  • Always put house keys and car keys in the front pocket of the bag when not using those keys.
  • Never pick up a call from an unknown number.

Enable Magic SysRq key:

  • Read /etc/sysctl.d/README.
  • Symlink /etc/sysctl.d/10-magic-sysrq.conf.

How to install Debian unstable:

  • Minimal-install Debian latest stable, upgrade to testing, install GUI, pin APT, upgrade to unstable.

Always check apt-get install plan. Don't just answer "yes". If the plan doesn't look sane, wait for a few days.

Dump and backup LVM metadata to GitHub? Is this not sensitive data?

Why must APT binary packages be installed to a fixed location? Because ELF hardcodes "rpath". NixOS patches ELF rpath.

Buy an SSD?

Use "brasero" to burn ISO to DVD. https://wiki.debian.org/BurnCd#Burn_the_image_file_to_CD.2C_DVD.2C_or_BD

How a Debian user is supposed to install a recent version of some packages: A Debian user is not supposed to install any recent version of packages.

How an advanced Debian user is supposed to install a recent version of some packages:

  • Install Debian stable.
  • Add testing repository.
  • Set up APT pinning:
    • Most things come from stable.
    • System packages come from stable.
    • GHC comes from testing.
  • Always check APT install plan. Avoid reinstalling system packages such as libc, python, perl, gnome, xorg, and so on. If installing something from testing requires removing something from stable, then say no to the apt prompt.
  • Does anything break?

3.2Unanswered questions

Which distro has the best governance (the best social system, and the most trustworthy and competent people)?

Which distro has the most packages?

Which distro has the most volunteers?

Fedora ships with SELinux enabled?

My university used Debian and Ubuntu.

4Woes upgrading to Debian 9

4.1GCC 6 PIE breaks GHC

GCC 6 PIE defaulting breaks GHC. Should Debian package ghc as several packages such as ghc-7.6, ghc-8.4, not as one package ghc with several versions? One Debian package per GHC minor version? Alternatives system? Like openjdk-6 and openjdk-7? Like python2 and python3?

4.2No GNOME Night Light

GNOME Night Light is not in Debian 9 (gnome-shell 3.22).2

4.3Massive Debian 9 Chromium privacy violation

On 2018-12-20, I fresh-install Debian 9.6. Chromium enables "Allow Chromium sign-in" without asking user consent.34

That's the last straw. I'm switching to firefox. I'm using chromium for privacy violators and shady companies:

  • google, youtube
  • facebook

4.4GNOME 3 woes

4.4.1Totem video player

Toem used to display playlist but it was removed because it was deemed "too complex" https://bugs.launchpad.net/ubuntu/+source/totem/+bug/1600606

4.4.2Fix GNOME 3 counterproductive defaults

gsettings set org.gnome.shell.app-switcher current-workspace-only true https://coderwall.com/p/m5mhoq/gnome-3-how-to-alt-tab-windows-on-current-workspace-only https://askubuntu.com/questions/653436/totem-sidebar-gone-after-upgrade-playlist

4.5git gui breaks

Ctrl+T no longer works with multiple files.

<2019-02-10> gitk gobbles insane amount of RAM.

4.6Change network DNS; NetworkManager broken

Nuke /etc/NetworkManager/system-connections and recreate that directory. https://askubuntu.com/questions/979939/network-manager-keeps-creating-new-profiles-for-the-same-network

Then connect to network.

Then stop.

sudo service NetworkManager stop

sudo nm-connection-edit

Use the GUI to manualize the DNS.

sudo service NetworkManager start

https://wiki.debian.org/NetworkManager

4.7Automatic install of updates, including security updates, should be disabled

I want to see it first before it is installed.

apt purge unattended-upgrades

5<2019-04-23> Create Debian Live USB

Get an 8 GB USB disk.

Download the Debian 9 Live ISO file.

Use dd/cp to copy the ISO file into the disk.

The Debian 9 Live ISO file is a horrible hack.5

<2019-04-23> I am trying machma.nl guide6.

6Administering a personal GNU/Linux installation (mostly Ubuntu)

6.1Bash shell programming

6.1.1Articles

6.1.2Error handling

I set these bash options in my script to make it fail fast:

6.1.3Bash pitfalls

This is bash version GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) that comes with Ubuntu 14.04.

  1. Local variable definition ignores command substitution result

    At first this seems like an unexpected interaction between function, local variable, set -e (set -o errexit), and command substitution $(cmd).

    The word local is a shell command that has an exit status, not a keyword like var in JavaScript. Bash is behaving as documented. See the documentation for local in man bash.

6.1.4Others

6.2Installing remote graphical user interface

6.2.1Goal, background, and failures

I need to run Java VisualVM on my server to profile my application.

I tried ssh -X, but it was unacceptably slow. SSH compression doesn't help; the problem is latency, not throughput.

I don't want to run an X server on the remote machine. I don't want a display server running all the time. I want to start it only when I need it.

Ubuntu help is not helpful. It doesn't even mention VNC or RDP. https://help.ubuntu.com/community/ServerGUI

VNC seems promising. Let's run VNC at the server's localhost, and connect through SSH tunneling. Let's go with TightVNC.

"VNC: A Faster Alternative to X11" https://www.nas.nasa.gov/hecc/support/kb/vnc-a-faster-alternative-to-x11_257.html

6.2.2Plan of action

We assume two machines:

  • The local machine is the machine that we use to start SSH connection.
  • The remote machine is the machine that accepts SSH connections.

What we need to do on the remote machine:

  • Install VNC server.
  • Start VNC server.
  • Stop VNC server.

What we need to do on the local machine:

  • Install VNC client/viewer.

6.2.3Installing, starting, and stopping TightVNC server on the remote machine

sudo apt-get install –no-install-recommends xfce4 tightvncserver

To start VNC server at remote localhost port 5901. 1920x1080. vncserver -localhost -nolisten tcp -geometry 1920x960 -depth 24 :1

Configure SSH LocalForward. If you have a jumpbox, you may need to forward twice.

To stop vncserver -kill :1

Start remmina. It seems to have been installed by default. The GUI should be obvious.

Sources:

6.2.4Installing TightVNC client on the local/development machine

6.2.5Path not taken

I saw these, but I did not try these.

6.3Autotools

6.4Running X client applications on Docker on Linux

docker \
    -e DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
    -u <user> <image> <command>

Replace <user> with a non-root user. You need a non-root user because the X server rejects connection from the root user by default. You can change this with xhost, but it's better to connect with a non-root user.

The <command> argument is optional.

The -e DISPLAY parameter reexports the DISPLAY environment variable to the application inside the container. X client applications will read from this environment variable to determine which server to connect to.

The -v HOST:CONT:ro option mounts HOST directory to CONT directory read-only. This is so that the application in the container can connect to the host X server's Unix socket.

On Linux, display :0 corresponds to the Unix socket /tmp/.X11-unix/X0. Everyone who can connect to that Unix socket will be able to run X client applications on the machine; it is not specific to Docker.

If X complains about shared memory, try:

docker \
    -e DISPLAY=unix$DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
    -u <user> <image> <command>

6.5Habits learned the hard way

  • I check the time at time.gov because Ubuntu 14.04 NTP once betrayed me.
    • 2018-01-16: I had always thought that it was dependable, but it betrayed me: It showed 2 a.m. while the actual time was 4 a.m.. I missed some hours of sleep.
  • I sometimes run sync, hoping to make sure my changes are written to disk.

6.6What

6.7sudo security hole mitigation: Don't reuse the terminal you use for sudo.

The problem: If you run sudo in a terminal, then every program you run in the same terminal shortly after can become root without asking for your password, (You may not have this problem if your system disables credential caching.)

To see how, save this into evil.sh, and then chmod 755 evil.sh, and then sudo echo login, and then ./evil.sh.

The security hole is by design for convenience because people don't like typing their passwords. This hole is not fatal; the user can control this. It seems that this hole won't be closed; there doesn't seem to be any way of closing this hole without annoying the user.

The mitigation is simple disciplined behavior:

  • Do as few things as necessary in an elevated terminal.
  • Run only trusted programs and scripts.
  • Close the terminal as soon as possible. Alternatively, you can also run sudo -K to remove the cache.

6.8Probably relevant Twitters

6.9Building software for old Ubuntu

Suppose:

  • You are using Ubuntu 14.04.
  • Ubuntu 14.04 comes with Emacs 24.
  • You want to build Emacs 26 (because you want Spacemacs).

You may be able to do that. Install the build dependencies, and hope that emacs 26 doesn't get too edgy with its libraries.

sudo apt-get build-dep emacs24

That is from How to Build Emacs on Linux.

You can do that for other software, as long as they don't require dependencies that are too recent.

6.10What

<2019-01-16> Ubuntu 14.04. Okular is better than Evince. Okular's "Trim Margins" feature is helpful. Okular also feels more responsive.

6.11Security


  1. <2020-01-11> https://security.stackexchange.com/questions/135499/what-is-the-point-of-encrypting-the-home-directory

  2. https://www.omgubuntu.co.uk/2017/02/gnome-night-light-blue-light-filter-linux

  3. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916320

  4. https://blog.cryptographyengineering.com/2018/09/23/why-im-leaving-chrome/

  5. https://lists.debian.org/debian-live/2017/06/msg00070.html

  6. https://www.machma.nl/DebianonUSB.html