147 lines
4.6 KiB
Markdown
147 lines
4.6 KiB
Markdown
# Linux – Administration
|
||
|
||
Overview of common Linux administration tasks. Focus on day‑to‑day system management rather than distribution‑specific tools.
|
||
|
||
For foundational concepts (kernel, filesystem, users, processes), see:
|
||
|
||
- [Linux / Basics](./Basics.md)
|
||
|
||
---
|
||
|
||
## 1. User and Group Management
|
||
|
||
Linux uses users and groups to control access to files, processes, and services.
|
||
|
||
Typical administration tasks include:
|
||
|
||
- Creating and removing users.
|
||
- Adding users to groups (for example to grant `sudo` access).
|
||
- Locking or disabling accounts.
|
||
|
||
Key ideas:
|
||
|
||
- Each user has a numeric user ID (UID) and a primary group ID (GID).
|
||
- Additional group memberships are used to grant extra permissions (for example access to Docker or systemd‑journal).
|
||
|
||
---
|
||
|
||
## 2. Privileged Access and sudo
|
||
|
||
Administrative operations are usually performed with elevated privileges.
|
||
|
||
Approaches:
|
||
|
||
- Direct `root` login (less common on modern systems for security reasons).
|
||
- Using `sudo` to run specific commands as `root`.
|
||
|
||
Principles:
|
||
|
||
- Only trusted users should have `sudo` rights.
|
||
- The set of allowed commands can be restricted via the sudoers configuration.
|
||
|
||
In practice, administration is often done as an unprivileged user with `sudo` used only when needed.
|
||
|
||
---
|
||
|
||
## 3. Filesystem Permissions and Ownership
|
||
|
||
Correct file and directory permissions are central to system security and stability.
|
||
|
||
Key aspects:
|
||
|
||
- Ownership (user and group) defines who primarily controls a resource.
|
||
- Permission bits (read, write, execute) for user, group, and others control what can be done.
|
||
- Special bits (setuid, setgid, sticky) influence execution and inheritance in specific cases.
|
||
|
||
Administration tasks related to permissions include:
|
||
|
||
- Adjusting ownership for application data directories.
|
||
- Ensuring configuration files are restricted when they contain secrets.
|
||
- Verifying that log and temporary directories have appropriate access.
|
||
|
||
Additional reminders and command examples can be kept in:
|
||
|
||
- [Linux / Cheat Sheet](./CheatSheet.md)
|
||
|
||
---
|
||
|
||
## 4. Services and systemd Units
|
||
|
||
On many modern Linux distributions, **systemd** is used as the init system and service manager.
|
||
|
||
Concepts:
|
||
|
||
- A **unit** defines how a service, mount, timer, or other resource is started and managed.
|
||
- Service units (for example `ssh.service`, `docker.service`) describe how to start and stop daemons.
|
||
- Targets group units to represent boot states (for example `multi-user.target`).
|
||
|
||
Typical administration actions:
|
||
|
||
- Starting, stopping, and restarting services.
|
||
- Enabling or disabling services at boot.
|
||
- Checking service status and logs.
|
||
|
||
Systemd units are usually stored under `/lib/systemd/system` or `/etc/systemd/system`. Local overrides can be created without modifying vendor files.
|
||
|
||
---
|
||
|
||
## 5. Logs and Troubleshooting
|
||
|
||
System logs are essential for diagnosing issues.
|
||
|
||
On systemd‑based systems, the journal stores logs from the kernel and many services.
|
||
|
||
Common tasks:
|
||
|
||
- Viewing recent logs for a specific service.
|
||
- Filtering logs by priority or time range.
|
||
- Inspecting boot logs to understand startup problems.
|
||
|
||
In addition to the journal, many services also write to files under `/var/log`. Knowing where a service writes its logs is an important part of administration.
|
||
|
||
---
|
||
|
||
## 6. Software Installation and Updates
|
||
|
||
Package management is used to install, update, and remove software.
|
||
|
||
Administration concerns:
|
||
|
||
- Keeping the system reasonably up to date for security fixes.
|
||
- Avoiding unnecessary packages on minimal or security‑sensitive systems.
|
||
- Understanding which repositories are enabled.
|
||
|
||
The concrete commands differ per distribution (for example `apt` vs `dnf`), but the underlying tasks are similar.
|
||
|
||
Distribution‑specific notes and examples can be recorded in a dedicated cheat sheet or in project‑specific documentation.
|
||
|
||
---
|
||
|
||
## 7. Scheduled Tasks and Automation
|
||
|
||
Linux systems provide several mechanisms for scheduled or automated tasks.
|
||
|
||
Common options:
|
||
|
||
- `cron` jobs for periodic execution.
|
||
- systemd timers for more structured scheduling tied to units.
|
||
|
||
These mechanisms are used for activities such as log rotation, backups, or periodic health checks.
|
||
|
||
---
|
||
|
||
## 8. Backup and Recovery Considerations
|
||
|
||
From an administrative perspective, backup and recovery planning includes:
|
||
|
||
- Identifying which directories and data must be backed up.
|
||
- Choosing backup tools and storage locations.
|
||
- Testing restore procedures.
|
||
|
||
Details are often project‑specific and can be documented alongside the systems that depend on them (for example in a home‑server or application‑specific section).
|
||
|
||
---
|
||
|
||
## 9. Relation to Other Documents
|
||
|
||
- [Linux / Cheat Sheet](./CheatSheet.md) |