User & Authentication
chage --maxdays 90 [user]: Set password expiration.
passwd -l [user]: Lock a user account.
userdel -r [user]: Delete a user and their home directory.
awk -F: '($2 == "")' /etc/shadow: Find accounts with empty passwords.
visudo: Safely edit the sudoers file.
lastlog: Review last login times for all users.
usermod -aG [group] [user]: Add a user to a group.
Filesystem & Permissions
find / -type f -perm -o+w: Find world-writable files.
find / -type d -perm -o+w: Find world-writable directories.
chmod 600 /etc/shadow: Secure shadow file permissions.
chmod 750 /etc/sudoers: Secure sudoers file permissions.
mount | grep /tmp: Check /tmp mount options.
aideinit: Initialize the AIDE database.
aide --check: Check for file integrity changes.
ls -lZ: View file SELinux contexts.
chown root:root /etc/crontab: Set ownership of main crontab.
Networking & Firewall
ufw enable: Enable the Uncomplicated Firewall.
ufw default deny incoming: Set default deny policy.
ufw allow ssh: Allow SSH traffic.
ufw status verbose: Check firewall status.
ss -tuln: List all listening ports.
ss -tan: Show all TCP connections.
sysctl -p: Apply kernel parameters from sysctl.conf.
netstat -r: Display the kernel routing table.
Services & System
systemctl list-units --type=service: List all active services.
systemctl disable [service]: Disable a service from starting on boot.
systemd-analyze security: Analyze security of running units.
journalctl -p err: View system logs for errors.
apt-get update && apt-get upgrade: Update system packages (Debian).
yum update -y: Update system packages (RHEL).
reboot: Reboot the system (e.g., to apply kernel updates).
Auditing & Scanning
rkhunter --check: Scan for rootkits.
chkrootkit: Check for rootkit signatures.
lynis audit system: Perform a full system security scan.
sestatus: Check SELinux status.
setenforce 1: Put SELinux in enforcing mode.
getsebool -a: List all SELinux booleans.
setsebool -P [boolean] on: Persistently enable an SELinux boolean.
ausearch -m AVC -ts recent: Find recent SELinux denials.
auditctl -l: List all auditd rules.
SSH Hardening
sshd -t: Test the SSH daemon configuration.
systemctl restart sshd: Restart the SSH service.
echo "PermitRootLogin no" >> /etc/ssh/sshd_config: Disable root login.
echo "Protocol 2" >> /etc/ssh/sshd_config: Use SSH protocol 2 only.
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config: Disable password authentication (use keys).
echo "MaxAuthTries 3" >> /etc/ssh/sshd_config: Limit authentication attempts.
echo "AllowUsers [user1] [user2]" >> /etc/ssh/sshd_config: Whitelist allowed users.
ssh-keygen -t rsa -b 4096: Generate a strong SSH key pair.
fail2ban-client status sshd: Check Fail2Ban status for the SSH jail.