The command-line (aka terminal) is a scary thing for most users. But understanding it can be a huge step in your learning journey and add a significant boost to your career in tech.
Photo by Tianyi Ma on Unsplash |
Depending on your technical skills, the command-line interface (also known as CLI or terminal) may look scary. But it shouldn't! The CLI is a powerful and resourceful tool that every person aspiring greater tech skills should learn and be comfortable with. On this article, let's review many reasons why you should learn and use the command line, commonly (and often incorrectly) referred to as terminal, shell, bash and CLI.
Ubiquitous
The command-line interface (CLI) is available in every operating system, not only in Linux. Very frequently, this is where developers and system administrators spend a lot of time. But, if you want to work with Linux, development, the cloud or with technology in general, better start learning it.
Terminals are available in every operating system including Linux, Windows and Macs |
Powerful
CLI-based apps are much more powerful than their GUI-based equivalents. That happens because usually GUIs are usually wrappers around libraries that power both the GUIs and the terminal apps. Very frequently, these libraries contain way more functionality than what's available in the graphical interface because, as you might expect, since software development takes time and costs money to produce, developers only add to GUI apps the most popular features.
For example, take a look at the plethora of options that the GNU find tool provides us:
Does your GUI-based find tool has all those options? |
Quicker
Common and repetitive tasks are also faster in the terminal with the advantage that you will be able to repeat and even schedule these tasks so they run automatically, releasing you to do actual work, leaving the repetitive tasks to computer.
For example, consider this standard development workflow:
- download code from GitHub
- make changes
- commit code locally
- push changes back to GitHub
If you were doing the above using a GUI-based git client (for example, Tortoise Git), the workflow would be similar to the below, taking you approximately 20 minutes to complete:
- Open Tortoise Git's web page
- Click Download
- Next -> Next -> Next -> Finish
- Right-click a folder in Windows Explorer (or Nautilus, or Finder) -> Select clone -> Paster the Url -> Click OK
- Wait for the download to Complete -> Click OK
- Back to Windows Explorer -> Find File -> Open it
- Make your changes (by probably using GEdit, KEdit or Visual Studio Code) -> Save
- Back to Windows Explorer
- Right Click -> Commit
- Right Click -> Push
- Take a deep breath
In the terminal (for example, in Ubuntu), the workflow would be equivalent to the below and could be completed in less than 2 minutes:
git clone <url> # clone the GitHub repo locally
vim/nano file -> save # edit the file using a text-based editor
git commit -m <msg> # commits the file locally
git push # push the changes back to our GitHub repo
Automation
Terminal/CLI-based tasks can be scripted (automated) and easily repeated, meaning that you will be able to optimize a big part of your workflow. Another benefit is that these scripts can be easily shared, exactly as business and professional developers do!
So let's continue the above example. Our developer realized she is wasting too much time in the GUI and would like to speed up her workflow even more. She learned some bash scripting and wrote the function below:
She's happy because now she can run from the terminal, the below command as soon as she finishes her changes:
What previously took 5 minutes is now is done in 2 seconds (1.8 seconds to write the commit message and 0.2 to push the code upstream). A significant improvement in her workflow. Imagine how much more productive she would be during the course of her career!
Lightweight
Not only the CLI is faster and more lightweight than equivalent GUI-based applications but it's quicker to run the same commands. For example, consider a Git client like Tortoise Git. It was supposed to be lightweight (what most GUI apps aren't) but it takes 3s to completely load and uses 10Mb of memory:
Our GUI-based git client TortoiseGit |
Now take a look at its CLI equivalent. git status runs in 0.3s and consumes less than 1Mb. In other words, 20 times more efficient memory-wise and 10 times faster.
A simple CLI command is 20x more efficient and 10x faster then its GUI equivalent |
Disk Space Efficient
Another advantage of terminal apps over their GUI-equivalents is reduced disk space. For example, contrast these two popular apps. Can you spot the differences?
Application | Installation Size | Total Size | Memory Usage |
Visual Studio Code | 80Mb | 300Mb | 500Mb (on sunny days) |
Nano | 0.2 Mb | 0.8 Mb | 3 Mb |
400x more efficient | 375x more efficient | 160x more efficient |
Extensible
Another important aspect is that the CLI is extensible. From it, skilled users could easily either extend its basic functionality using its built-in features like pipes and redirections combining inputs and outputs from different tools.
For example, sysadmins could list the first two users in the system who use Bash as a shell, ordered alphabetically with:
What's interesting from the above command is how we combined 5 different tools to get the results we need. Once you master the Linux terminal, you'll too will be able to utilize these tools effectively to get work done significantly faster!
Customizable
As you might expect, the terminal is extremely customizable. Everything from the prompt to functions (as seen above) and even custom keybindings can be customized. For example, In Linux, binding the shortcut Ctrl+V to open the Vim text editor on the terminal is simple. Add this to your .bashrc file:
Extensive range of Apps
Contrary to what most newcomers thing, the terminal has apps too! You will find apps for pretty much any use case. For example:
- Text Editors: Vim, Emacs, Nano
- Email Clients: Mutt, Aerc
- Newsreaders: Newsboat
- File Managers: Ranger, nnn
- Web Browsers: w3m, ELinks, Lynx
- Calendar: Calcourse
- Social: Reddit, Podcasts, IRC,
- Multimedia: ffmpeg
For example, here's the Castero Podcast app running on a terminal:
Source; GitHub |
Professional Development
Want to work with Linux, as a developer or with the cloud? Another important aspect of using the terminal is that it will make you more ready for the job market. Since servers usually run Linux and don't have GUIs, you will end up having to use some of the above tools on your day-to-day work. Developers frequently use it to run repetitive tasks, becoming way more productive. So why not start now?
Learn more about your System
Hopefully at this point you realize that you will learn way more about your system and computers in general when you use the terminal. And I'm not talking solely to Linux users. Windows and Mac users will learn a lot too! This is the secret sauce that the most productive developers want you to know!
It's also a huge win for testing new tools, maintaining your system, installing software, fixing issues and tweaking as you wish.
Getting Started
Ready to get started on your terminal/CLI journey? Here's a video that may serve as a good intro:
Conclusion
Every modern computer has a terminal. Learning it will save you time, allow you to automate common actions, make you learn more about your system, grow professionally and be more productive. Well worth the effort, isn't it?
See Also
- Microservices in ASP.NET
- My journey to 1 million articles read
- Creating ASP.NET Core websites with Docker
- Hosting NuGet packages on GitHub
- Configuration in .NET Core console applications
- Deploying Docker images to Azure App Services
- Distributed caching in ASP.NET Core using Redis, MongoDB and Docker
- How to build and run ASP.NET Core apps on Linux
- How to create a Ubuntu Desktop on Azure
- How to Enable ASP.NET error pages using Azure Serial Console
- How I fell in love with i3