> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/linux-server-administrator.md).

# Linux Server Administrator

Linux is a Unix-like operating system based on the Linux kernel, created by Linus Torvalds in 1991. It is free and open-source, meaning anyone can view, modify, and distribute its source code. Linux is known for its stability, security, and flexibility, making it popular for servers, desktops, embedded systems, and more.

## **Linux Features**

1. **Open Source:** The source code is freely available for modification and distribution.
2. **Multitasking:** Supports the simultaneous execution of multiple tasks.
3. **Multiuser:** Allows multiple users to use the system simultaneously.
4. **Portable:** Can be installed and run on various hardware platforms.
5. **Security:** Offers robust security features like file permissions, encryption, and user roles.
6. **Reliability:** Known for its stability and low risk of crashes.

***

## **Linux Distributions**

Linux distributions (or "distros") are customised versions of the Linux operating system, tailored for specific use cases. Each distribution includes the Linux kernel, system utilities, and software packages.

| **Distribution**  | **Package Format** | **Package Manager** | **Examples**                                    |
| ----------------- | ------------------ | ------------------- | ----------------------------------------------- |
| **Debian-based**  | `.deb`             | `dpkg` and `apt`    | Ubuntu, Kali Linux, Debian                      |
| **Red Hat-based** | `.rpm`             | `rpm` and `yum`     | Fedora, CentOS, Red Hat Enterprise Linux (RHEL) |

## **Linux Directory Structure**

Linux file system follows a hierarchical directory structure.

| **Directory** | **Description**                                                                                                            |
| ------------- | -------------------------------------------------------------------------------------------------------------------------- |
| **/**         | The **root directory**, the top-level directory in the hierarchy. All other directories and files are nested under this.   |
| **/bin**      | Contains **essential binary executables** (commands) required for system booting and operation (e.g., `ls`, `cp`, `bash`). |
| **/boot**     | Stores **bootloader files** (e.g., kernel, initramfs) needed to start the system.                                          |
| **/dev**      | Contains **device files** that represent hardware components (e.g., `/dev/sda` for a hard disk).                           |
| **/etc**      | Holds **system-wide configuration files** (e.g., `/etc/passwd`, `/etc/hosts`).                                             |
| **/home**     | Contains **personal directories** for all non-root users (e.g., `/home/username`).                                         |
| **/lib**      | Stores **shared library files** required by system binaries in `/bin` and `/sbin`.                                         |
| **/lib64**    | (On 64-bit systems) Contains 64-bit shared libraries.                                                                      |
| **/media**    | Used for mounting **removable media** like USB drives, CDs, etc.                                                           |
| **/mnt**      | A temporary mount point for **manually mounted filesystems** (e.g., network shares).                                       |
| **/opt**      | Reserved for **optional or third-party software** installations.                                                           |
| **/proc**     | A **virtual filesystem** that provides information about running processes and system resources (e.g., `/proc/cpuinfo`).   |
| **/root**     | The **home directory for the root user** (system administrator).                                                           |
| **/run**      | Stores **runtime data** for processes started since the last boot (e.g., PID files).                                       |
| **/sbin**     | Contains **system administration binaries** (e.g., `fdisk`, `iptables`).                                                   |
| **/srv**      | Holds **data for services** provided by the system (e.g., web server files).                                               |
| **/sys**      | A **virtual filesystem** that exposes kernel and hardware information.                                                     |
| **/tmp**      | Stores **temporary files**, which are usually deleted upon reboot.                                                         |
| **/usr**      | Contains **user-installed software**, libraries, and documentation.                                                        |
| **/var**      | Stores **variable data** such as logs, databases, and spool files.                                                         |

#### **Visual Representation of the Linux Directory Structure**

```
/
├── bin
├── boot
├── dev
├── etc
├── home
│   └── username
├── lib
├── lib64
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
│   ├── bin
│   ├── lib
│   ├── local
│   └── share
└── var
    ├── log
    ├── cache
    └── spool
```
