Linux Shell
by Felix Kinaro About 2 min reading time
What is the Shell?
The Shell is a program that takes inputs through the keyboard and passes them to the operating system for execution. It is a command-line interface into which users type commands.
Common Examples of Shells
POSIX is a family of standards for maintaining compatibility between operating systems. Compliance to the standard ensures compatibility as you move through various Unix-like systems. The primary focus is on AT&T System V UNIX and BSD UNIX. The specification covers aspects such as network file access, system interfaces, commands and utilities among others. The shell falls in the category of commands and utilities.
- The original Unix Shell - Written by Steve Bourne.
- The Bourne Again Shell (Bash) - This is the default login shell in most Linux systems. The name is a deliberate pun intended to sound like "Born again." It was written Brian Fox for the GNU project. It was a free software replacement for the original Bourne shell (sh).
- Korn Shell - Developed by David Korn in 1980 and released in 1983. It is based on the Bourne again shell and is backward-compatible.
- Z Shell - A feature-rich shell developed by Paul Falstad in 1990. It features useful additions like auto-completion, text correction, and themeable prompts among others.
How Do You Run the Shell?
You need a terminal emulator to run shell commands. The terminal emulator allows us to run commands that perform desired actions.
The terminal emulator depends on the desktop environment you are using. Gnome users get gnome-terminal, XFCE has XFCE Terminal while KDE has Konsole.
We can run commands on a local machine or a remote device through SSH, copy files with SCP or transfer files using SFTP.
How to Find Installed Shells
Open your terminal emulator program and run cat /etc/shells
The output indicates the various shells you have installed
Interactive Shell vs Non-interactive
There are four categories of shells:
- Interactive login shell: This allows you to log in to a remote computer via SSH. An alternative is to open one on your local tty on your local machine (
Ctrl
+Alt
+F1-F6
). - Interactive non-login shell: Open a new terminal.
- Non-interactive non-login shell: This allows you to run a script. All scripts run in their own sub-shell that is not interactive. It only opens to execute the script and closes immediately once the script is finished.
- Non-interactive login shell: This is extremely rare. One way of launching one is
echo command | ssh server
. SSH starts a login shell if it is started without a command. If thestdin
of thessh
is not a tty, it starts a non-interactive shell. This is whyecho command | ssh server
will launch a non-interactive login shell. You can also start one withbash -l -c command
.
Conclusion
We have looked at the basics of what a shell is and why it is necessary.
Stay tuned for more as we explore file manipulation, permissions, and users in the upcoming posts.