---
title: "Linux World (part I)"
description: "Today, we will explore the world of Linux. Why we study Linux's security, management, file system, commands, and the general Linux environment."
canonical_url: "https://otabek.io/blogs/linux-world-part-i"
md_url: "https://otabek.io/blogs/linux-world-part-i.md"
language: "en"
last_updated: "2024-06-15"
tags: ["Operating System"]
---

# Linux World (part I)

Today, we will discover the world of Linux together. We'll cover why Linux's security, management, file system, commands, and overall environment are important to learn.

![Linux Meme](https://telegra.ph/file/3e722483adf40da6fd439.jpg)

> You don’t need to have Linux installed to follow the practical exercises in this post. Use [docker playground](https://labs.play-with-docker.com/) instead.

### Introduction

![](https://telegra.ph/file/60366987ac21ed14db237.gif)

There are two essential concepts you need to understand in the Linux world: **SHELL** and **KERNEL** (we’ll dive deeper into these at the end of this post). **KERNEL** is the core part of your operating system that manages everything. **SHELL**, on the other hand, is the interface that lets you communicate with the **KERNEL**. You've probably heard of it as **bash**, **zsh**, or even **fish**. In short, you type commands into the **SHELL**, it translates them to the **KERNEL**, and your computer performs the requested task. It's a simple concept.

Imagine you have a fresh Linux system with no software installed. Let’s start installing the necessary programs. We will need a package installer tool like `apt`, `apt-get`, `apk`, or `yum`. For example, let’s install **ipython**.

![](https://telegra.ph/file/171e0fe135da9345e9c04.gif)

Since we are using Linux Alpine, we’ll use **apk**, while Ubuntu uses **apt** or **apt-get**.

> Before using **apt install** in Ubuntu, remember to run **apt update** first, because the installer often comes with outdated URLs. Without updating, it might not be able to fetch the latest versions of software.

### File System

![Linux File System Meme](https://telegra.ph/file/feb7a9f1974ee30fe177f.png)

There are many types of **files**, such as txt, mp3, jpeg, png, etc. **Directory** is what you might call a **folder** in Russian (папка). Below is a list of the important **directories** in Linux (try to understand in English, as translations may sometimes alter meanings):

```bash
| Directory | Description                                          |
| --------- | ---------------------------------------------------- |
| /bin      | binary or executable programs.                       |
| /etc      | system configuration files.                          |
| /home     | home directory, where your personal files reside.    |
| /opt      | optional or third-party software.                    |
| /tmp      | temporary space, typically cleared on reboot.        |
| /usr      | user-related programs.                               |
| /var      | log files and variable data.                         |
```

For learning how to work with files, the best resource is the Linux section of the 42.uz Express Backend course:

<iframe width="100%" height="200" src="https://www.youtube.com/embed/PcoP1mykdEs" title="Shell Bor Joyda, Yo&#39;l Bor | Express Backend (1-bo&#39;lim)" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

### Access Control

Let’s imagine you’ve been hired as a **Cloud Administrator** (just kidding, don’t apply for this job yet). Now, you’re responsible for managing the security of the system. Developers in your office have asked you for access to certain resources. What will you do? **You**: I’ll give them root access. **Me**:

![](https://gifdb.com/images/high/matthew-perry-oh-no-eqz81f12tsymfmjl.gif)

No, don’t do that. Instead, create a new user for the person and grant only the permissions they need. To create a user, you can use the **adduser** command:

```bash
adduser <username>
```

When you create a new user, they can only read, write, and execute their own files. They won’t have access to modify other files. If you trust the user, you can give them **superuser** privileges (or **sudo**, short for superuser do). In Linux, users are organized into groups, and users can perform tasks based on the permissions granted to their group. To grant **sudo** access, you need to add the user to the **sudoers** group:

```bash
# usermod command to add user to sudo group
usermod -a -G sudo <username>
```

Now, the user can run commands with elevated privileges using **sudo**. Learn more about groups for better management. And just a heads-up, don't think just because you can use **sudo**, you should... 😅

![](https://telegra.ph/file/5ae6ce323bd96614a9726.jpg)

### Process Control

> In Linux, every program runs as a **process**, and each process is identified by a unique **PID** (Process ID).

Let’s say you granted access to a **jprq** (a random program), and now it’s using too many resources (RAM, CPU, or Storage) or acting strangely. You don’t know exactly what it's doing. To identify and monitor resource usage, use the `top` or `htop` commands.

Once you've identified the process and its **PID**, how do you stop it? Use the **kill** command. The **kill** command sends various **signals** to processes, but it doesn't actually kill the program; it simply informs it of the action. The program will respond to the signal based on its type.

![](https://telegra.ph/file/f8000f8bee541335efbd8.png)

```bash
kill <signal> <PID>
```

For example, the **-9** signal will forcefully terminate the process, while the **-20** signal suspends it. To resume a suspended process, you can use the `fg <PID>` command. There are many other commands to explore.

### Conclusion

In upcoming parts, we will dive deeper into the tricks used by young hackers and explore the darker sides of Linux with hands-on examples. Sharing is caring—feel free to share this post with your friends!

---

```quiz
{
  "quiz": {
    "id": "linux-basics-quiz",
    "title": "Linux Basics Quiz",
    "description": "Test your understanding of Linux fundamentals",
    "questions": [
      {
        "id": "q1",
        "type": "single-choice",
        "question": "What is the KERNEL in Linux?",
        "options": [
          { "id": "a", "text": "The core part of the OS that manages everything", "description": "" },
          { "id": "b", "text": "The command line interface", "description": "That's the SHELL, not the KERNEL." },
          { "id": "c", "text": "A type of Linux distribution", "description": "The kernel is the core of ALL Linux distributions." },
          { "id": "d", "text": "A package manager", "description": "Package managers (apt, yum) are separate tools, not the kernel." }
        ]
      },
      {
        "id": "q2",
        "type": "single-choice",
        "question": "What is the SHELL used for?",
        "options": [
          { "id": "a", "text": "Managing hardware resources", "description": "That's the kernel's job. Shell is for user interaction." },
          { "id": "b", "text": "Communicating with the KERNEL", "description": "" },
          { "id": "c", "text": "Storing files", "description": "The file system stores files, not the shell." },
          { "id": "d", "text": "Running graphical applications only", "description": "Shell is a command-line interface, not just for graphics." }
        ]
      },
      {
        "id": "q3",
        "type": "drag-drop",
        "question": "Match the directories to their purposes:",
        "items": [
          { "id": "bin", "content": "/bin - Binary/executable programs" },
          { "id": "etc", "content": "/etc - System configuration files" },
          { "id": "home", "content": "/home - User personal files" },
          { "id": "tmp", "content": "/tmp - Temporary files" },
          { "id": "var", "content": "/var - Log files and variable data" }
        ]
      },
      {
        "id": "q4",
        "type": "drag-fill",
        "question": "Complete the command to add a user to the sudo group:",
        "template": "{{b1}} -a -G {{b2}} <username>",
        "options": [
          { "id": "opt1", "content": "usermod" },
          { "id": "opt2", "content": "sudo" }
        ],
        "blanks": [
          { "id": "b1" },
          { "id": "b2" }
        ]
      },
      {
        "id": "q5",
        "type": "single-choice",
        "question": "What does PID stand for in Linux?",
        "options": [
          { "id": "a", "text": "Process Identification", "description": "Close! It's Process ID, a unique identifier for each process." },
          { "id": "b", "text": "Process ID", "description": "" },
          { "id": "c", "text": "Program Identifier", "description": "It identifies processes, not programs specifically." },
          { "id": "d", "text": "Protected ID", "description": "PID stands for Process ID." }
        ]
      },
      {
        "id": "q6",
        "type": "single-choice",
        "question": "Which command forcefully terminates a process?",
        "options": [
          { "id": "a", "text": "kill -9 <PID>", "description": "" },
          { "id": "b", "text": "kill -20 <PID>", "description": "Signal -20 suspends a process, it doesn't terminate it." },
          { "id": "c", "text": "stop <PID>", "description": "There's no 'stop' command for processes in Linux." },
          { "id": "d", "text": "end <PID>", "description": "There's no 'end' command - use 'kill' with signals." }
        ]
      }
    ]
  },
  "answers": {
    "q1": { "correctOptionIds": ["a"] },
    "q2": { "correctOptionIds": ["b"] },
    "q3": { "correctOrder": ["bin", "etc", "home", "tmp", "var"] },
    "q4": { "correctPlacements": { "b1": "opt1", "b2": "opt2" } },
    "q5": { "correctOptionIds": ["b"] },
    "q6": { "correctOptionIds": ["a"] }
  }
}
```


## Sitemap

See the full [Markdown sitemap](/sitemap.md) for all pages.
