added apt doc

This commit is contained in:
2025-05-28 21:44:45 +03:30
parent d761d87e16
commit 2ce50f4aa9
4 changed files with 159 additions and 59 deletions

View File

@@ -0,0 +1,84 @@
# 🐧 Linux Runlevels Guide
This guide provides a concise overview of traditional **runlevels** in Linux systems, particularly for **Red Hat** and **Debian**-based distributions. Runlevels define specific states of system operation, historically managed by the `init` system.
---
## 🔄 System Boot Sequence
```plaintext
BIOS → Bootloader → Kernel → init
```
* **BIOS**: Performs hardware checks via **POST** (Power-On Self Test).
* **Bootloader**: Loads the kernel.
* **Kernel**: Initializes system and mounts the root filesystem.
* **init**: Launches system processes based on the selected runlevel.
---
## 📊 Runlevels Comparison
| Runlevel | Description | Red Hat | Debian |
| -------- | ----------------------------------- | ---------------- | --------------- |
| 0 | Halt / Shutdown | ✅ Supported | ✅ Supported |
| 1 | Single-User Mode | ✅ Supported | ✅ Supported |
| 2 | Multi-User (No Network) | ❌ (Includes Net) | ✅ Supported |
| 3 | Multi-User (Network, No GUI) | ✅ Supported | ✅ Supported |
| 4 | User-Defined / Custom | ✅ Supported | ✅ Supported |
| 5 | GUI Mode / *(Halt on some systems)* | ✅ GUI Mode | ⚠️ Custom/Halt? |
| 6 | Reboot | ✅ Supported | ✅ Supported |
> 💡 **Notes**:
> • **Runlevel 5** on Red Hat typically launches a full graphical environment (GUI).
> • On Debian, runlevels 25 are often configured identically and can be customized.
> • Runlevel behavior is configurable via `/etc/inittab` (SysVinit systems).
---
## 🔧 Useful Commands
### ✅ Check Current Runlevel
```bash
runlevel
```
### 🔁 Change Runlevel
```bash
telinit <runlevel>
```
or
```bash
init <runlevel>
```
> ⚠️ **Caution**: Switching runlevels may stop services or terminate user sessions. Use carefully on production systems.
---
## 🚀 Modern Systems: systemd Targets
Most modern Linux distributions use **systemd**, which replaces runlevels with **targets**.
| Runlevel | systemd Target |
| -------- | ------------------- |
| 0 | `poweroff.target` |
| 1 | `rescue.target` |
| 3 | `multi-user.target` |
| 5 | `graphical.target` |
| 6 | `reboot.target` |
### 📌 Common systemd Commands
```bash
# Show default target
systemctl get-default
# Change to graphical mode
systemctl isolate graphical.target
```

View File

@@ -0,0 +1,75 @@
# 📦 Linux Libraries & Package Management
This guide provides a quick overview of **library types**, **package sources**, and **Debian-based package management** commands using `apt`.
---
## 📚 Library Types
Linux supports two main types of libraries:
1. **Static Libraries (`.a`)**
- Linked at **compile-time**
- Included in the final binary
- Larger file size, faster execution
2. **Shared Libraries (`.so`)**
- Linked at **run-time**
- Saved separately from the binary
- Saves space and allows updates without recompiling
---
## 📦 Package Sources
### ✅ Official Packages
Provided and maintained by the distribution (e.g., Debian, Ubuntu, Red Hat).
### 🌐 Third-Party Packages
Created by external developers or organizations. Use with caution and verify trustworthiness.
---
## 🏬 Linux Package Managers
### 📦 Debian-based Systems
- **Package Manager**: `apt`
- **Low-level Tool**: `dpkg`
- **Package Format**: `.deb`
### 📦 Red Hat-based Systems
- **Package Manager**: `yum` or `dnf` (newer)
- **Low-level Tool**: `rpm`
- **Package Format**: `.rpm`
---
## 🌍 Package Mirrors
Mirrors are alternative download sources for package repositories, often closer geographically for faster updates.
To sync with package mirrors and get the latest updates:
```bash
sudo apt update
```
---
## 🔧 Common `apt` Commands
| Command | Description |
|--------------------------|---------------------------------------|
| `apt update` | Refresh package lists |
| `apt upgrade` | Upgrade all installed packages |
| `apt list` | List packages |
| `apt show <package>` | Show details of a package |
| `apt install <package>` | Install a new package |
| `apt reinstall <package>`| Reinstall an existing package |
| `apt remove <package>` | Remove a package (keep config files) |
| `apt purge <package>` | Remove package **and** config files |
| `apt-cache search <term>`| Search for a package |
| `apt autoremove` | Remove unused dependencies |
> 🔐 Use `sudo` before these commands when required.

View File

@@ -1,59 +0,0 @@
# Linux Runlevels Guide
This document outlines the standard runlevels for **Red Hat** and **Debian**-based systems. Runlevels are used by `init` systems to define different states or modes of operation for the system.
---
## 📊 Runlevels Overview
| Runlevel | Description | Red Hat | Debian |
| -------- | ------------------------------------ | ------------ | --------------- |
| 0 | Halt | ✅ Supported | ✅ Supported |
| 1 | Single User Mode | ✅ Supported | ✅ Supported |
| 2 | Multi-user (No Network) | ❌ (HaveNet) | ✅ Supported |
| 3 | Multi-user (Network, No GUI) | ✅ Supported | ✅ Supported |
| 4 | Custom/User Defined | ✅ Supported | ✅ Supported |
| 5 | Multi-user (GUI Mode) / Halt *(err)* | ❌ (GUI Mode) | ❌ (Halt/Error?) |
| 6 | Reboot | ✅ Supported | ✅ Supported |
> 💡 **Note**:
>
> * On **Red Hat**, runlevel 5 typically starts the system with a graphical user interface (GUI).
> * On **Debian**, runlevel 5 is often unused or reserved for custom setups.
> * Runlevel behavior can be customized depending on system configuration.
---
## 🔧 Commands
### Check Current Runlevel
```bash
runlevel
```
### Change Runlevel
```bash
telinit <runlevel>
```
or
```bash
init <runlevel>
```
> ⚠️ Changing runlevels may stop or restart services. Use with caution, especially on production systems.
---
## 📚 Additional Tips
* Modern Linux systems (especially systemd-based) may not rely on traditional runlevels. Instead, they use *targets*. Example:
```bash
systemctl get-default
systemctl isolate graphical.target
```