DEV Community

Programming Entry Level: step by step linux

Understanding Step by Step Linux for Beginners

So, you're starting your programming journey and keep hearing about Linux? Don't worry, it's not as scary as it sounds! In fact, understanding the basics of Linux is a huge advantage for any developer. Many servers run on Linux, deployment often happens on Linux, and even tools like Docker and WSL (Windows Subsystem for Linux) leverage it. You might even encounter questions about Linux in technical interviews. This post will walk you through the fundamentals, step by step, so you can feel comfortable navigating and using this powerful operating system.

Understanding "Step by Step Linux"

Think of your computer as a house. Windows, macOS, and Linux are all different ways to manage that house. They control how everything works, from opening doors (applications) to finding furniture (files). Linux is a bit different because it's open-source, meaning anyone can look at and modify the "blueprint" of the house.

The core of Linux is called the kernel. This is the central part that talks directly to the hardware. But you don't interact with the kernel directly. Instead, you use a shell. The shell is like a translator – you give it commands in a language it understands, and it tells the kernel what to do.

There are different shells, but the most common one you'll encounter as a beginner is Bash (Bourne Again Shell). We'll focus on Bash in this guide.

Imagine you want to find a specific book in your house. You wouldn't tear apart every room! You'd ask someone (the shell) to go to the library (a directory) and find the book (a file). Linux commands are like those requests.

Here's a simple way to visualize it:

graph LR
    A[You] --> B(Shell);
    B --> C{Kernel};
    C --> D[Hardware];
Enter fullscreen mode Exit fullscreen mode

This diagram shows how you interact with the hardware through the shell and kernel.

Basic Code Example

Let's start with some fundamental Linux commands. Open your terminal (on macOS or Linux) or WSL (on Windows).

First, let's see what files and folders are in your current location:

ls
Enter fullscreen mode Exit fullscreen mode

This command, ls, stands for "list". It shows you the contents of the current directory. You'll see a list of files and folders.

Now, let's change directories. Imagine you want to move from the living room to the kitchen. You'd use the cd command (change directory):

cd Documents
Enter fullscreen mode Exit fullscreen mode

This will move you into the "Documents" folder. If you want to go back to the previous folder, you can use:

cd ..
Enter fullscreen mode Exit fullscreen mode

The .. means "parent directory".

Finally, let's create a new folder:

mkdir my_new_folder
Enter fullscreen mode Exit fullscreen mode

mkdir stands for "make directory". This creates a folder named "my_new_folder" in your current location.

Common Mistakes or Misunderstandings

Let's look at some common pitfalls beginners face:

❌ Incorrect code:

ls -l
Enter fullscreen mode Exit fullscreen mode

(Trying to list files with a space between -l and the directory name)

✅ Corrected code:

ls -l
Enter fullscreen mode Exit fullscreen mode

Explanation: The -l option provides a detailed listing of files (permissions, size, date, etc.). It must be directly attached to the ls command, without a space in between.

❌ Incorrect code:

cd  Documents
Enter fullscreen mode Exit fullscreen mode

(Extra space before "Documents")

✅ Corrected code:

cd Documents
Enter fullscreen mode Exit fullscreen mode

Explanation: Linux is case-sensitive and very strict about spaces. An extra space can cause the command to fail.

❌ Incorrect code:

mkdir new folder
Enter fullscreen mode Exit fullscreen mode

(Space in the folder name)

✅ Corrected code:

mkdir new_folder
Enter fullscreen mode Exit fullscreen mode

Explanation: While you can create folders with spaces in their names, it's generally best practice to avoid them. If you must use spaces, you'll need to "escape" them with a backslash (\) or enclose the name in quotes. Using underscores (_) is much simpler.

Real-World Use Case

Let's say you're working on a simple Python project. You want to organize your files into a specific structure. Here's how you could do it using Linux commands:

# Create a project directory

mkdir my_python_project

# Navigate into the project directory

cd my_python_project

# Create a directory for source code

mkdir src

# Create a directory for tests

mkdir tests

# Create a main Python file

touch src/main.py

# Create a test file

touch tests/test_main.py
Enter fullscreen mode Exit fullscreen mode

touch creates an empty file. This example demonstrates how you can quickly set up a basic project structure using just a few Linux commands. This is a common workflow for developers.

Practice Ideas

Here are a few exercises to solidify your understanding:

  1. File Explorer: Create a directory structure with at least three levels of nested folders.
  2. List Master: Practice using ls with different options (e.g., -l, -a to show hidden files).
  3. Navigation Challenge: Navigate through your file system using cd and cd .. without using a graphical file explorer.
  4. File Creation: Create several empty files using touch and then list them using ls.
  5. Remove and Recreate: Create a folder, remove it using rmdir, and then recreate it. (Be careful with rmdir – it only works on empty directories!)

Summary

You've taken your first steps into the world of Linux! You've learned about the shell, the kernel, and some essential commands like ls, cd, mkdir, and touch. You've also seen how these commands can be used in a real-world project scenario.

Don't be afraid to experiment and make mistakes – that's how you learn! Next, you might want to explore commands for viewing file contents (cat, less), copying and moving files (cp, mv), and searching for files (find). The more you practice, the more comfortable you'll become with Linux, and the more powerful a developer you'll be. Keep exploring, and have fun!

Top comments (0)