Command line Interface (CLI)

CLI is the short form for Command Line Interface.
It is a text-based way of using your computer i.e. instead of an interface where you can click buttons, menus, etc using a mouse, you type commands and the computer responds.
CLI is referred to as the Command Prompt on Windows and Terminal on macOS and Linux.
Why use CLI?
CLI is the most ancient way of interacting with computers before the development of GUI (Graphical User Interface) dating back from the development of Unix Operating Systems.
Some of the reasons why people, especially developers would use CLI are as follows;
Speed: CLI is faster and quicker at doing things compared to GUI. In the terminal, you type commands and press Enter and quickly an output is displayed unlike GUI where you have to click around to find folders etc.
It helps one stay organized: Creating folders and files in CLI is done in short commands without having to switch between app like in GUI.
CLI works everywhere: CLI can be used in running servers, installing software, used in version control, and to build projects while some of the aforementioned things cannot be done on GUI.
CLI vs. GUI
Feature | Command Line Interface | Graphical User Interface |
Interface type | Type commands in text interface. | Click buttons, menus, icons, etc. |
Memory requirements | Low memory requirement. | High because of graphics and animations. |
Speed and efficiency | It’s faster once you learn the basics. | It’s slower for repetitive tasks. |
What you need | Developer just needs a keyboard. | You need a keyboard and mouse. |
How it feels | It feels like giving instructions. | It feels like exploring with a mouse. |
Accessing the CLI
Windows
a). Press Windows Key + S
b). Type Git Bash (if installed) or cmd
c). Click to open it.
macOS
Option 1:
a). Open Finder
b). Go to
Application > Utilities
c). Open
Terminal
Option 2:
a). Press
Command + Space
b). Type
Terminal
c). Press
Enter
Linux
a). Press
CTRL + ALT + T
or searchTerminal
from App launcher.
N/B: A Shell - This is a program that takes the user commands typed on the CLI, calls the operating system to run these commands to interpret them and give an output.
Git
It’s almost agreed universally in software development world that the best developer experience comes from unix-based operating system. That doesn’t windows is bad though.
For this reason, let’s learn how to install Git Bash in order to have that experience on our windows machine.
Git Bash is a terminal application that brings unix styled command line to Windows. It is not a full Linux system, but it gives you access to many of the same tools and behaviors while running on windows.
How to install Git
Go to git website. Git download link
Download the Git Windows installer.
Open the installer and follow the set up prompts.
Finish installation and you’ll have Git in your Windows computer.
Basic Unix Navigation
When you start the terminal, you will see a text display called prompt waiting for your input. Note that your current directory/folder will always be your home directory represented by the tilde
symbol (~)
To look around, find files and directories within your home directory, use the ls
command which stands for list. it lists contents of the current directory.
To make a new directory/folder, use the mkdir
commands followed by the name of the new directory and press Enter
. For instance, lets create a directory named css20. The command will be;
mkdir css20
.
Now when you list the content of current directory again, you’ll notice the new folder called css20
Notice the new folder css20 that’s highlighted in the above image.
To move to a new directory/folder such that it becomes your current working directory, use the cd
command which stands for change directory, followed by the directory name. For example. let’s move from our home directory to css20 directory using the cd command.
cd css20
Notice that the current working directory has changed from tilde(~)
to css20
.
Now to create a file inside the css20 directory, we can either use touch
to create an empty file or a text editor called nano
or vim
. The choice is yours but for now, lets use touch to create empty file called homework
.
touch homework
After creating the file, when we ls
, we can see the homework file inside the css20
directory.
If you no longer needs a file and wants to delete it, we the rm command followed by the file name as shown
rm homework
homework file no longer exists inside the css20
directory after ls
command.
However, to delete a directory, we use the rm
command plus a -r
to mean we want to delete the directory and all its content recursively as shown below;
rm -r css20
Here are tables of unix commands and what they do:
File and directory management.
Command | Description |
ls | List current directory contents. |
pwd | Shows current working directory. |
cd [directory name] | Change directory |
mkdir [directory name] | Create a new directory |
rm -r [directory name] | Deletes a directory recursively. |
rm [file] | Delete a file. |
cp [source] [destination] | Copy a file or directory. |
mv [source] [destination] | Move or rename a file. |
File content commands
Command | Description |
cat [file] | Display file content |
more [file] | View file content page by page. |
less [file] | Similar to more but with backward navigation. |
head [file] | Show the first 10 lines of a file. |
tail [file] | Show the last 10 lines of a file. |
Process management
Command | Description |
ps | Display active processes. |
top | Show real time process usage. |
kill [PID] | Terminate a process by ID. |
killall [process_name] | Kill all processes with the specified name. |
User and permission management
Command | Description |
whoami | Display current user. |
who | Show logged in user. |
chmod [permission] [file] | Change file permission. |
chown [owner] [file] | Change file ownership. |
passwd | Change user password. |
In conclusion, UNIX remain to be the most influential operating system in the software development world and the fact that it’s more secure, robust, and efficient makes it a better choice for servers, software development and networking.
Subscribe to my newsletter
Read articles from Lord Abiolla directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Lord Abiolla
Lord Abiolla
Passionate Software Developer with a strong enthusiasm for data, technology, and entrepreneurship to solve real-world problems. I enjoy building innovative digital solutions and currently exploring new advancements in data, and leveraging my skills to create impactful software solutions. Beyond coding, I have a keen interest in strategic thinking in business and meeting new people to exchange ideas and collaborate on exciting projects.