Terminal vs. shell vs. CLI vs. Prompt

Terminal vs. shell vs. CLI vs. Prompt

Terminal:

Short answer: It’s an application that we use when we type in commands to a command-line application or shell of any kind.

It basically listens for keyboard input. But the terminal itself doesn't know what to do with that input. So whatever keys you type in, it gets sent down a pipe to another application on the other end. Then the terminal will also listen to an incoming pipe from that application, and display whatever characters it sent.

Screen Shot 2022-06-10 at 7.31.29 PM.png

Technically, it's called a terminal emulator, as it acts like one of those old-school hardware terminals (back then each machine had a screen and keyboard physically attached to it as one thing called a terminal.

Shell:

In our case, we need an application that actually runs our input, that program is the shell. Once you enter your input, press Enter and the shell will interpret what you wrote as a command, figures out what program you want to run, runs it, and sends the output back to the terminal so you can see it.

Screen Shot 2022-06-10 at 7.35.32 PM.png

Frankly speaking, you could use the terminal without the shell, as the intermediate application to run our commands, there are a lot of terminal programs you can tell it what program to run i.e., the Python interpreter. But the default is shell.

Also, there are actually a lot of different shell programs that you can choose from. The default one on most Linux systems, and on the Mac, is called Bash. But there are others i.e., zsh, sh. They all work slightly differently and have various different features.

echo $SHELL

Screen Shot 2022-06-10 at 6.51.31 PM.png Screen Shot 2022-06-10 at 6.50.36 PM.png

So, the terminal is the window where we type the commands in, shell is the language/interpreter that runs the commands.

Command-line:

A command-line interface (CLI) is a computer program that processes commands in the form of lines of text. so you as a user will typically interact with the shell via a command-line interface (CLI).

Screen Shot 2022-06-10 at 7.40.44 PM.png

Prompt:

The command prompt provides some useful information to the user. Your command prompt will differ from mine.

Screen Shot 2022-06-10 at 5.02.19 PM.png

Look at my command prompt in the screenshot above. My prompt, "[salah@ubuntu:~] $ " is the text field that provides some information about the Linux system

Let’s wrap up with one big example: let’s try showing the contents of a folder “ls” those commands, those characters get sent down to the shell running on the other end. It then spits out the text representing the file listing and the terminal then displays it on the screen.

Screen Shot 2022-06-10 at 6.38.00 PM.png

In Windows, we terminal is called Windows Console. You never however actually directly create the console on Windows, you generally run Cmd or PowerShell for example, and then Windows will create a console for you. But essentially the console does exactly the same stuff as a terminal.

Fun fact, you can also use a shell without the terminal, sort of. You can write shell commands into a file and arrange for your computer to run the shell program on that file. This is called shell scripting. And it will be the topic of my next blog.