voipmeister.com voip stuff matters and more

Articles tagged with shell

Change the default shell on macOS

Since 2019, Apple is favoring the zsh shell over Bash. The reason has not been made public, but logic dictates it is because of the licensing differences between Bash and zsh. Bash is GPL-licensed; zsh is released under the MIT-license which is less restrictive apparently. A writeup can be found here. I have been using Bash since forever and it is the default shell for all the Linux servers I manage at work. For me, it makes sense to keep using Bash on my laptops as well.

Setting the default shell to Bash

It’s not difficult to switch back to Bash when Apple -yet again- has changed the shell to zsh after a macOS update. Just open a Terminal window and type:

chsh -s /bin/bash

Verify the shell

To verify the shell has indeed changed to Bash, open a new Terminal window and type:

echo $SHELL

Example output:

/bin/bash

Depending on the shell you use, the shell prompt might also look different. Bash uses a dollar sign instead of the precentage sign used by zsh for example.

Available shells

In case you’re curious what shells are available to you, it’s easy to list them. In a Terminal window, type:

cat /etc/shells

This will produce output like:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

Thoughts

Zsh does have advantages over Bash, some of which can be read here.

Git and Python virtualenv prompt

Another note-to-self, mostly. When working with Git and Python virtual environments, it’s nice to have a shell prompt that’s informative. I have been using various prompts in the past, some of which were great to use. After I reinstalled my MacBook I ended up not knowing what I’d been using up till then. Searching for this prompt led me to the discovery of this great prompt. I’ve been using it since I discovered it, and I still like it today :)

The prompt is very informative about Git repositories (if you happen to be in one) and virtual environments, if one is active.

Perl woes

Today I was working on a backup solution for multiple linux hosts. My intention was to install BackupPC, which requires some Perl modules. I used this command to interactively install perl modules:

perl -MCPAN -e shell

The first time you invoke this command, you’ll go through the setup procedure. In my case, installation of Compress-Raw-Zlib-2.033 failed at the make stage. Looks like I forgot to install make prior to going through the setup procedure. On top of that, the perl installation might not detect when it is installed later on. Here’s how to configure the path to make:

[root@srv-test build]# perl -MCPAN -e shell CPAN
cpan> o conf make /usr/bin/make
cpan> o conf commit
Tags: Linux, perl

Listening ports on Windows

Here’s how to find which ports are listening on a Windows host:

C:\>netstat -an |find /i "listening"
TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
TCP    0.0.0.0:1559           0.0.0.0:0              LISTENING
TCP    0.0.0.0:8081           0.0.0.0:0              LISTENING
TCP    0.0.0.0:59021          0.0.0.0:0              LISTENING
TCP    127.0.0.1:1159         0.0.0.0:0              LISTENING
TCP    127.0.0.1:5152         0.0.0.0:0              LISTENING
TCP    127.0.0.1:5354         0.0.0.0:0              LISTENING
TCP    127.0.0.1:27015        0.0.0.0:0              LISTENING
TCP    127.0.0.1:62514        0.0.0.0:0              LISTENING