210 lines
6.1 KiB
Markdown
210 lines
6.1 KiB
Markdown
# Linux – Basics
|
||
|
||
---
|
||
|
||
## 1. What Is Linux?
|
||
|
||
Linux is a family of open-source operating systems built around the Linux kernel. The kernel was created in 1991 by Linus Torvalds and is now maintained by a large community.
|
||
|
||
In practice, "Linux" usually refers to a complete system that combines:
|
||
|
||
- The Linux kernel (manages hardware, memory, processes).
|
||
- User space tools and libraries (often from the GNU project).
|
||
- Additional software such as shells, utilities, and applications.
|
||
|
||
These complete systems are distributed as Linux distributions.
|
||
|
||
---
|
||
|
||
## 2. Linux Distributions
|
||
|
||
A Linux distribution ("distro") bundles the kernel with a selection of software, configuration defaults, and a package manager.
|
||
|
||
Common examples include:
|
||
|
||
- **Debian / Ubuntu** – widely used on servers and desktops; focus on stability and large software repositories.
|
||
- **Fedora / RHEL / CentOS / AlmaLinux** – often used in enterprise environments.
|
||
- **Arch Linux** – rolling release, minimal by default, focused on simplicity and control.
|
||
- **OpenSUSE**, **Gentoo**, and many others.
|
||
|
||
Distributions differ mainly by:
|
||
|
||
- Package manager (`apt`, `dnf`, `pacman`, etc.).
|
||
- Release model (stable vs rolling release).
|
||
- Default configuration and tooling.
|
||
|
||
Despite these differences, the core concepts (filesystem layout, permissions, processes, services) are very similar across distributions.
|
||
|
||
---
|
||
|
||
## 3. Kernel, User Space, and Shell
|
||
|
||
### 3.1 Kernel
|
||
|
||
The kernel is the central part of the operating system. It is responsible for:
|
||
|
||
- Managing memory and CPU time.
|
||
- Talking to hardware devices (disks, network cards, etc.).
|
||
- Creating and scheduling processes.
|
||
- Enforcing basic security boundaries between processes.
|
||
|
||
Users and applications normally do not talk directly to the kernel; they use system calls via libraries and tools.
|
||
|
||
### 3.2 User Space
|
||
|
||
User space contains all programs that run "on top" of the kernel, such as:
|
||
|
||
- Command-line tools (`ls`, `cp`, `mv`, `ps`, etc.).
|
||
- System utilities (`ip`, `systemctl`, `journalctl`, etc.).
|
||
- Libraries (for example the C standard library `glibc`).
|
||
|
||
These tools are what administrators and scripts interact with in daily work.
|
||
|
||
### 3.3 Shell
|
||
|
||
The shell is the command-line interpreter used to run commands and scripts. Common shells include:
|
||
|
||
- **Bash** (Bourne Again SHell).
|
||
- **Zsh**.
|
||
- **Fish**.
|
||
|
||
The shell provides features such as:
|
||
|
||
- Command history and completion.
|
||
- Variables and environment management.
|
||
- Scripting (loops, conditions, functions).
|
||
|
||
For concrete shell usage and commands, see:
|
||
|
||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||
|
||
---
|
||
|
||
## 4. Filesystem and Paths
|
||
|
||
Linux uses a single hierarchical filesystem tree that starts at the root directory `/`.
|
||
|
||
Typical top-level directories include:
|
||
|
||
- `/bin`, `/usr/bin` – essential user commands.
|
||
- `/sbin`, `/usr/sbin` – system administration commands.
|
||
- `/lib`, `/usr/lib` – shared libraries.
|
||
- `/etc` – system-wide configuration files.
|
||
- `/var` – variable data (logs, spool, caches).
|
||
- `/home` – home directories for regular users.
|
||
- `/root` – home directory for the `root` user.
|
||
- `/tmp` – temporary files.
|
||
|
||
Additional mount points (such as `/mnt`, `/srv`, or custom locations) are used for disks, network shares, or application data.
|
||
|
||
Paths can be:
|
||
|
||
- **Absolute** – start with `/` (for example `/etc/hosts`).
|
||
- **Relative** – based on the current working directory (for example `../logs`).
|
||
|
||
---
|
||
|
||
## 5. Users, Groups, and Permissions
|
||
|
||
Linux is a multi-user system. Access control is based on users, groups, and file permissions.
|
||
|
||
### 5.1 Users and Groups
|
||
|
||
- Each user has a numeric user ID (UID) and belongs to one or more groups (GID).
|
||
- The special user `root` (UID 0) has full administrative privileges.
|
||
- Regular users have limited permissions and may use tools like `sudo` to perform administrative tasks.
|
||
|
||
### 5.2 File Permissions
|
||
|
||
Every file and directory has:
|
||
|
||
- An owner user.
|
||
- An owner group.
|
||
- Permission bits for **user**, **group**, and **others**:
|
||
- Read (`r`)
|
||
- Write (`w`)
|
||
- Execute (`x`)
|
||
|
||
Permissions control who can read, modify, or execute a file or enter a directory.
|
||
|
||
---
|
||
|
||
## 6. Processes and Services
|
||
|
||
### 6.1 Processes
|
||
|
||
A process is an instance of a running program. Each process has:
|
||
|
||
- A process ID (PID).
|
||
- A parent process.
|
||
- An associated user.
|
||
|
||
Basic operations include listing processes, checking resource usage, and sending signals to stop or reload them.
|
||
|
||
Concrete commands for process inspection are listed in:
|
||
|
||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||
|
||
### 6.2 Services and systemd
|
||
|
||
Many modern distributions use **systemd** as the init system and service manager.
|
||
|
||
systemd is responsible for:
|
||
|
||
- Starting services at boot.
|
||
- Managing service dependencies.
|
||
- Monitoring and restarting services on failure.
|
||
|
||
Service definitions are stored as **units** (for example `ssh.service`, `docker.service`).
|
||
|
||
For more detailed administration topics (services, logs, units), see:
|
||
|
||
- [Linux / Administration](./Administration.md)
|
||
|
||
---
|
||
|
||
## 7. Networking Overview
|
||
|
||
Linux provides a full networking stack, including:
|
||
|
||
- IPv4 and IPv6 addressing.
|
||
- Routing between interfaces.
|
||
- Firewalling and packet filtering.
|
||
|
||
Network configuration usually involves:
|
||
|
||
- Assigning IP addresses to interfaces.
|
||
- Setting gateways and routes.
|
||
- Configuring DNS resolvers.
|
||
|
||
For networking concepts specific to this knowledge base, see:
|
||
|
||
- [Network / Basics](../Network/Basics.md)
|
||
|
||
---
|
||
|
||
## 8. Package Management
|
||
|
||
Each distribution uses a package manager to install, update, and remove software:
|
||
|
||
- Debian/Ubuntu: `apt`, `apt-get`, `dpkg`.
|
||
- RHEL/Fedora: `dnf`, `yum`, `rpm`.
|
||
- Arch Linux: `pacman`.
|
||
|
||
Package managers handle:
|
||
|
||
- Downloading software from repositories.
|
||
- Dependency resolution.
|
||
- Keeping a local database of installed packages.
|
||
|
||
Concrete command examples for package management can be added to the Cheat Sheet or distribution-specific notes.
|
||
|
||
---
|
||
|
||
## 9. Where to Go Next
|
||
|
||
- For hands-on commands and quick reminders, see [Linux / Cheat Sheet](./CheatSheet.md).
|
||
- For administration tasks (services, logs, users, updates), see [Linux / Administration](./Administration.md).
|
||
- For networking details, see [Network / Basics](../Network/Basics.md).
|
||
|
||
This basics document is intended as a neutral foundation that other, more specific guides can reference. |