Chapter 2: Basic Commands

Foreword

We recommend that you not use AI to do the exercises, since you are still in the learning phase.

Introduction

Even though there is a multitude of commands in Linux, a few of them turn out to be essential to make the most of this system. Chances are you will use them every day.

Prerequisites

Info: If you don’t have a Linux environment available, you can register at https://killercoda.com and go here https://killercoda.com/playgrounds/scenario/ubuntu to get access to a virtual machine running Ubuntu 24.04 (without a graphical interface of course!!) for 1 hour, renewable for free.

You will then have this view:


Bonus for the Killercoda team 👨🏾‍💻👩🏾‍💻:

You will now have this view:




Discovering the Linux terminal

Who says Linux terminal, mainly says command prompt and command interpreter (shell). But also commands.

Example of a Linux terminal:

  1. The command prompt
    • This is the line that indicates where you are and who you are in the system. It can vary depending on the distribution and the configuration, but it often looks like this:
      Example: user@machine:directory$
      • user: Your username.
      • machine: The name of the host (computer).
      • directory: The current folder (e.g. ~ for the home folder).
      • $: Symbol for a standard user (# for root).
  2. The command interpreter (shell)
    • The program that executes the commands you type. The most common is Bash (Bourne Again Shell), but others exist such as Zsh, Fish, or Tcsh.
    • It translates your instructions into actions for the system.
  3. Commands
    • The instructions you enter, such as ls, cd, cat, or even cowsay, etc. In this regard, it’s worth noting that they can be:
      • Internal: Built into the shell (e.g. cd to change directory).
      • External: Programs or applications installed on the system, independent of the shell. The shell looks them up and then runs them when they are called (e.g. ls to list files).

    You can identify whether a command is external or internal by running:

    type -t <command>
       
    or
    
    type <command>
    


    Below is an example of the output:

    widal@j4rd1n-d3s-0mbr3s:~$ type -t cd
    builtin # Indicates an internal command
    
    widal@j4rd1n-d3s-0mbr3s:~$ type  cd
    cd est une primitive du shell
    
    widal@j4rd1n-d3s-0mbr3s:~$ type -t cat
    file # Indicates an external command
    
    widal@j4rd1n-d3s-0mbr3s:~$ type cat
    cat est /usr/bin/cat # External command: the shell shows where the program is located
    
    




The Linux system tree

The Linux system tree is like a big, well-organized cabinet full of drawers and folders. It’s the way files and directories are structured in a Linux system. Everything starts from a single point called the root, denoted simply by a slash ” / “. From there, everything is organized into branches, like a tree (hence the name “tree structure”).

Here are the main directories and their role:

Below is a small illustration:


To test 👨🏾‍💻👩🏾‍💻:


Extra info:
The “/etc” directory mainly contains configurations related to your entire Linux system, but there is also a configuration directory called “.config”, usually found in each user’s home directory ( /home/username ). It’s a hidden directory containing configurations specific to applications, on a per-user basis. For your information, any file or folder name starting with a dot (“.”) is a hidden item.




Comparison between the Linux and Windows directory trees (BONUS)

Let’s compare the Linux directory tree with that of Windows, as if we were comparing two cabinets with different storage logics.

Linux: The unified tree (everything starts from /)

In Linux, everything starts at the root (/) and is organized into a single large structure. Each directory has a well-defined role:

It’s a unified system: no matter where you install Linux or which disk you add, everything is seen as a branch of this single tree. For example, an external disk might be mounted under /mnt or /media.

Windows: A structure based on drive letters

In Windows, there isn’t a single root, but several separate “cabinets,” identified by letters (C:, D:, etc.). Each letter represents a disk or partition, and the organization is less standardized. Here are the main equivalents:

The big differences

  1. Single root vs. multiple letters:
    • Linux: Everything is connected to /.
    • Windows: Each disk is a separate island (C:, D:, etc.).
  2. Clear roles vs. mixing:
    • Linux keeps things well separated (configs in /etc, programs in /bin).
    • Windows often puts everything in C:\Windows or C:\Program Files, which can seem less structured.
  3. Paths:
    • Linux: /home/user/doc.txt.
    • Windows: C:\Users\User\doc.txt, with backslashes (\).

Concrete example

Let’s imagine you want to store a personal file:

And if you plug in a USB stick:

In summary

Linux is like a big library with a single entry point and well-labeled shelves, while Windows is like several small independent libraries, each with its own storage system.




Basic commands

Info : If you’re used to using your graphical interface to work, your goal will be to reproduce everything you know how to do in the graphical interface in the Linux terminal (create/move/copy/delete files/folders, create shortcuts, move around directories/folders …)

Commands for displaying and manipulating content

Search and filter commands

System information commands

Permission management commands

Network commands

Utility commands

Redirections and pipes

Well! That’s quite an array of commands. Keep in mind that it’s through practice that you’ll remember these various commands. On top of that, the –help option (two dashes) and the man command will be your best friends for figuring out how to use a command.


To test 👨🏾‍💻👩🏾‍💻:


Training ⚔️

Exercise 1

Exercise 2

The exercises in this section will be in the form of challenges. There will be five challenges. Each challenge is accessible via a script that you’ll need to run to get started.

Below is an example of execution:

# Download the challenge 1 script
curl -LO https://raw.githubusercontent.com/N0vachr0n0/NoFD/refs/heads/main/BC_EXO_1.sh

# Make it executable
chmod +x BC_EXO_1.sh

# Run it to start the challenge
./BC_EXO_1.sh


Exercise 3 (Deep dive)

Exercise 4 (Bonus)

To learn how to master / get familiar with the vim text editor, we recommend going through vimtutor. Open your terminal and type vimtutor. You’ll get output similar to:



Feedback

Let us know what you think of this chapter.

👉🏾 Click here