A nerd’s guide to knowing your Terminal better.
Hello everyone, I am Darsh Mashru. Today I will be talking about the CLI (Command Line Interface). What most people think about CLI today is that it is a black box of boredom. Well, in this terminal series, I am planning to change your mindset by giving you a more detailed insight on the importance of terminal for developers as well as daily users.
So lets firstly start off with the basics,
There are 2 types of UIs (User Interface), CLI (Command Line Interface) and GUI (Graphical User Interface).
What is a CLI?
CLI stands for Command Line Interface. It is a text based interface that helps us give commands to the computer directly.
What is a GUI?
GUI stands for Graphical User Interface. It is a graphical interface that consists of icons, animations and is generally more user friendly than CLI.
CLI vs GUI:
In reference to the table we can see that CLI is less intuitive, needs to be learnt for optimal usage and doesn’t support any pointing device like a mouse*. But with those drawbacks, most developers still prefer using a CLI over a GUI just because it barely uses any system resources, really helps out with its high precision and is way way faster than a GUI when it comes to things like doing repetitive tasks.
* technically CLI can support pointing devices within a terminal emulator
Now since we know a lot more about these interfaces of the computer, let’s talk about a few more key terminologies that are required for knowing your CLI better.
What is a Shell?
A shell is an interface that is used to communicate with the core of the computer so you can access that computer’s services. It can either be a CLI or a GUI. Windows and macOS use their own GUI shells while Linux distributions give their users a choice of GUI shells that they can install and use.
Examples of commonly used CLI Shells on respective platforms:
Windows: Powershell, Command Prompt
Linux: Bash, Zsh
macOS: Zsh, Bash
Examples of GUI Shells:
Windows: Aero
Linux: GNOME shell, KDE Plasma Desktop
macOS: Aqua
GUI Shells normally come in a bundle with other softwares, in a combined package known as Desktop Enviroment.
We will look further into GUI Shells and Desktop Environments in another article, so for now let’s just stick to CLI.
Let’s talk about Windows first:
Windows comes with 2 shells namely Command Prompt and Powershell 5.1.
We will refer to Command Prompt as cmd and Powershell as pwsh.
Command Prompt in 2022 is a completely obsolete program, however it still exists for users who just don’t want to move to powershell. Microsoft has been pushing more users to powershell by making it the default shell of the latest version of Windows.
Command Prompt vs Powershell:
One key selling point of PowerShell is also that it is also available for Linux distros and macOS, and is for people who prefer to have the same shell across their operating systems.
The other is that PowerShell is built on the .NET Common Language Runtime (CLR). All of it’s inputs and outputs are .NET objects. Hence, there is no need to parse the text output to extract information.
Here are the list of differences between cmd and pwsh:
Also, one thing to keep in mind: Microsoft uses an older version of Powershell on their latest operating systems, Windows 10 uses 5.0 and Windows 11 uses 5.1.
I highly recommend users who use powershell regularly to upgrade to pwsh 7 or later (7.2.5 at the time of writing this article).
Powershell has a really good plugin support and it just gets better with “Oh My Posh”. It is a really good framework that helps in adding custom plugins to your shell so you can utilise it more efficiently.
But then you might be wondering, what is Windows Terminal? Why do we use Windows Terminal and why has Microsoft made Windows Terminal the default program to use powershell and cmd? Such programs are known as Teminal Emulators.
What are Terminal Emulators?
Terminal Emulators allow us to access a CLI shell of our choice to communicate with the system’s core services within a GUI. So basically, when you try to access CLI, it opens within a virtual terminal.
Examples of Terminals:
Windows: Windows Terminal, Hyper
macOS: Terminal, Hyper
Now coming to macOS, older versions of OS X/macOS used bash but since macOS Catalina, Apple moved from bash to zsh as their default CLI Shell.
Let’s now discuss the differences between bash and zsh.
Bash vs Zsh:
Zsh has a really good plugin support and it just gets better with “Oh My ZSH!”. It is a really good framework that helps in adding custom plugins to your shell so you can utilise it more efficiently.
In the next article I will be discussing about how can one utilise their shells more efficiently to help with everyday tasks.
Feel free to reach out to me if you have any doubts/feedback at darshmashru@protonmail.com.