Installing Debian 11 from scratch


Pre-scriptum

I wrote this post a while back. Debian has progressed, and so has my understanding. Debian 13 “Trixie” has just been released.

Still, there’s some info in this post on setting up non-free audio/video stuff. It’s useful to me, so I’m reposting it.

Intro

So my ThinkPad just borked itself. It was running Ubuntu LTS. I got tired of Ubuntu’s faffing about with ads in the terminal, pushing private data to Amazon, and general asshattery. From a previous install I knew that installing Debian wasn’t as difficult as I recalled from the before times, so I went with that.

Unless otherwise stated, everything here happens in the terminal. Don’t be afraid, it’ll be ok. Just open a terminal.

The default on Debian 11 would be gnome-terminal.

Moving your data onto your freshly installed machine

You had backups, right? Before we do anything else, take that hard drive (or whatever) with your old data on it, connect it to your computer, and start moving the files over.

The fiddly stuff below will take a while, so let’s make good use of the time.

Getting up to date

While your data is being copied over, let’s get the OS up-to-date. Who knows how long that install ISO has been lying around there.

In your terminal, become root:

    su
    (Enter root password)

And run the update commands:

    apt-get update
    apt-get upgrade

Enable sudo

UPDATE: You can skip this step if you’re smart during the installer stage.

It works like this:

When the installer prompts you to set a password for the root user, leave the field blank. In the next screen, the installer will then let you create your own user. Sudo will be enabled, and your user will have sudo privileges.

Thanks @neil!

Or just keep doing it the hard way

So far, so good. On to more interesting things. We want to install the sudo command, because… I’m used to it, and I hate having to change my habits. That’s a perfectly cromulent reason.

Install the sudo package:

    apt-get install sudo

Now we have to amend the PATH variable in our bash settings, because otherwise we won’t find the command we need. (No idea why this is necessary. Whoever set things up this way: I have words to say to you.)

    export PATH="$/usr/sbin:$PATH"

Now close your terminal, and open it again – just to make sure the new path is loaded. Become root again:

    su
    (Enter root password)

Then add the user account in which you need to use the sudo privileges:

    adduser yourusername sudo

If the damn box still says “adduser: command not found”, just do

    /usr/sbin/adduser yourusername sudo

I swear, it’s there. Debian just doesn’t want you to know. Whatever.

Doing the evil thing: Add contrib and non-free repos

While I don’t want to recommend running non-free software, it can be rather practical for some things. Like getting your wifi working, if you’ve ended up with one of the many machines where that requires proprietary drivers.

So let’s add some package repositories! In your terminal, do

    nano /etc/apt/sources.list

and after each “main” that you see, add

    contrib non-free

Save and exit with Ctrl-O Ctrl-X, and run

    apt-get update

Getting wifi to work

Now with the repos for the dark side enabled, we can install the wifi drivers that at least my ThinkPad needs. You’ll have to figure out which ones are needed for your machine. I do:

    apt-get install firmware-iwlwifi

Good, that should do it. We’ll see after a reboot.

More evil proprietary stuff: multimedia codecs, playing DVDs

The steps in this section come from this page, which was recommended to me by the most excellent Neil Brown. Thanks!

You’ve done the update / upgrade dance described at the start of this post, right? If not, do it now.

Then let’s install the libraries that let us play DVDs:

    apt-get install libdvd-pkg

This will give you one of Debian’s lovely blue config screens that always pop up for the more serious stuff. Not to worry, just select the defaults and run with those.

At this point, in order for stuff to work I had to close my terminals, start them again, and become root as

    su -

Maybe this is about loading the path variable that we modified above. Who knows. Who cares.

Now download, compile and install libdvdcss. (This sounds way worse than it is. The reason you need to do this at all is the absolute state of global copyright law.)

    dpkg-reconfigure libdvd-pkg

Another blue config screen, another click on the default, off you go.

Next, we install the regionset command:

    sudo apt-get install regionset

and finally, all those juicy codecs:

    apt-get install libavcodec-extra

If your DVD player refuses to play your discs, use the regionset command to set your machine’s DVD region code to whatever the DVD demands. The region codes are listed on the regionset man page. (1 is for North America, 2 is for EMEA / South Africa / Japan, etc. I don’t make the rules.)

You’ll also want some software to, well, actually play those DVDs:

    apt-get install vlc

Now it works for me! I tested it with one of those top TERF wizard kid movies that I happened to have lying around.

Making CapsLock an additional Ctrl

The Ctrl key is in the wrong place on modern standard keyboards. (No, I’m not interested in your views on this point.) Let’s fix that.

While this has to be one of the most popular modifications to the keyboard layout, it has apparently
been less than straightforward historically.

Fortunately, things are better now. Open the gnome-tweaks tool, and you’ll find everything you need under “Keyboard & Mouse” > “Additional layout options”.

This will require a restart, which by this point is probably advisable anyway, what with all the stuff we’ve been installing and configuring.

(Optional) Restoring passwordless ssh login

This use case is a lot more specific than the rest, so feel free to ignore this section.

I have a managed server that I can ssh into. That’s nice! I’ve set it up so that I can just type “ssh (server shortname) on the console, and I’ll be logged in. This is also very handy for running scripts. Unfortunately, it didn’t work after the Debian install, even though I had restored my old ssh keys from backup.

The error message read:

    sign_and_send_pubkey: signing failed: agent refused operation

This turned out to be a permissions problem. I fixed it in the following way (all this happens on my laptop, not on the server):


  1. Go to your home directory:


    cd ~


  2. Set the correct permissions for the .ssh directory:


    chown 700 .ssh


  3. Go into the .ssh directory:


    cd .ssh


  4. Make sure the permissions for your ssh key files are set as they should be, like so:


    chown 600 id_rsa
    chown 644 id_rsa.pub


  5. Add your private key to the OpenSSH authentication agent:


    ssh-add

That’s it. Now everything should work as before.

Done. I think.

With this, we should have most of the boxes ticked. Of course you’ll want to install more stuff as needed.

Enjoy your new Debian system!

Freeing up disk space on Debian

[This post is above all for my own reference, so I’ll know what to do the next time this problem occurs.]

My Thinkpad’s SSD has an impolite tendency to run out of disk space, even though I might not really be adding lots of data. It seems to be mostly cruft that Debian accumulates, perhaps out of a desire for thorough record-keeping.

Looking for ways to free up disk space, I found this StackExchange post. It has bunch of ways for giving my hard drive a good scrub.

Let’s see what they do!

Helpful commands

  1. Start by emptying your Trash bin.

2. Clean up logs – this freed about 3GB of disk space.

sudo journalctl --vacuum-size=300M # reduces the logs to 300 MB

This freed about 3GB of disk space.

More log cleaning. Did not have any visible impact:

sudo logrotate /etc/logrotate.conf # compresses or (?) deletes system logs

3. Delete cached packages. I did this before starting a more systematic analysis, so I can’t say how much space it freed up. But it was easily more than one GB:

sudo apt clean # deletes packages that were cached for installation

4. Remove unused packages. Freed up a cool 1.9 GB:

sudo apt autoremove # removes unused packages

That’s all the straightforward commands that the linked post provided.

Finding large files

In addition, it told me how to find large (<100MB) files, so that I can check whether I want to delete them:

sudo find / -mount -type f -size +100M -exec du -h {} \; | sort -n

But most of the results looked like they were at least somewhat important, so I didn’t actually go and delete any of them.

Remember to floss regularly

Maybe I should simply put all these commands into a little script, and run that as a cron job? Once a month or so?

Airdrop for the rest of us


Serving files from an iPhone via http

Those of us living in Apple’s golden cage know that the fruity phones offer a pretty decent user experience. But try rattling the bars, and you’ll find out that Cupertino has done a solid job of locking you into their system.

One of the nicer functionalities of iOS is Airdrop. This lets us transfer files between devices over Bluetooth. It’s as easy as sending a file by Signal. But disappointingly, it only works with Apple devices. This both a fact of life, and really stupid.1

For example, I sometimes find interesting ebooks on the internet. My ebook reader is in the non-aligned camp, because what I’m reading is honestly none of Jeff Bezos’ fucking business. When I find a book I like, e.g. on Project Gutenberg, I often download it to my phone.

So, how do I transfer that epub file to my ebook reader?

http to the rescue

I could just copy it to my computer, connect the ebook reader with a cable, and copy it over. This works, but it’s cumbersome: When I get time to read, I’ve usually just managed to tear myself away from the computer. So I don’t want to turn around and fire up the time-wasting box again.

Much better to waste time in a more interesting way! Turns out it’s really not hard to start a http server on my iPhone, direct the ebook reader’s browser to download the epub file from there.

(Of course, this works with literally any sort of file. Let’s just stick with my use case for now for simplicity’s sake.)

Important: This will only work if your iPhone and your ebook reader are on the same wifi network. If your reader doesn’t have wifi, then sorry, it’s cables for you.

Preparations

You only need to do this stuff the first time. We’re following these instructions.

On the iPhone:

  1. download the iSH app. It’s a Linux shell, more or less.
  2. start iSH, and install Python 3:

    apk add python3

  3. open your Files app, and hit “Browse”. In the top right corner there’s a circle with three little dots in it. A menu pops up, and you select “Edit”. This will show you a bunch of places where your phone can store files, iSH among them. Make sure iSH has a green toggle.

=== ADDED ===

Instead of installing Python and then using the http.server package, you can also just install darkhttpd, like so (still in iSH):

apk add darkhttpd

and then run it with

darkhttpd .

The dot is for the current (root) folder. If you’re feeling fancy, use another path where your files are stored.

(Thanks jacksonchen666 for the pointer!)

=== end of addition ===

Oh, and download the epub file you want to transfer to your reader. It doesn’t matter where you get it from, nobody’s judging you.

Transferring files

  1. On your iPhone, figure out where the downloaded file is stored. Just open the Files app, click on “Recent”, and it’ll probably sit right at the top.
  2. Copy the epub file to iSH’s root directory:
    • Long press on the file > copy.
    • Then hit “Browse”, and under “Locations”, you should see “iSH”.
    • Tap on “iSH”, then on “root”
    • long press somewhere on the empty screen. A context menu pops up, and you select “paste”. That’s it.
  3. On your iPhone, open iSH and fire up the web server:

    python3 -m http.server

If all is well, you should now get a message in iSH like “Serving HTTP on 0.0.0.0 port 8000”.

Do you see it? Congratulations, you’re running a web server on your phone!

But where, in network terms, is your phone? Let’s go find out your local IP address. On your iPhone:

  1. Open Settings
  2. Tap on “Wifi”. You’ll see the network you’re connected to. There’s a little “i” in a circle. Tap that, scroll down a bit, and you’ll see your phone’s local IP address. Mine is currently 192.168.178.47. Yours should look similar.

Now let’s transfer the file.

On your ebook reader, fire up the web browser. In the address bar, enter

http://< your IP address >:8000

for example

http://192.168.178.47:8000

Then hit “Enter”. You should now see a very plain directory listing that contains the epub file!

Just tap on the file to download it. My ebook reader decided to store it in its library and open it right away; I’m not sure how yours will do it. But you’ll figure it out.

Done!

Congratulations! You did it. That’s all. Repeat the steps from the “Transferring files” section as often as you like.

When you’re done, go to iSH on your phone, tap “^” and then “Z” to stop the server.

Of course, this process isn’t limited to ebooks. Open protocols like http are among the finer things in life, right up there with food and sex. Enjoy them!

You can just put any file in iSH’s root directory, and access it from any device on your network that speaks http.

Feedback, please

Did this work for you? Cool!

Oh, it didn’t work? Please let me know on the Fediverse, and I’ll see what I can do to help.I’m fully aware of how capitalism works. We’re writing from the user’s perspective here, ok?

  1. I’m fully aware of how capitalism works. We’re writing from the user’s perspective here, ok? ↩︎