StackExchange Answers: Shells

Sometimes a Stackoverflow answer is so good that it helps me understand something I had kind of given up on. The distinctions of login and interactive shells are a good example. Some ressources had pointed me to the INVOCATION section of the bash man page. Here’s the explanation of what login and interactive shells are:

A login shell is one whose first character of argument zero is a , or one started with the –login option.
An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

https://linux.die.net/man/1/bash

I’m sure it’s correct and proper. From the perspective of someone trying to understand when .bashrc is invoked, it’s also absurdly unhelpful. Askubuntu user terdon to the rescue.

They just provide examples of each of the four combinations (and two binary tests that will tell you if the shell you’re in is login/interactive or nor) but from those examples, the defining characteristics become so much clearer. A shell is a login shell if I changed user when entering it be that by using su, ssh or logging in on a tty. An interactive shell is basically anything with a prompt and a non-interactive one is running something scripted. The combinations are then as follows:

ExamplesInteractive shellNon-interactive shell
Login shellTTY, su, sshPiping commands into ssh
Non-login shellA terminal emulator, starting a shell within a login shellScripts

I’m not summarizing to replace the answer, just to check that I understand. terdon’s examples do a much better job of explaining it – go have a read.

How to force Steam UI doubling on linux

In 2018 Steam on linux got the ability to autodetect HiDPI screens and resize the UI accordingly. I would guess this kicks in on 4k resolutions. I’m guessing because I don’t have one. What I do have is a laptop with a 14″ 2560×1440 screen and failing eyesight. Alas, neither one triggers the UI resize. Here’s how to consistently force the UI resizing instead of relying on Steam’s autoconfiguration.

(more…)

Proxy-set-header: Forwarding HTTP headers from Nginx to a WordPress container

I detailed in a recent post how I got a working WordPress container setup, complete with database and PHP engine. I saved the bit about how to redirect traffic to the container (and apply encryption to the outbound connections) because I knew it was going to be just as much work as getting the setup running. Also I needed to first get up to speed on HTTP headers in general and how to inspect them specifically.

This post is not a how-to any more than it’s a how-not-to. I wanted to detail as much the attempts that did not work as the final one that did because the former were just as illuminating as the latter.

(more…)

My life as an IP hobo and the promise of Dynamic DNS

When your servers don’t respond / who you gonna call? Well, maybe not call but look. And I’m talking about my server residing on my HTPC not yours. And it’s rhetorical question anyway because I know where to look once I get home. At one of the many what-is-my-ip address sites because the problem inevitably boils down to my ISP having changed my IP address.

This may elicit “duh”s from people whose IP addresses change every lunch break but mine used to be stable for months if not years on end. So I never bothered with my ISP’s 2€/month offer of a permanent IP address. Recently though, they changed their practices and now I rarely get in to a new pair of underpants before the address has changed. Read into that what you will. Oh, also the offer is 4€/month now. Coincidence? /conspiracy

(more…)

Moving site: Using MySQL to search-and-replace WordPress domain name

It seems that the recommended way to change the references to the domain name in MySQL on a WordPress install is to take the whole thing offline and do it by using text tools on a database dump. Either that or change the settings in WordPress while the site is still live on the old domain.

It was too late for the latter and I could not be bothered to do the former – partly because I had just gone through the whole mysql dump routine, partly because the site I wanted to move was only one among a number of sites contained in the dump. While the web server was all set up to use the new domain name, WordPress persisted in redirecting me to the old.

So I looked at the recent database dump, figured out what tables and fields to target so that I could replace the domain name on a live install.

(more…)
tea shark

Inspecting HTTP headers with tshark

Redirecting traffic from an nginx reverse proxy to a docker container I needed to add some forwarding information to the http headers. And so I figured I had better start wrapping my head around what http headers actually were, how they looked and how my nginx settings were impacting them. Enter tshark, the command line version of Wireshark.

Wire-/tshark are general purpose packet analyzers so the challenge here is to avoid casting a too wide net: I don’t want all the network traffic on my host, just the http headers and just those coming in and out of one particular virtual box.

(more…)