DEV Community

Cover image for Beyond the Linux GUI: Part 1 - First Steps in the Terminal
kasboi
kasboi

Posted on

Beyond the Linux GUI: Part 1 - First Steps in the Terminal

Linux for Developers

Hello and welcome to my first technical article on Linux for Developers.

Linux is a free and open source kernel that powers a lot of operating systems such as Ubuntu, Fedora, Debian and many more. In most circles though, this coalition of operating systems are referred to as Linux distros or just distro (distributions) and most people will tell you they are using Linux if you ask what O.S they are running.

But, to be clear, Linux is just a kernel—the core of the operating system that manages communication between hardware and software. It controls system resources like CPU, memory, disk and network. The operating system is the complete package that includes the kernel and other software that provides a user interface, file management, and other features.

Going forward, I will refer to the complete package as Linux though, as that is how most people refer to it and to prevent confusion regardless of the O.S (distro) you are using.

Why Linux?

There are many reasons people — developers or not — use Linux. Some of the most common reasons are:

  • Open Source: Linux is free to use, modify, and distribute. This means you can customize it to fit your needs.
  • Lightweight: Linux is known for its efficiency and low resource usage. You think your computer is slow? Try a lightweight Linux distro like Lubuntu or Xubuntu.
  • Community Support: Linux has a large and active community that provides support, documentation, and resources.
  • Development Environment: Many developers prefer Linux for its powerful command line interface, package management, and development tools.

Personally, I use Linux because things just work. Trying to get Python to work on Linux? just sudo apt install python3 and you are done. No need to download an installer, run it, set environment variables, etc. It just works.

I also like the fact that I can customize it to fit my needs. I have a silly command lol that works like ls but with rainbow colour output.

lol command output

Linux Installation

There are many articles out there that guide you through the various options you have when installing Linux. You might decide to replace your entire OS with Linux, dual-boot (installing Linux alongside your current OS) or run it via a virtual machine (running Linux in an application window). The choice is yours.

Personally, I run Ubuntu through WSL2 (Windows Subsystem for Linux), which is a lightweight virtual machine for running Linux directly on Windows machine. I am satisfied with it for my work and it feels native enough.

It is also easy to install via powershell with wsl --install. You can find the docs here

What are we doing here?

In this limited series, I will be sharing my knowledge of Linux with you. I will cover topics such as:

  • Terminologies
  • Basic Linux commands
  • Exiting vi/vim
  • Shortcuts and signals
  • File management
  • User, superuser and permissions
  • Environment variables
  • Process management
  • Networking: wget and curl
  • Package management: apt and snap
  • Shell scripting and aliases

These topics are not exhaustive and you will be surprised at how simple most of them are. I will try to keep the articles short and to the point, with practical examples and explanations.

Terminologies

Before we dive into the commands, let's cover some basic terminologies that will help you understand Linux better.

Terminal

The terminal is a text-based interface that comes with every operating system. It allows you to interact with the system using text commands. The terminal is often referred to as the command line, shell, or console. You can open the terminal by searching for it in your applications or using a keyboard shortcut (usually Ctrl + Alt + T on Linux).

The interesting thing about the terminal is that it is not the shell. The shell is the program that interprets your commands and executes them. The terminal is just the interface that allows you to interact with the shell. You will find on Windows that you can have multiple shells open within the same terminal window, such as PowerShell, Command Prompt, and WSL. You can also use other terminal emulators like iTerm2 on macOS.

Terminal screenshot

Shell

The shell is a program that interprets your commands and executes them. It is the interface between you and the operating system. There are many different shells available, but the most common ones are:

  • Bash: The default shell on most Linux distributions. It is a powerful and widely used shell that supports scripting and automation.
  • Zsh: An extended version of Bash with additional features and improvements. It is popular among developers for its customization options and plugins.
  • Fish: A user-friendly shell with a focus on interactive use and ease of use. It has a different syntax than Bash and Zsh, but it is easy to learn and use.
  • PowerShell: A shell developed by Microsoft for Windows, but it is also available on Linux and macOS. It is designed for system administration and automation, with a focus on object-oriented scripting.

Your shell runs within the terminal and you can check which shell you are using by running the command:

echo $SHELL
Enter fullscreen mode Exit fullscreen mode

If you haven't changed anything on Linux, you should get /bin/bash output.

REPL

REPL stands for Read-Eval-Print Loop. It is an interactive programming environment that allows you to enter commands, evaluate them, and see the results immediately. The shell acts as a REPL, allowing you to enter commands and see the output immediately. This is useful for testing commands, running scripts, and experimenting with different commands. A lot of programming languages also have their own REPLs, such as Python, Ruby, and Node.js. You can access the REPL by simply typing the name of the language in the terminal:

python
ruby
node
Enter fullscreen mode Exit fullscreen mode

Navigating the File System

When you open a terminal, you are always located inside a directory. Think of it as having a file explorer window open—you're always in a specific folder. This location is called the current working directory.

Here are the essential commands for finding your way around:

# Print Working Directory - tells you where you are right now
pwd

# List - shows files and subdirectories in your current location
ls

# Change Directory - move between directories
cd documents
Enter fullscreen mode Exit fullscreen mode

Important Directory Shortcuts

# The Root Directory - base of the entire Linux file system
cd /

# The Home Directory - your personal user directory
cd ~
# or simply
cd
Enter fullscreen mode Exit fullscreen mode

Finding Commands

You might be wondering where commands like ls or pwd actually live. They are just small programs, and you can find their location using the which command:

which ls
# Output: /bin/ls
Enter fullscreen mode Exit fullscreen mode

You can also create your own commands, which we will cover later in the series. For now, if you need more information about a command, you can use the man command (short for manual):

man ls
Enter fullscreen mode Exit fullscreen mode

This will show you the manual page for the ls command, detailing its usage and available flags.

Using Flags to Modify Commands

Most commands can be modified by using flags (also known as options or switches). Flags are extra arguments that change a command's behavior. They usually start with one or two dashes.

For example, the ls command on its own gives a simple list of files. But you can add flags to get more information:

# Simple list of files
ls

# Long format - detailed list with permissions, owner, size, and date
ls -l

# All files - shows hidden files too (those starting with a dot)
ls -a

# Combine flags - detailed list of all files
ls -al
# or
ls -a -l
Enter fullscreen mode Exit fullscreen mode

Flags that are a full word are usually preceded by two dashes (--) and cannot be combined. A common example is the --help flag:

ls --help
Enter fullscreen mode Exit fullscreen mode

Tab Completion

One of the most useful features of the terminal is tab completion. When you start typing a command or a file name, you can press the Tab key to automatically complete it. If there are multiple options, pressing Tab twice will show you all available options.

This feature saves you time and helps avoid typos. For example, if you type:

cd Doc<Tab>
# It will complete to:
cd Documents
Enter fullscreen mode Exit fullscreen mode

Conclusion

In this first part of the series, we covered some basic Linux terminologies, how to navigate the file system, and how to use commands effectively. We also touched on the importance of flags and tab completion.

These fundamentals will serve as the foundation for everything we do moving forward. Don't worry if it feels like a lot—with practice, these commands will become second nature.

In the next part, we'll dive deeper into essential commands, useful shortcuts (including the life-saving reverse search), and learn how to manage processes with signals. We'll also tackle the age-old question: "How do I exit vim?"

Top comments (0)