Tech/Basics/Shell

From lathama
< Tech‎ | Basics
Jump to navigation Jump to search

A Shell is a program that is an interface to the system. Think of it as a human interface like a Tech/Basics/GUI. There are many shells out there. Some of them are personal choice. Some are forced by vendor.

What Shell are you using?

Discovery of which shell is in use and common on a system is fun.

Debian 11 example
root@lappy:~# getent passwd root
root:x:0:0:root:/root:/bin/bash
root@lappy:~# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
root@lappy:~# echo $SHELL
/bin/bash
root@lappy:~# which sh
/usr/bin/sh
root@lappy:~# ls -lha /usr/sh
ls: cannot access '/usr/sh': No such file or directory
root@lappy:~# ls -lha /usr/bin/sh
lrwxrwxrwx 1 root root 4 Dec 10  2020 /usr/bin/sh -> dash
root@lappy:~# ls -lha /bin/sh
lrwxrwxrwx 1 root root 4 Dec 10  2020 /bin/sh -> dash
root@lappy:~# ls -lha /bin/bash
-rwxr-xr-x 1 root root 1.2M Mar 27  2022 /bin/bash
root@lappy:~# which bash
/usr/bin/bash
root@lappy:~# ls -lha /usr/bin/bash
-rwxr-xr-x 1 root root 1.2M Mar 27  2022 /usr/bin/bash

Note the ENV SHELL vs the sh do not match. Note the various places things get pointed to. Even if your $$SHELL is set to DASH for example a script might call BASH like

#!/bin/bash


DASH (Debian Almquist shell)

DASH is the default on many modern systems (/bin/sh) even when people expect it to be BASH. DASH is a build on to ASH.

Bash (the Bourne-Again shell)

Industry standard for years, used in documentation and code examples to this day even when not the shell in use.

many many many more

I don't know if I should make an exhaustive list.

Resources