Understanding Linux Authentication and Access Control
Authentication is the foundation of Linux security. It determines who can access a system and what they can do.
Authentication Methods and User Files
Linux uses several authentication methods: passwords, SSH keys, and multi-factor authentication. The /etc/passwd file contains user account information. The /etc/shadow file stores encrypted password hashes, accessible only to root.
User IDs (UID) and Group IDs (GID) form the basis of Linux's permission model. Every file and directory has three permission sets:
- Owner (read=4, write=2, execute=1)
- Group (read=4, write=2, execute=1)
- Others (read=4, write=2, execute=1)
Permission Notation and Special Bits
Umask values determine default permissions for newly created files and directories. Understanding the difference between standard users, system users, and root is crucial.
Special bits control additional access:
- Setuid: Run with file owner's permissions
- Setgid: Run with group's permissions
- Sticky bit: Only owner can delete files in a directory
Delegated Administration and ACLs
Sudo (superuser do) allows delegated administrative tasks without sharing the root password. Configure it through /etc/sudoers.
Access Control Lists (ACLs) provide fine-grained permission management beyond basic permissions. Use getfacl and setfacl commands to manage ACLs. Flashcards help you memorize permission notation (755, 644) and command syntax for managing users and groups like useradd, usermod, groupadd, and passwd.
SELinux and Mandatory Access Control
SELinux (Security Enhanced Linux) implements mandatory access control (MAC) beyond traditional discretionary access control (DAC). DAC depends on file ownership and user permissions. SELinux enforces policies that restrict even privileged processes.
SELinux Modes and Context Labels
SELinux operates in three modes:
- Enforcing (policies are applied and violations blocked)
- Permissive (policies checked but violations logged only)
- Disabled (SELinux is off)
Context labels follow a user:role:type:level format. The type is the most important component for determining access rules.
Managing SELinux Policies
SELinux booleans enable or disable specific policy rules without editing complex configuration files. Use semanage to manage SELinux policies and getenforce to check the current mode.
The audit daemon (auditd) logs SELinux violations in /var/log/audit/audit.log. Use chcon to temporarily change labels and semanage fcontext for permanent changes.
AppArmor and Troubleshooting
AppArmor provides similar mandatory access control on some Linux distributions as an alternative to SELinux. For Linux+ exam preparation, knowing when to use SELinux booleans versus custom policies is essential for practical security implementation.
Cryptography, Encryption, and Secure Communication
Encryption protects data confidentiality by converting readable plaintext into unreadable ciphertext using cryptographic algorithms and keys.
Symmetric and Asymmetric Encryption
Symmetric encryption uses a single shared key for encryption and decryption. Common algorithms include AES, DES, and 3DES.
Asymmetric encryption uses public and private key pairs. Data encrypted with the public key can only be decrypted with the private key. RSA and ECC are common algorithms.
SSH (Secure Shell) provides encrypted remote access using public key cryptography. SSH keys stored in ~/.ssh/authorized_keys enable password-less authentication.
Cryptographic Tools and Standards
GPG (GNU Privacy Guard) implements OpenPGP standards for encrypting files, emails, and creating digital signatures.
SSL/TLS protocols encrypt web traffic using certificates verified by certificate authorities. The /etc/ssl/certs directory stores trusted certificate authorities.
Hash functions create fixed-size digests from variable-length data. Use them for integrity verification and password storage:
- MD5 and SHA-1 (deprecated)
- SHA-256 and SHA-512 (current standards)
HMAC combines hashing with a secret key for authentication. Generate keys with openssl genrsa, create requests with openssl req, and sign certificates accordingly.
Firewall Configuration and Network Security
Firewalls control network traffic by filtering packets based on predefined rules. Linux firewalls operate at the kernel level using netfilter, with user-space tools providing configuration interfaces.
Firewall Tools and Concepts
iptables is the traditional command-line firewall tool using tables (filter, nat, mangle) and chains (INPUT, OUTPUT, FORWARD). Each rule specifies source/destination addresses, ports, protocols, and actions (ACCEPT, DROP, REJECT).
firewalld provides dynamic firewall management with zones and services, automatically handling rule complexities. ufw (Uncomplicated Firewall) simplifies configuration with intuitive commands like "ufw allow 22/tcp".
Stateful packet inspection tracks connection states, intelligently allowing return traffic for established connections. Network Address Translation (NAT) enables private IP addresses to communicate through public IPs.
Security Scenarios and Monitoring
Common firewall scenarios include:
- Blocking specific ports
- Allowing services based on allowlists
- Protecting against port scans
- Rate limiting traffic
- SSH hardening through non-standard ports
netstat and ss display open ports and connections. tcpdump and wireshark capture and analyze network traffic for security monitoring. Regular firewall audits ensure rules align with security policies.
Auditing, Logging, and Security Monitoring
Security auditing tracks system activities and changes, creating evidence trails for compliance and incident investigation. The auditd daemon captures detailed kernel-level events configured through /etc/audit/audit.rules.
Audit Configuration and Tools
Audit rules monitor file access, system calls, authentication attempts, and permission changes. Use ausearch and aureport tools to query audit logs stored in /var/log/audit/audit.log.
Syslog centralizes log collection from various services, configured in /etc/rsyslog.conf. Logs use facilities (auth, authpriv, kern) and severity levels (debug, info, notice, warning, err, crit, alert, emerg).
Log Management and Analysis
Log rotation through logrotate prevents logs from consuming excessive disk space while retaining historical records. Important security logs include:
- /var/log/auth.log or /var/log/secure (authentication)
- /var/log/syslog (system messages)
- Application-specific logs
Failed login attempts should trigger alerts and investigations. The last command shows login history, wtmp stores login records, and lastlog displays recent logins per user.
File Integrity and Incident Detection
AIDE (Advanced Intrusion Detection Environment) monitors file integrity, detecting unauthorized modifications. Tripwire provides comprehensive file system monitoring. Regular log reviews identify suspicious patterns like repeated failed logins or unusual process execution. Log aggregation and SIEM (Security Information and Event Management) tools centralize monitoring across multiple systems.
