Learn Security (Linux+) with Interactive Flashcards
Master key concepts in Security through our interactive flashcard system. Click on each card to reveal detailed explanations and enhance your understanding.
User and Group Management
User and group management is the foundation of system security and administration in Linux, forming a critical component of the AAA (Authentication, Authorization, Accounting) framework. In the context of CompTIA Linux+ and Security+, mastering this ensures systems adhere to the Principle of Least Privilege.
At the technical level, Linux users are defined in /etc/passwd (metadata) and /etc/shadow (secure password hashes), while groups are defined in /etc/group. The root user, identified by User ID (UID) 0, holds supreme authority. Security best practices dictate disabling direct root logins; instead, administrators should use sudo to perform privileged tasks. This, configured via the /etc/sudoers file, creates an audit trail and limits potential damage from accidental commands.
Administrators manage these entities using commands like useradd, usermod, and userdel for accounts, and groupadd for defining roles. Access to files and directories is controlled by assigning specific octal or symbolic permissions (Read, Write, Execute) to the owner, the group, and others using chmod, chown, and chgrp.
From a security perspective, management extends beyond simple account creation. It involves implementing strong password policies (complexity and aging) via Pluggable Authentication Modules (PAM), locking dormant accounts using usermod -L, and ensuring correct special file permission bits (SUID, SGID, Sticky Bit) are set to prevent privilege escalation attacks. Effective group management simplifies administration; rather than assigning permissions to individual users, admins assign permissions to a group and add users to that group. This scalable approach reduces configuration errors and closes security gaps significantly.
File Permissions and ACLs
In the context of CompTIA Linux+ and Security, file access control is fundamental to system hardening and data confidentiality. The standard Linux permission model is known as UGO (User, Group, Others). Every file and directory is assigned an owner and a group. Permissions—Read (r), Write (w), and Execute (x)—are assigned relative to three entities: the owning User, the owning Group, and Others (everyone else). Administrators manage these using commands like `chmod` (change mode) and `chown` (change owner). While effective for general use, standard permissions are rigid; a file can only have one owning group.
To address complex scenarios, Linux utilizes Access Control Lists (ACLs). ACLs provide fine-grained control, allowing administrators to grant permissions to specific users or groups beyond the standard owner/group designation. For instance, if you need to grant write access to a specific contractor without adding them to a sensitive group or opening the file to 'Others', you would use `setfacl`. The `getfacl` command audits these extended attributes.
From a security perspective, mastering both is crucial for implementing the Principle of Least Privilege. Relying solely on standard permissions often leads to over-privileged groups or dangerous 'world-readable/writable' settings. Furthermore, security professionals must vigilantly monitor special permission bits like SUID (Set User ID) and SGID (Set Group ID). While useful for functionality, SUID binaries can be exploited for privilege escalation if they contain vulnerabilities. Therefore, a combination of strict standard permissions and targeted ACLs constitutes the baseline for secure Discretionary Access Control (DAC) on Linux systems.
SELinux and AppArmor
SELinux (Security-Enhanced Linux) and AppArmor (Application Armor) are Linux kernel security modules that implement Mandatory Access Control (MAC). While standard Linux permissions (Discretionary Access Control) rely on user ownership, MAC systems utilize granular policies to restrict what specific applications or processes can do, adhering to the principle of least privilege.
SELinux, developed with the NSA and default on Red Hat-based distributions (RHEL, Fedora), operates on a 'labeling' system. Every file, process, and port has a security context (label). Policies define rules for how a labeled process interacts with a labeled object. It operates in three specific modes: Enforcing (blocks and logs violations), Permissive (logs violations only), and Disabled. Key commands for the exam include 'getenforce', 'sestatus', 'ls -Z' (to see labels), and 'restorecon'.
AppArmor, default on Debian and Ubuntu, uses a 'path-based' approach. It binds security profiles to executable file paths. These profiles are human-readable text files stored in /etc/apparmor.d/ that define exactly what files a program can read, write, or execute. AppArmor modes include Enforce (blocks violations) and Complain (logs violations for debugging). Key commands include 'aa-status', 'aa-genprof', and 'aa-complain'.
In a CompTIA context, the primary distinction is the mechanism: SELinux uses inode labels and is considered more complex but robust, whereas AppArmor uses file paths, making it easier to configure and manage.
SSH Configuration and Security
Secure Shell (SSH) is the industry standard for secure remote Linux administration, operating by default on TCP port 22. In the context of CompTIA Linux+, securing the SSH daemon (`sshd`) is a primary system hardening task, primarily managed via the `/etc/ssh/sshd_config` file.
The most critical configuration step is disabling direct root login by setting `PermitRootLogin no`. This forces attackers to guess a valid username rather than targeting 'root' and ensures that legitimate administrators log in as unprivileged users before elevating rights via `sudo`, creating a better audit trail. Furthermore, password-based authentication should be disabled (`PasswordAuthentication no`) in favor of SSH Key-based authentication (Public Key Infrastructure). This method, which uses a private key on the client and a public key within the server's `~/.ssh/authorized_keys` file, renders traditional dictionary and brute-force password attacks useless.
Access control should be strictly defined using the `AllowUsers` or `AllowGroups` directives to whitelist specific entities. Administrators often change the default listening port to a non-standard number to bypass automated scanning scripts, although this is considered security by obscurity. Additionally, ensuring the use of SSH Protocol 2 is mandatory to avoid vulnerabilities found in Protocol 1. It is also best practice to disable X11 forwarding (`X11Forwarding no`) if GUI tunneling is unnecessary to reduce the attack surface.
On the file system level, strict permissions are required: the `.ssh` directory must be set to `700`, and private keys to `600`. Finally, SSH security should be reinforced by external tools like Fail2Ban, which monitors `/var/log/auth.log` to dynamically ban IPs exhibiting brute-force behavior, and host-based firewalls (such as `ufw` or `iptables`) that restrict SSH traffic to trusted management subnets.
Firewall Configuration (firewalld, ufw, iptables)
In the context of CompTIA Linux+, firewall configuration is the primary method for implementing host-based network security. Linux firewalls interact with the core **Netfilter** kernel subsystem to accept, reject, or drop network packets based on rules.
**iptables** is the traditional, low-level utility used to manage these rules directly. It controls traffic via **chains** (principally INPUT, OUTPUT, and FORWARD) stored in tables. While powerful, iptables serves as a stateless packet filter unless connection tracking is explicitly enabled. Its syntax is complex (e.g., `iptables -A INPUT -p tcp --dport 22 -j ACCEPT`), and rules are lost upon reboot unless manually saved and restored.
**UFW (Uncomplicated Firewall)** is the default on Debian and Ubuntu systems. It acts as a user-friendly wrapper (frontend) for iptables/nftables. UFW simplifies syntax to commands like `ufw allow 80/tcp` or `ufw deny out 25`. It is designed to be easy to script and adheres to an "implicit deny" default policy for incoming traffic once defined via `ufw enable`.
**Firewalld**, default on Red Hat-based systems (RHEL, CentOS, Fedora), introduces dynamic management using D-Bus, allowing rule changes without breaking existing connections. It utilizes **Zones** (e.g., Public, Work, Home) to define trust levels for different network interfaces. Administrators use `firewall-cmd` to manage settings, distinguishing between runtime context and permanent configuration (e.g., `firewall-cmd --permanent --add-service=https`).
For the exam, you must understand that UFW and Firewalld are abstractions of the underlying kernel filtering. Security relies on the **principle of least privilege**: ensure the firewall service is running (`systemctl status firewalld`), only necessary ports are open, and rules are configured to persist across system reboots.