This commit is contained in:
2025-06-04 18:30:20 +03:30
parent a7509c6285
commit ac1d0dfdeb
3 changed files with 148 additions and 26 deletions

View File

@@ -47,29 +47,3 @@ Created by external developers or organizations. Use with caution and verify tru
## 🌍 Package Mirrors ## 🌍 Package Mirrors
Mirrors are alternative download sources for package repositories, often closer geographically for faster updates. 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.

148
Linux/LPIC1/5-apt.md Normal file
View File

@@ -0,0 +1,148 @@
# 📦 Managing Packages with `apt` on Debian/Ubuntu
The `apt` (Advanced Package Tool) command-line utility allows you to manage software on Debian-based Linux systems. Below are essential `apt` commands grouped by purpose, with clear explanations for each.
---
## 🔄 1. Updating and Upgrading the System
### `sudo apt update`
Fetches the latest package lists from repositories. This ensures your system is aware of the newest available versions of packages.
```bash
sudo apt update
```
---
### `apt upgrade`
Installs the newest versions of all installed packages based on the updated package lists. It does **not** remove or install any other packages.
```bash
apt upgrade
```
---
## 🔍 2. Searching and Viewing Packages
### `apt show <package>`
Displays detailed information about a specific package, including version, dependencies, description, and more.
```bash
apt show <package>
```
---
### `apt list`
Lists packages based on various filters (e.g., installed, upgradable, available). Running it without arguments shows all packages.
```bash
apt list
```
---
### `apt-cache search <pkg name>`
Searches the package cache for packages matching the given name or description. Useful for discovering packages related to a topic or function.
```bash
apt-cache search <pkg name>
```
---
## 📥 3. Installing and Reinstalling Packages
### `apt install <pkg name>`
Installs a package and its dependencies from the repositories.
```bash
apt install <pkg name>
```
---
### `apt reinstall <package>`
Reinstalls the specified package. This is useful if files from a package are accidentally deleted or corrupted.
```bash
apt reinstall <package>
```
---
## ❌ 4. Removing Packages
### `apt remove <package>`
Removes the specified package but **retains configuration files**. Useful when planning to reinstall later without losing settings.
```bash
apt remove <package>
```
---
### `apt purge <package>`
Completely removes the package **along with its configuration files**. Use when you want a clean uninstallation.
```bash
apt purge <package>
```
---
### `apt autoremove`
Automatically removes packages that were installed as dependencies but are no longer needed.
```bash
apt autoremove
```
---
## 🛠️ 5. Advanced Package Handling
### `apt install -f`
Attempts to **fix broken dependencies** by installing missing packages. Often used after a failed install.
```bash
apt install -f
```
---
### `apt install --download-only <package>`
Downloads a package without installing it. The downloaded `.deb` files are saved in:
```bash
/var/cache/apt/archives/
```
Example:
```bash
apt install --download-only <package>
```
---
## ✅ Final Notes
* Always start with `sudo apt update` before any install or upgrade.
* Use `apt-cache search` when unsure of a packages exact name.
* Be cautious with `purge` as it deletes config files too.

0
Linux/LPIC1/6-yum.md Normal file
View File