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.
You don’t need to have Linux installed to follow the practical exercises in this post. Use docker playground instead.
Introduction
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.
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
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):
| 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:
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:
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:
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:
# 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... 😅
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.
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!