Linux Command Line Interface: The Basics — Part 1

1. The Command Line Interface, CLI

The command line interface, better known as CLI, is just another way to interact with the computer. This technology works with text commands typed line by line. There is a CLI enabled in the left panel, lets get our current username:

  1. Click on the CLI
  2. Type: whoami
  3. Press the return key

Command: whoami

Description: The whoami utility displays your current user ID as a name.

1.1 Inputs and outputs

Let’s review what we’ve done.

After typing the whoami command, you will have got:

root ~/workspace $ whoami
root

The first line, where you typed the command, is called the command prompt. In the second line, we’ve got an output after executing that command by pressing the return key.

Basically, this is how the CLI works:

One important question to ask is how does the CLI recognize the whoami command?

1.2 Program execution

How does the CLI recognize commands

Pay attention to the 2nd step of the program execution flow:

After hitting the return key, the CLI takes the whoami command and looks for a program with the same name somewhere in the computer:

command = program name

To better understand this, try to type any word into the command prompt and hit the return key, we’ll use anyword as an example:

root ~/workspace $ anyword 
-bash: anyword: command not found

1. 3. The CLI programs

The command line programs

The CLI recognizes several program names depending on the computer and the operating system that lives in the computer. CLI, also known as the terminal window has an installed software called: bash.

Bash is the name of the software that makes the interaction between the user and the terminal window possible.

Bash has a vast catalog of program names, each of them perform different actions.

We already know how to get the current user with the whoamicommand, but what about getting the current working directory?

In other words, where we are right now inside the computer files and folders structure.