Brief Thoughts on Fairness, Equality & Hierarchy

Another day, another semi-coherent ramble. These thoughts need tightening up and some underlying structure added. But I thought I’d put them down as something to do in an evening.

Climb that social ladder

Ape societies are naturally hierarchical. This refutes the pre-Fall equality that characterised early Christian thought and continued into “noble savage” philosophies of later eras. Plato & Aristotle were on the right path.

However, Plato and Aristotle were writing from positions of privilege; they were not slaves but reasonably well-off men. Their concluding views appear to support the societal structure that worked out well for them. This bias may not have been conscious. Their arguments have been used for millennia by the aristocracy to support rule by the aristocracy. That should at least make us pause and seek out an opinion from the other side.

Hierarchies in all ape societies are a curious mixture of nature and nurture. Stronger apes tend to occupy higher social positions; executives of companies are taller and more attractive than their peers. But the shuffle of the genes means that intelligence, aptitude and physical prowess also emerge relatively randomly across the hierarchy. And fate can take as well as give; diseases and disasters strike with little regard for simian organisation. These two factors, over time, create the dynamics of politics: every ally is a potential usurper and everyone wants the rewards of the alpha ape.

What Plato and Aristotle may have ignored was time. They lived in a static and eternal universe. The nature hierarchies were always there. The aristocracy was in its proper unchanging place. But what happens when our hierarchies change over time with fate and the cards of nature? The glorious meritocracy. The belief structure of the modern aristocracy: we are at the top because the game of life has shown we are the best. Just as long as no one notices the game is rigged.

Time is also the downfall of meritocracy as a belief system for political organisation. Over time good luck clusters and compounds. If you are born into a stable country and family, have stable finances, food and housing, your benefits will feedback: you are more likely to get an education and find a job that at least matches your advantage. If you are able to increase your advantage by a few percent per year, then you can double your standing over a generation. If fate takes, you are down but not out. Synergies abound: a good genetic hand on intelligence, aptitude and physical prowess plus a stable pathway (give or take) means it is likely you will spend your fertile years mixing with similar levels of the hierarchy, your offspring then have a boost from both sides. This applies to baboons in the Rift Valley and to humans in university campuses and capital cities. The balance is a difficult one, prevent fate causing suffering and you tend to calcify the hierarchies.

Meritocracy also suffers from the lacuna that inflicted Plato and Aristotle: those that are in a position to enter the canon of written thought need an education and freedom from want that is only available at upper echelons of the hierarchy. Even if hierarchies are “natural”, if those at the bottom unduly suffer, are they “right”? Many simian studies show that life at the lower rungs leads to more stress and early death. Supporters of “natural” hierarchies tend to lack an awareness of life below their position, and seldom ask the question of whether these hierarchies benefit everyone.

John Rawls is one of the best for frameworks of justice that support everyone fairly. His famous philosophy can be brutally paraphrased as: design societies so you would be happy if you were randomly assigned to any role within that society. It’s really a twist on the Golden Rule: do unto others as you want them to do unto you (and don’t do unto others what you don’t want them to do to you). Thinking about hierarchies, it becomes: if hierarchies cannot be avoided, structure them to minimise your suffering if you were randomly parachuted into any level (or to maximise your happiness, if you are more optimistic). This works surprisingly well for both ends of the hierarchy – it means we don’t want an overworked President as much as a disease-ridden vagrant. We can also add time back in: design a society where you would be happy to move up and down the levels.

Of course, the struggle is putting these ideas into practice. At any level of the hierarchy all you tend to see are reflections of your self. At higher levels of the hierarchy, the solution for all levels is often: make them more like us; at lower levels, the solution for all levels is often: make them less like us. With limited resources and a dynamic nature-fate tag-team, this is not possible. Indeed, societies founded on an idea of equality tend to be the most unequal. It also discounts truth available at lower levels of the hierarchy, while condoning falsehoods at the higher levels.

Another problem is a natural loss aversion. If you have worked hard to gain wealth or support your family, you naturally balk at any suggestion to redistribute these advantages (at the loss of your family) to those you perceive haven’t put in the effort or sacrifice. Tell most people that they need to take a 10% pay cut for someone else’s benefit and they’ll tell you to piss off. Tell them they have a 5% pay cut but someone else in the hierarchy (up or down) has a 10% cut and they may acquiesce.

Our hierarchies are also nested and local. We care about relative not absolute distance. A lowly ape in a Garden of Eden will socially feel as bad as one in a desert plain (even though the latter’s life expectancy may be much shorter). Those living in run-down estates in Western Europe have a material quality of life that is much better than the favelas of the developing world, but the stress of living in both places is similar. Those critical of immigration often miss this one as well; many migrants to developed countries are actually in the mid-to-upper levels of home hierarchies, the perceived fall in level following immigration leads to psychological suffering despite material progress. It tends to be their children who grow up with improved material circumstances but carry the mental baggage of that suffering. This is an unspoken truth in a rapidly globalising world.

So what can we do?

Nordic countries provide some suggestions. If the hierarchies exist, at least make the distance comprehensible. Reduce the distance along certain dimensions. Encourage mixing across hierarchies. Attempt to avoid Malthusian competition. Have different dimensions of hierarchy that are negatively correlated. Material, intellectual and spiritual dimensions are not always positively correlated. Each may be valid and encouraged. Attempt to avoid policies or behaviour that calcify privilege. Positively invest against clustering (clustering will be fine on its own). Safety nets and public services are generally good (but not necessarily totemic or always good). Use evidence-based policy; ask rather than assume.


MongoDB with Docker – Quick Refresh

Quick refresh on one way to manage a Mongo database for access by Python programs.

Set a directory to store the database. Let’s call this /mnt/mongodata.

Then run a docker container with the most recent version of MongoDB:

docker run --name mongoserver -p 27017:27017 -v /mnt/mongodata:/data/db  mongo.

Just for completeness:

  • the “–name” flag allows us to start/stop our container easily using the name rather than an ID;
  • the “-p” flag exposes the port so that other computers on the network can access the database; and
  • the “-v” flag maps the local directory to the /data/db directory in the container (where Mongo stores its data).

When using Docker Compose and building more advanced systems it is recommended to use named volumes. The problem with named volumes is that all the data is stored in “/var/lib/docker/volumes/” and I have some big databases that mean I’m constantly running out of space. One solution is to maybe mount a logical volume to “/var/lib/docker/volumes/” before creating the volumes that is managed separately from the “/” logical volume.

Amateur Dev-Ops: Setting Up an Ubuntu Server

This post sets out the steps I performed to configure a new (physical) Ubuntu Server.

black and grey device
Photo by Pixabay on

I chose a physical server over a cloud server (e.g. as provided by Google, Amazon or Digital Ocean) as I wanted to build up my server administration skills while retaining  direct control of my data and processes. I chose Ubuntu as I am already familiar with the desktop variants.


I started out with a Dell PowerEdge T130 Tower Server. This is their small business entry-model, costing around £650 (with VAT) with an Intel Xeon E1220 4-core processor, 8GB of memory and a 1 TB hard drive.

I chose a configuration without an operating system. We’re going to install that in this post.

To set up the system, you also need an old VGA monitor, a USB mouse and a USB keyboard. These can be ditched later, but are useful to have around if you run into problems. You will also need an Ethernet connection to a local network. I have a power line network that is connected to the property’s router.

The tower also came with a now rather defunct optical media drive (you can’t choose to omit this). As I won’t use this I disconnected it internally. This may free up some power and resources.

Connect up the monitor, mouse and keyboard. Also connect the Ethernet cable. Plug in the server.

iDRAC Setup

Dell provides an Integrated Dell Remote Access Controller that is referred to as iDRAC. This allows you to remotely access system information and control the server. There are a number of quick steps to set this up.

First, power on the server. The system performs a number of checks. Press F12 to access the lifecycle manager. On the first run this will display a short set of screens to configure iDRAC access.

Because I am lazy I opted to use DHCP to configure the IPv4 and IPv6 addresses. I can cheat a little by accessing the network configuration for the router and looking for the server as a wired client device. The server actually has two IP addresses, one for the server itself and one for the out-of-band iDRAC management channel. In the router configuration I set both IP addresses to be constant – this way I get the simplicity of DHCP yet also have static IP addresses on the local network.

Once the iDRAC configuration is complete the server will restart.

Operating System Install

As we have no operating system installed the server will not boot by default. Things are clearly set up for a Windows Server install as it keeps looking for a drive C:\.

There are number of ways to install the OS. The Dell Lifecycle Manager offers a wizard to install from an .ISO file. I chose to use a USB stick as this is how I normally install Ubuntu Desktop on other machines. On another machine download the latest copy of Ubuntu Server (18.04 LTS for me) and use a startup disk creator to load onto a USB stick (Ubuntu desktop has one that can be accessed from the searchable dash).

To boot from a USB stick you need to enter the BIOS settings on boot by pressing F2. Select “Boot Options” in the system configuration and in the lower third of the options move the “Flash Drive” (i.e. USB stick) to the top of the boot order. Then reboot.

If you successfully boot from the USB stick, you should see the Ubuntu Server install screen. The options are all text based and fairly straightforward. I chose not to install any programs to start, as I’ll install these later (and mainly use Docker). You can import allowed SSH public keys for a user from Github, which is pretty cool.

You may need to format and/or partition the hard drive (which is setup for a Windows Server install). If you want to do this using a graphical interface you can always boot with a USB stick having a desktop version of Ubuntu and use GParted. We will look at volume management a bit later.

SSH Server Configuration

There are a few things I like to do to make a new server more secure. These are fairly simple low-hanging fixes but can prevent around 80% of attacks.

The first is to change the SSH port from the usual port of 22. Most automated attacks just randomly select IP addresses and try this port.

The second is to login using SSH keys instead of usernames and passwords. Login via username can then be switched off. If you have imported authorised public SSH keys from Github, any machine you’ve allowed to access Github should be able to access the server.

The third is to disable root login. This means we have to login as a user and use “sudo”.

All these can be performed by editing the settings in sudo nano /etc/ssh/sshd_config. Uncomment the Port and PubKeyAuthentication lines and edit accordingly. Also add a PasswordAuthentication no line. Root login is typically disabled by default. Remember to restart the SSH service after saving the updates using service sshd restart.

Install Docker & Docker Machine

Docker is available in the Ubuntu repository but it’s currently a version behind (17 vs 18 at the time of writing). To install the latest version of Docker you can follow the steps here. Beware: we now have a mixture of apt packages and snap packages. When installing Ubuntu Server it installs the “snap” version of Docker. Hence, I recommend not installing Docker as part of the initial installation and using the linked apt method for now.

Connect Some USB Hard Drives

I have a few USB Terabyte hard drives I want to hook up. First, connect the USB cables. Then to view the drives you can use the “list hardware” command sudo lshw -class disk -short.

To mount a particular partition we need to create a mount folder. There are generally two places to do this /mnt or /media. The consensus is that user mounts should go into /mnt. Use sudo mkdir /mnt/mybigdrive to create the directory.

Now we need to mount a particular partition. Use lsblk -f to list the partitions on the attached devices. If my attached drive is sdb and has one partition, I can mount the drive using something like sudo mount /dev/sdb1  /mnt/mybigdrive/ .

TMUX is Your Friend

One useful discovery is TMUX (Terminal Multiplexer I think). This can help you keep track of your remote SSH sessions.

First create a new terminal session by running tmux new -s server_admin. Do your business. Then detach using tmux detach. The session is now available even if your SSH connection goes. You can attach to the session by running tmux a -t server_admin.

This is a great guide to TMUX.

Understanding Logical Volume Management

As we are using a recent version of Ubuntu Server we need to get our heads around logical volume management. This is a way of flexibly controlling our data storage.

We have three types of volume:

  • Physical Volumes – these are often the underlying hard disks.
  • Volume Groups – these are collections of Physical Volumes.
  • Logical Volumes – these are created from the pool of storage provided by a Volume Group.

We can use the pvdisplayvgdisplay, and lvdisplay commands to show information about each volume type.

These two articles from Digital Ocean provide a good introduction:

Now we have a 1TB hard disk that is prepared using the Ubuntu Server install as one physical volume. There is also one volume group, which contains the physical volume. The volume group is by default named “ubuntu-vg”.

Let’s run through an example of creating a logical volume to store our projects.

First we can use sudo lvs to have a look at the existing logical volumes. This is also helpful for checking the Volume Group that is in use.

Next we create a new logical volume using sudo lvcreate -L 100G -n projects ubuntu-vg. This creates a new logical volume of size 100GB called “projects” using the “ubuntu-vg” volume group.

Now we need to create a file system on the new logical volume. To do this use sudo mkfs.ext4 /dev/ubuntu-vg/projects. We can check the file system has been created successfully by running sudo fsck -t ext4 -f /dev/ubuntu-vg/projects.

Finally to use the new logical volume we need to mount it somewhere. Lets choose “/mnt/projects”. Create a new blank folder using sudo mkdir /mnt/projects. Then mount the new logical volume into the folder using sudo mount /dev/ubuntu-vg/projects /mnt/projects. We can check everything is where it should be by running df -h.

It’s going to take me a bit of time to get used to volume management but I can quickly see the upside. I can add physical volumes to the volume group from other hard drives, and then expand existing logical volumes using the extended volume group.

Group Permissions

As we are running a server that may have multiple users we need to move from a single user owning everything to group access. This is explained here.

Our “projects” directory created above will initially be owned by “root” of the group “root” (as we mounted the drive using sudo, i.e. as the super user). Let’s initially change this to the “leader” of a new group: <code>sudo chown -R [groupLeader]:[groupLeader]</code>.

Now let’s add a new group for project developers using <code>sudo groupadd projectdev</code>. You can check this has been created by using <code>getent group | cut -d: -f1 | sort</code> (this lists all groups, cuts out the group name and sorts alphabetically).

Now let’s add our another user to the “projectdev” group using <code>sudo usermod -a -G projectdev [otherUser]</code>. We can check the user has been added using <code>getent group projectdev</code>. Then change the ownership of the projects folder to be owned by the group (assuming you are logged in as [groupLeader])<code>chgrp projectdev /mnt/projects</code>.

You’ll need to log in and out before you can access the folder.

Restoring Backups

I had a duplicity backup from a previous (fried) computer. If you use the “backup” GUI on Ubuntu Desktop, this uses duplicity on the backend (wrapped using Deja-Dup).

First you may need to install duplicity on the server. Use sudo apt-get install duplicity to do this.

Next we need to find the folder containing your duplicity backups. For me this was a folder on a USB drive. Mount the drive and navigate to the folder. Restoring the backup then becomes a case of running sudo duplicity restore --progress file://[/full/path/to/backupfolder] [/full/restore/folder/path].

If the folder is not blank (sometimes Ubuntu sticks system folders like “lost&found” in there), you may need to use the “–force” flag to overwrite any contents in the restore folder. I also had an issue with running out of temporary storage, so I mounted a new bigger logical volume to a “/mnt/customtemp” directory and then used the “–temp /mnt/customtemp” option to use this over the default “/tmp” directory. The “–progress” flag just helps to make things more verbose and show progress during the restore.

Loading Keys

If your backup contained any key files (e.g. “id_rsa” and “”) you may want to copy these into your current “/home/[$USER]/.ssh” directory. This can then allow you to use existing keys to access remote SSH servers (such as GitHub).

Reflections on “Meaning”

Existential “meaning” is partly the telling of a story featuring ourselves that is available and consistent with our higher-level representations of the world. It is not, generally, rational; it is more a narrative correlated with a feeling of “selfness” and “correctness”.

For example, think of how you feel when you hear your own internal voice as opposed to hearing another person speak. You feel that the internal voice is somehow “you”. This is not a rational thought, indeed the language of rational thought may be seen, in part, to *be* the internal voice. This feeling breaks down in certain brain diseases, such as schizophrenia. With these diseases, the “me” feeling is lost or broken, and hence the internal voice of “you” becomes an auditory hallucination, a voice of “them”.

Concentrate on this feeling of “you” for a moment, try to explore what it feels like.

Now think about a feeling of “correctness”. This can also be seen as a feeling of “truthiness”. For example, try to concentrate on how the feeling of “1 + 1 = 2”, differs from the feeling of “1 + 1 = 5”. The latter invokes a feeling of uneasiness, an itching to correct. It has tones of unpleasantness. It induces a slight anxiety, a feeling that action is needed. The former invokes a feeling of contentment, that no action is required; it may be contemplated for an extended period without unease of additional thought. It’s a similar feeling to artistic “beauty”, the way we can contemplate a great painting or a landscape.

Both feelings may arise from a common mechanism in the cingulate cortex, a medial layer of cortex that sits between older brain structures such as the thalamus and the higher cortical layers. Indeed, certain forms of schizophrenia have been traced back to this structure. The cingulate cortex may be considered to be the emotional gateway between complex neural representations in the upper cortex and structures that manage low-level sensory input and co-ordinate physiology response. “Sensory input” in this context also includes “gut feeling”, sensory input from internal viscera. Work, such as that performed by Antonio Damasio, shows that this input is important for the embodied feeling of self, e.g. “self” may in part be a representation formed from signals from these viscera. In a not dissimilar manner, “correctness” may be based on a representation of error or inconsistency between a sequence of activated cortical representations. At a very naive level this could be built from familiarity, e.g. at a statistical level, does this sequence match previously activated sequences? Over a human life this is a “big data” exercise.

So, back to “meaning”. Our higher-level cortical systems, e.g. the frontal lobes, create narratives as patterned sequences of goal-orientated social behaviour, which may be expressed in various media (stories, plays, comics, dance, songs, poems etc). For “meaning” to be present, we are looking for strong positive correlations between these narratives and the emotional representations of “self” and “correctness”. What form could these correlations take?

First, let’s look at “goal-orientated behaviour”. The frontal lobes build representations of sequences of other representations. These sequences can represent “situation, action, outcome”. There is some overlap with the methods of reinforcement learning. Over time we learn the patterns that these sequences tend to match (google Kurt Vonnegut’s story graphs). The frontal lobes are powerful as they can stack representations over one to seven layers of cortex, allowing for increasing abstraction. Narratives are thus formed from hierarchical sequences of sequences. (There may also be a bottom-up contributions from lower brain structures such as the basal ganglia, which represents more explicit cause-effect pairings without abstract, e.g. “button tap: cocaine”.)

Second let’s look at activities that are widely reported to be “meaningful”, and those that are not. “Meaningful” activities tend to be pro-social. For example, imagine you are an artist on your deathbed; what feels more meaningful, that you produced a work of art seen by no one or that you produced a work of art seen by millions? I’d hazard that the second scenario provides greater “meaning”. We need a sense that we have affected others in a positive manner. Similarly, does “1+1=2” feel “meaningful”? Do your tax returns feel “meaningful”? Does the furniture in a new home feel “meaningful”? I’d hazard “no”. These things do not elicit a strong emotional reaction. The furniture example is a good one; the furniture in your family home may come to have “meaning”, but only because it forms the background of your social memories. We are social animals, like parrots, dolphins or baboons, and so the social realm forms a bedrock to our emotional states.

For correlations to stick in the brain we need two things: 1) for correlations to be present in the outside world (or at least some situations that form a sensory base to those correlations); and 2) for us to regularly experience these external situations. Here “regularly” means at a daily or at least weekly.

Religions have long been aware of these aspects, indeed we often define “religion” as a structured practice built on a common mythological framework. It is widely reported that it is not possible to feel “faith” without practice. In Islam this is explicit, “Islam” means to submit or surrender; you have to practice to believe. The structure of religion provides the regular experience of 2): daily prayers, weekly worship, and annual festivals.

To provide correlations between feelings of “self” and “correctness” and particular narratives, we need to experience them all collectively. It is important that the narratives are at least analogous to our daily experience. If they are not, we cannot experience them as being “correct” or “true”. All of this also needs to take place below a level of conscious awareness.

Again, we can learn a lot from religion. Rituals light up the brain of those experiencing them. You are the one experiencing the ritual, you are taking in heavy sensory stimulation, and are performing actions within the world. Rituals often involve singing, collective and stylised movement, repetition of motifs. These activate common neural representations each time the ritual is performed. The connections that are formed fuse the self and the experience.

The last part of the puzzle involves fusing the narrative and the experience. The self is thus fused with the narrative via the repeated experience.

In religion, rituals tell a story. The Eucharist is rooted in the story of last summer, Passover the liberation of the Israelites, and Ramadan commemorates the receipt of the Quran. It is important that the faithful act in a manner that is consistent with the story. Although many stories are based on an echo of history, historical fact is not important. More important is that the story, or an abstraction of the story, mirrors experience outside of the ritual. For example, many religious stories are based on familial relations, which most can instantly relate to. Many religious stories acknowledge suffering and struggle, as well as moments of joy and exhilaration, which again people regularly feel in their daily lives. The stories are also dynamic, they emerge from history through retelling, emphasis, interpretation. Like our own memories they are recreated every time they are retold. A key role of clergy is to draw parallels between these stories and our daily tribulations.

Having considered these points, we can see why the rational secularism of modernity often leaves people cold and lacking meaning. Science is not a vehicle for creating human meaning. Indeed, I would go as far to say that the factors that make science successful move us in a direction away from meaning. The workaday stories of science need to be sterile for science to work; they need to be objective, unbiased and unemotional. They then provide us with predictive power. But predictive power is not emotional resonance. The predictive stories of science, equations and theories, are not human-centric in a way that matches what we feel. If they were, we would all be reading scientific papers as opposed to watching Netflix.

If people lack meaning in their lives, they quickly fall into nihilism and despair. The challenge of Western post-modernism, having largely ditched religion, is thus to fill the void and create something we can use in our daily lives. Science and engineering could provide the tools and understanding, but they will not provide the solution themselves.