Chủ Nhật, 5 tháng 4, 2026

🐧 LPI Linux Certification Tutorial

LPI Linux Certification – Tutorial Toàn Diện

🐧 LPI Linux Certification Tutorial

Hướng dẫn toàn diện từ cơ bản đến nâng cao · Dựa theo LPI Linux Certification in a Nutshell 2nd Ed.

LPIC-1 (Exam 101 + 102) LPIC-2 (Exam 201 + 202) 20+ năm kinh nghiệm thực chiến
LPIC-1 · Topic 101 · Exam 101
🖥️ Hardware Architecture
Nhận biết và cấu hình phần cứng trong Linux
📋
1. Menu Tổng Thể – Các chủ đề trong Module
Sub-topicNội dung chínhMức độ quan trọng
101.1Xác định và cấu hình phần cứng⭐⭐⭐
101.2Boot the system⭐⭐⭐
101.3Thay đổi runlevels / boot targets⭐⭐⭐
🎯
2. Mục Đích Module

Module này giúp bạn hiểu cách Linux nhận diện và quản lý phần cứng – từ CPU, RAM, thiết bị PCI/USB đến quá trình khởi động hệ thống. Đây là nền tảng để debug phần cứng và cấu hình hệ thống.

  • Biết cách xem thông tin phần cứng mà không cần mở máy
  • Hiểu quá trình boot: BIOS/UEFI → Bootloader → Kernel → Init
  • Quản lý runlevels và systemd targets
  • Nạp và gỡ kernel modules
📖
3. Giải Thích Chi Tiết & Ví Dụ

🔍 101.1 – Xem thông tin phần cứng

Linux cung cấp nhiều lệnh và file ảo trong /proc, /sys để xem thông tin phần cứng:

Terminal – Xem thông tin phần cứng
root@server:~# lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma]
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE
00:02.0 VGA compatible: Cirrus Logic GD 5446
00:03.0 Ethernet: Red Hat, Inc. Virtio network device

root@server:~# lspci -v        # Chi tiết hơn
root@server:~# lspci -k        # Hiển thị kernel driver đang dùng

root@server:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0781:5581 SanDisk Corp. Ultra

root@server:~# cat /proc/cpuinfo | head -20
processor   : 0
vendor_id   : GenuineIntel
model name  : Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
cpu cores   : 8
cache size  : 20480 KB

root@server:~# cat /proc/meminfo | head -10
MemTotal:       16384000 kB
MemFree:         8192000 kB
MemAvailable:   12288000 kB
Buffers:          512000 kB
Cached:          4096000 kB

root@server:~# dmidecode -t memory   # Xem RAM vật lý (cần root)

🔌 Quản lý Kernel Modules

Terminal – Kernel Modules
root@server:~# lsmod
Module                  Size  Used by
iptable_nat            16384  1
nf_nat                 49152  2 iptable_nat
ext4                  909312  2

root@server:~# modinfo ext4     # Xem chi tiết module
filename: /lib/modules/5.15.0/kernel/fs/ext4/ext4.ko
description: Fourth Extended Filesystem
author: Remy Card, Stephen Tweedie, Andrew Morton...

root@server:~# modprobe ext4    # Nạp module (tự động xử lý dependencies)
root@server:~# modprobe -r ext4 # Gỡ module
root@server:~# insmod /path/module.ko  # Nạp thủ công (không xử lý deps)
root@server:~# rmmod ext4       # Gỡ thủ công

🚀 101.2 – Quá trình Boot

💡 Thứ tự boot: BIOS/UEFI → POST → MBR/GPT → Bootloader (GRUB2) → Kernel → initramfs → init/systemd → runlevel/target
Terminal – Kiểm tra boot messages
root@server:~# dmesg | head -30
[    0.000000] Linux version 5.15.0 (gcc version 11.3.0)
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz root=/dev/sda1
[    0.001000] BIOS-provided physical RAM map:
[    0.001000]  BIOS-e820: [mem 0x0000-0x09ffff] usable

root@server:~# dmesg -T | grep -i error  # Tìm lỗi trong boot
root@server:~# journalctl -b             # Toàn bộ boot log (systemd)
root@server:~# journalctl -b -1          # Boot log lần trước

⚙️ 101.3 – Runlevels và Systemd Targets

RunlevelSystemd TargetMô tả
0poweroff.targetTắt máy
1rescue.targetSingle user (recovery)
2,3,4multi-user.targetMulti-user, không có GUI
5graphical.targetMulti-user với GUI
6reboot.targetKhởi động lại
Terminal – Quản lý Targets
root@server:~# systemctl get-default
graphical.target

root@server:~# systemctl set-default multi-user.target
Created symlink /etc/systemd/system/default.target → multi-user.target

root@server:~# systemctl isolate rescue.target  # Chuyển ngay sang rescue
root@server:~# who -r                            # Xem runlevel hiện tại
         run-level 5  2024-01-15 08:00

root@server:~# runlevel
N 5
4. Câu Hỏi Ôn Tập
Lệnh nào hiển thị danh sách các thiết bị PCI trong hệ thống?
A. lsusb
B. lspci
C. dmidecode
D. hdparm
Lệnh nào nạp module kernel và tự động xử lý các dependency?
A. insmod
B. rmmod
C. modprobe
D. lsmod
Systemd target nào tương đương với runlevel 3 (multi-user, không GUI)?
A. graphical.target
B. multi-user.target
C. rescue.target
D. emergency.target
File nào trong /proc chứa thông tin về RAM của hệ thống?
A. /proc/cpuinfo
B. /proc/meminfo
C. /proc/version
D. /proc/mounts
📌
5. Tổng Kết
lspci / lsusbLiệt kê thiết bị PCI và USB kết nối
/proc/cpuinfo & /proc/meminfoThông tin CPU và RAM dạng text
modprobe / lsmodQuản lý kernel modules với dependency
dmesg / journalctl -bĐọc boot messages và kernel log
systemctl get/set-defaultCấu hình target mặc định khi boot
Thứ tự bootBIOS → GRUB2 → Kernel → initramfs → systemd
🔬
6. Bài Tập Thực Hành
Bài 1: Điều tra phần cứng hệ thống

Tạo một báo cáo phần cứng bằng cách chạy các lệnh sau và lưu kết quả vào file hw_report.txt:

  • Liệt kê tất cả thiết bị PCI và driver đang sử dụng
  • Xem thông tin CPU (số lõi, tốc độ, model)
  • Xem tổng RAM và RAM còn trống
  • Liệt kê các kernel module đang được nạp
Lời giải
# Tạo báo cáo phần cứng
root@server:~# {
  echo "=== PCI Devices ==="
  lspci -k
  echo ""
  echo "=== CPU Info ==="
  grep -E "model name|cpu cores|MHz" /proc/cpuinfo | sort -u
  echo ""
  echo "=== Memory Info ==="
  grep -E "MemTotal|MemFree|MemAvailable" /proc/meminfo
  echo ""
  echo "=== Loaded Modules ==="
  lsmod
} > hw_report.txt

root@server:~# cat hw_report.txt | head -30
=== PCI Devices ===
00:00.0 Host bridge: Intel Corporation...
        Kernel driver in use: agpgart-intel
=== CPU Info ===
cpu cores       : 8
model name      : Intel(R) Xeon(R) E5-2670 @ 2.60GHz
=== Memory Info ===
MemAvailable:   12288000 kB
MemFree:         8192000 kB
MemTotal:       16384000 kB
Bài 2: Thay đổi default boot target

Thực hiện các bước: (1) Kiểm tra target hiện tại, (2) Đổi sang multi-user.target, (3) Xác nhận thay đổi, (4) Đổi lại graphical.target

Lời giải
# Bước 1: Kiểm tra target hiện tại
root@server:~# systemctl get-default
graphical.target

# Bước 2: Đổi sang multi-user (text mode)
root@server:~# systemctl set-default multi-user.target
Created symlink /etc/systemd/system/default.target
 → /lib/systemd/system/multi-user.target

# Bước 3: Xác nhận
root@server:~# systemctl get-default
multi-user.target

# Bước 4: Đổi lại graphical
root@server:~# systemctl set-default graphical.target
Created symlink /etc/systemd/system/default.target
 → /lib/systemd/system/graphical.target
LPIC-1 · Topic 102 · Exam 101
📦 Cài đặt Linux & Quản lý Package
Phân vùng ổ đĩa, bootloader, thư viện chia sẻ, Debian & RPM packaging
📋
1. Menu Tổng Thể
Sub-topicNội dung
102.1Thiết kế layout ổ đĩa (disk partitioning)
102.2Cài đặt Boot Manager (GRUB2)
102.3Quản lý shared libraries
102.4Debian package management (dpkg, apt)
102.5RPM & YUM/DNF package management
🎯
2. Mục Đích Module

Đây là kỹ năng thiết yếu của một sysadmin: cài đặt hệ thống từ đầu, phân vùng đĩa khoa học, quản lý phần mềm bằng package manager của từng distro (Debian/Ubuntu dùng dpkg/apt; RHEL/CentOS dùng rpm/dnf).

📖
3. Giải Thích Chi Tiết & Ví Dụ

💾 102.1 – Disk Partitioning

Layout khuyến nghị cho server production: /boot 1GB, / 20GB, /home phần còn lại, swap = 1–2x RAM
fdisk – Phân vùng ổ đĩa
root@server:~# fdisk -l /dev/sda
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Device     Boot   Start       End   Sectors  Size  Id Type
/dev/sda1  *       2048   2099199   2097152    1G  83 Linux
/dev/sda2       2099200  43956223  41857024   20G  83 Linux
/dev/sda3      43956224 100663295  56707072   27G  83 Linux
/dev/sda4     100663296 104857599   4194304    2G  82 Linux swap

root@server:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0   20G  0 part /
├─sda3   8:3    0   27G  0 part /home
└─sda4   8:4    0    2G  0 part [SWAP]

root@server:~# parted /dev/sdb    # Dùng parted cho GPT (>2TB)

🔧 102.3 – Shared Libraries

Quản lý thư viện chia sẻ
root@server:~# ldd /bin/ls
        linux-vdso.so.1 (0x00007ffc12345000)
        libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
        /lib64/ld-linux-x86-64.so.2

root@server:~# ldconfig          # Cập nhật cache thư viện
root@server:~# ldconfig -p | grep libssl  # Tìm libssl trong cache
        libssl.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl.so.3

📦 102.4 – Debian Package Management (apt/dpkg)

apt & dpkg commands
# === APT (high-level, xử lý dependencies tự động) ===
root@ubuntu:~# apt update              # Cập nhật danh sách package
root@ubuntu:~# apt upgrade             # Nâng cấp tất cả package
root@ubuntu:~# apt install nginx       # Cài nginx
root@ubuntu:~# apt remove nginx        # Gỡ nginx (giữ config)
root@ubuntu:~# apt purge nginx         # Gỡ hoàn toàn kể cả config
root@ubuntu:~# apt search "web server" # Tìm kiếm package
root@ubuntu:~# apt show nginx          # Xem chi tiết package

# === DPKG (low-level, không xử lý dependencies) ===
root@ubuntu:~# dpkg -i package.deb     # Cài file .deb cục bộ
root@ubuntu:~# dpkg -r nginx           # Gỡ package
root@ubuntu:~# dpkg -l | grep nginx    # Kiểm tra đã cài chưa
ii  nginx  1.18.0-6ubuntu1  amd64  small, powerful web server
root@ubuntu:~# dpkg -L nginx           # Liệt kê files của package
root@ubuntu:~# dpkg -S /usr/sbin/nginx # Package nào chứa file này?
nginx: /usr/sbin/nginx

🔴 102.5 – RPM & DNF/YUM (RHEL/CentOS)

rpm & dnf commands
# === DNF (high-level, xử lý dependencies) ===
root@centos:~# dnf install httpd       # Cài Apache
root@centos:~# dnf remove httpd        # Gỡ package
root@centos:~# dnf update              # Cập nhật tất cả
root@centos:~# dnf search nginx        # Tìm package
root@centos:~# dnf list installed      # Liệt kê đã cài

# === RPM (low-level) ===
root@centos:~# rpm -ivh package.rpm    # Install verbose với progress bar
root@centos:~# rpm -e httpd            # Erase (gỡ) package
root@centos:~# rpm -q httpd            # Query (kiểm tra cài chưa)
httpd-2.4.51-7.el9.x86_64
root@centos:~# rpm -ql httpd           # List files của package
root@centos:~# rpm -qf /etc/httpd/conf/httpd.conf  # File thuộc package nào?
httpd-2.4.51-7.el9.x86_64
root@centos:~# rpm -V httpd            # Verify tính toàn vẹn package
4. Câu Hỏi Ôn Tập
Lệnh nào kiểm tra file nào trong hệ thống thuộc về package "nginx" trên Debian?
A. dpkg -l nginx
B. dpkg -L nginx
C. dpkg -S nginx
D. apt show nginx
Lệnh ldd được dùng để làm gì?
A. Cập nhật cache thư viện hệ thống
B. Hiển thị shared libraries mà một chương trình phụ thuộc vào
C. Liệt kê files trong một package
D. Kiểm tra tính toàn vẹn của package
Trên CentOS/RHEL, lệnh nào tìm package chứa file /usr/bin/vim?
A. rpm -ql vim
B. rpm -qf /usr/bin/vim
C. dnf search /usr/bin/vim
D. rpm -q /usr/bin/vim
📌
5. Tổng Kết
apt / dpkgHệ thống package của Debian/Ubuntu. apt xử lý deps, dpkg low-level
dnf / rpmHệ thống package của RHEL/CentOS. dnf thay thế yum từ RHEL8+
lddXem shared libraries mà một binary phụ thuộc
ldconfigCập nhật cache /etc/ld.so.cache cho dynamic linker
fdisk / partedPhân vùng ổ đĩa (fdisk cho MBR, parted cho GPT)
lsblk / df -hXem layout ổ đĩa và dung lượng đã dùng
🔬
6. Bài Tập Thực Hành
Bài 1: Package investigation

Trên hệ thống Ubuntu: (1) Cài package curl, (2) Xem danh sách files được cài, (3) Tìm package nào cung cấp file /usr/bin/curl, (4) Gỡ hoàn toàn curl kể cả config.

Lời giải
# (1) Cài curl
root@ubuntu:~# apt update && apt install -y curl

# (2) Xem files được cài
root@ubuntu:~# dpkg -L curl
/usr/bin/curl
/usr/share/doc/curl/changelog.Debian.gz
/usr/share/man/man1/curl.1.gz

# (3) Tìm package chứa file
root@ubuntu:~# dpkg -S /usr/bin/curl
curl: /usr/bin/curl

# (4) Gỡ hoàn toàn
root@ubuntu:~# apt purge curl
root@ubuntu:~# apt autoremove  # Dọn dependencies không còn cần
LPIC-1 · Topic 103 · Exam 101
⌨️ GNU & Unix Commands
Làm chủ command line: files, text, processes, I/O redirection, regex
📋
1. Menu Tổng Thể
Sub-topicNội dung
103.1Làm việc với command line shell
103.2Xử lý văn bản (grep, awk, sed, cut, sort)
103.3Quản lý files và thư mục
103.4Streams, pipes, và I/O redirection
103.5Tạo, theo dõi, tắt processes
103.6Tìm kiếm với find
103.7Tìm kiếm với locate, which, whereis
📖
3. Giải Thích Chi Tiết & Ví Dụ

🔀 103.4 – I/O Redirection & Pipes

Redirection & Pipes
# Standard streams: stdin(0), stdout(1), stderr(2)
user@linux:~$ ls /tmp > output.txt       # stdout → file (ghi đè)
user@linux:~$ ls /tmp >> output.txt      # stdout → file (thêm vào)
user@linux:~$ ls /nonexist 2> err.txt    # stderr → file
user@linux:~$ ls /tmp /nonexist > all.txt 2>&1   # cả stdout và stderr
user@linux:~$ cat < input.txt            # stdin từ file
user@linux:~$ ls /tmp 2>/dev/null        # Bỏ stderr (null device)

# Pipes: kết nối stdout của lệnh này → stdin của lệnh khác
user@linux:~$ ps aux | grep nginx | grep -v grep
user@linux:~$ cat /var/log/auth.log | grep "Failed" | wc -l
47

# tee: ghi vào file VÀ tiếp tục pipe
user@linux:~$ ls /tmp | tee /tmp/list.txt | wc -l

📝 103.2 – Xử lý văn bản

grep, awk, sed, cut, sort
# grep – tìm kiếm pattern
user@linux:~$ grep "error" /var/log/syslog
user@linux:~$ grep -i "error" /var/log/syslog   # case-insensitive
user@linux:~$ grep -r "TODO" /home/user/src/     # recursive
user@linux:~$ grep -v "^#" /etc/fstab            # loại bỏ dòng comment
user@linux:~$ grep -E "^[0-9]{1,3}\." /etc/hosts # Extended regex

# cut – cắt cột từ dữ liệu có delimiter
user@linux:~$ cut -d: -f1,3 /etc/passwd
root:0
daemon:1
www-data:33

# sort – sắp xếp
user@linux:~$ sort /etc/passwd                   # ABC
user@linux:~$ sort -t: -k3 -n /etc/passwd        # Theo UID (cột 3, số)
user@linux:~$ sort -rn /tmp/numbers.txt          # Giảm dần số
user@linux:~$ sort -u /tmp/list.txt              # Loại bỏ trùng lặp

# awk – xử lý cột mạnh mẽ
user@linux:~$ awk -F: '{print $1, $3}' /etc/passwd
root 0
daemon 1
user@linux:~$ awk -F: '$3 > 1000 {print $1}' /etc/passwd  # UID > 1000
user@linux:~$ df -h | awk 'NR>1 {print $5, $6}'  # % dùng và mount point

# sed – chỉnh sửa stream
user@linux:~$ sed 's/old/new/g' file.txt         # Thay thế tất cả
user@linux:~$ sed -i 's/apache/nginx/g' config   # Thay trực tiếp trong file
user@linux:~$ sed '/^#/d' /etc/ssh/sshd_config   # Xóa dòng comment
user@linux:~$ sed -n '10,20p' bigfile.log        # In dòng 10-20

⚙️ 103.5 – Quản lý Processes

Process management
user@linux:~$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY  STAT START  COMMAND
root         1  0.0  0.1 225856  9132 ?   Ss   08:00  /sbin/init
nginx     1234  0.1  0.5 123456 40960 ?   S    08:01  nginx: worker

user@linux:~$ ps -ef | grep nginx   # BSD style
user@linux:~$ top                   # Real-time monitor
user@linux:~$ htop                  # Đẹp hơn top (cần cài)

# Signals
user@linux:~$ kill -9 1234          # SIGKILL – force kill
user@linux:~$ kill -15 1234         # SIGTERM – terminate gracefully
user@linux:~$ kill -1 1234          # SIGHUP – reload config
user@linux:~$ killall nginx         # Kill theo tên
user@linux:~$ pkill -u john         # Kill tất cả process của user john

# Background jobs
user@linux:~$ sleep 100 &           # Chạy nền
user@linux:~$ jobs                  # Xem background jobs
[1]+  Running   sleep 100 &
user@linux:~$ fg %1                 # Đưa job 1 ra foreground
user@linux:~$ bg %1                 # Tiếp tục chạy nền
user@linux:~$ nohup long_script.sh & # Chạy không bị kill khi logout

🔍 103.6 – Tìm kiếm với find

find – lệnh tìm file linh hoạt nhất
# Cú pháp: find [path] [criteria] [action]
user@linux:~$ find /home -name "*.log"
user@linux:~$ find /tmp -name "*.tmp" -mtime +7 -delete  # Xóa file >7 ngày
user@linux:~$ find / -perm -4000 2>/dev/null   # Tìm file SUID (bảo mật)
/usr/bin/sudo
/usr/bin/passwd
/usr/bin/su
user@linux:~$ find /var -size +100M             # Tìm file lớn hơn 100MB
user@linux:~$ find /home -user john -type f      # File của user john
user@linux:~$ find /etc -newer /etc/passwd       # File mới hơn passwd
user@linux:~$ find /tmp -name "*.log" -exec rm {} \;  # Thực thi lệnh
4. Câu Hỏi Ôn Tập
Lệnh nào in ra cột 1 và 3 từ /etc/passwd với dấu phân cách là dấu hai chấm (:)?
A. awk -d: '{print $1, $3}' /etc/passwd
B. cut -d: -f1,3 /etc/passwd
C. grep -d: -f1,3 /etc/passwd
D. sed -F: '{print $1, $3}' /etc/passwd
Để gửi cả stdout và stderr vào một file all.log, lệnh nào đúng?
A. command 2>&1 > all.log
B. command > all.log 2>&1
C. command 2> all.log
D. command &>> all.log
Lệnh nào tìm tất cả file có quyền SUID trong hệ thống?
A. find / -perm 4000
B. find / -perm -4000
C. find / -type s -perm 4000
D. locate -perm 4000
Lệnh sed nào thay thế TẤT CẢ chữ "http" bằng "https" trong file config.txt và lưu trực tiếp vào file?
A. sed -i 's/http/https/' config.txt
B. sed -i 's/http/https/g' config.txt
C. sed 's/http/https/g' config.txt
D. sed -r 's/http/https/g' config.txt
📌
5. Tổng Kết
grep / egrepTìm kiếm pattern trong text, -i (case), -r (recursive), -v (invert)
cut / sort / uniqCắt cột, sắp xếp, loại bỏ trùng lặp trong dữ liệu
awkNgôn ngữ xử lý cột mạnh mẽ nhất trên CLI
sedStream editor – thay thế, xóa, chèn text
> >> 2>&1Redirection: stdout, append, stderr vào stdout
findTìm file theo name, type, size, permission, thời gian
kill / killallGửi signal đến process: SIGTERM(15), SIGKILL(9), SIGHUP(1)
ps aux / topXem danh sách và monitor process đang chạy
🔬
6. Bài Tập Thực Hành
Bài 1: Log Analysis – Phân tích access log

Từ file /var/log/nginx/access.log, hãy: (1) Đếm tổng số request, (2) Tìm 10 IP truy cập nhiều nhất, (3) Tìm tất cả request trả về lỗi 404, (4) Tìm request lớn nhất (theo bytes)

Lời giải
# (1) Tổng số request
user@linux:~$ wc -l /var/log/nginx/access.log
15234 /var/log/nginx/access.log

# (2) Top 10 IP truy cập nhiều nhất
user@linux:~$ awk '{print $1}' /var/log/nginx/access.log \
  | sort | uniq -c | sort -rn | head -10
 1543 192.168.1.100
  876 10.0.0.55
  234 203.0.113.42

# (3) Tất cả request 404
user@linux:~$ grep ' 404 ' /var/log/nginx/access.log | wc -l
89

# (4) Request lớn nhất (cột 10 là bytes)
user@linux:~$ awk '{print $10, $7}' /var/log/nginx/access.log \
  | sort -rn | head -5
Bài 2: File Hunt – Tìm files nguy hiểm

Tìm tất cả file: (1) Có quyền SUID, (2) Thuộc về root và có thể ghi bởi others, (3) Lớn hơn 500MB, (4) Không có owner (orphan files)

Lời giải
# (1) SUID files
root@server:~# find / -perm -4000 -type f 2>/dev/null

# (2) Root-owned world-writable files
root@server:~# find / -user root -perm -002 -type f 2>/dev/null

# (3) Files lớn hơn 500MB
root@server:~# find / -size +500M -type f 2>/dev/null \
  -exec ls -lh {} \;

# (4) Orphan files (không có owner)
root@server:~# find / -nouser -o -nogroup 2>/dev/null
LPIC-1 · Topic 104 · Exam 101
📁 Filesystem & Thiết Bị
Filesystem, quyền truy cập, links, disk quotas
📖
Nội dung chính

🔒 Permissions & Ownership

chmod, chown, umask
root@server:~# ls -la /var/www/html/
drwxr-xr-x 2 www-data www-data 4096 Jan 15 10:00 .
-rw-r--r-- 1 www-data www-data 1234 Jan 15 09:00 index.html

# chmod – thay đổi quyền
root@server:~# chmod 755 /var/www/html        # Số octal: rwxr-xr-x
root@server:~# chmod u+x,g-w script.sh         # Symbolic notation
root@server:~# chmod -R 644 /var/www/html/     # Recursive

# chown – thay đổi owner
root@server:~# chown www-data:www-data index.html
root@server:~# chown -R nginx:nginx /etc/nginx/

# umask – mask mặc định khi tạo file
user@linux:~$ umask
0022
# File mới: 666 - 022 = 644 (rw-r--r--)
# Dir mới:  777 - 022 = 755 (rwxr-xr-x)

# Special bits
root@server:~# chmod u+s /usr/bin/passwd    # Set SUID
root@server:~# chmod g+s /shared/project/   # Set SGID trên thư mục
root@server:~# chmod +t /tmp/               # Sticky bit

🔗 Hard Links vs Symbolic Links

ln command
# Hard link: cùng inode, cùng filesystem
user@linux:~$ ln file.txt hardlink.txt
user@linux:~$ ls -li file.txt hardlink.txt
1234567 -rw-r--r-- 2 user group 100 Jan 15 file.txt
1234567 -rw-r--r-- 2 user group 100 Jan 15 hardlink.txt
# Cùng inode (1234567), link count = 2

# Symbolic link: pointer đến path, có thể cross-filesystem
user@linux:~$ ln -s /etc/nginx/nginx.conf nginx.conf
user@linux:~$ ls -la nginx.conf
lrwxrwxrwx 1 user group 23 Jan 15 nginx.conf -> /etc/nginx/nginx.conf

user@linux:~$ stat file.txt    # Xem inode và link count

💽 Filesystem Operations

mkfs, mount, fstab
# Tạo filesystem
root@server:~# mkfs.ext4 /dev/sdb1
root@server:~# mkfs.xfs /dev/sdb2
root@server:~# mkswap /dev/sdb3 && swapon /dev/sdb3

# Mount / Unmount
root@server:~# mount /dev/sdb1 /mnt/data
root@server:~# mount -t ext4 -o ro /dev/sdb1 /mnt/data  # read-only
root@server:~# umount /mnt/data

# /etc/fstab – mount tự động khi boot
root@server:~# cat /etc/fstab
UUID=abc123  /         ext4  defaults          0 1
UUID=def456  /boot     ext4  defaults          0 2
UUID=ghi789  /home     ext4  defaults,noexec   0 2
tmpfs        /tmp      tmpfs  defaults,size=1G 0 0

# Kiểm tra filesystem
root@server:~# df -h      # Disk free (human readable)
root@server:~# du -sh /var/log/  # Dung lượng thư mục
root@server:~# fsck /dev/sdb1    # Check và sửa filesystem (phải unmount)
LPIC-1 · Topic 105 · Exam 102
🐚 Shells & Shell Scripts
Bash scripting, environment variables, aliases
📖
Nội dung chính

🌍 Environment Variables

Environment & Shell config
user@linux:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

user@linux:~$ export MY_VAR="hello"   # Tạo biến môi trường
user@linux:~$ env | grep MY_VAR       # Xem tất cả env vars
user@linux:~$ unset MY_VAR            # Xóa biến

# Shell config files (Bash)
# Login shell:  /etc/profile → ~/.bash_profile → ~/.bashrc
# Non-login:    /etc/bash.bashrc → ~/.bashrc

user@linux:~$ source ~/.bashrc        # Reload config
user@linux:~$ alias ll='ls -alh'      # Tạo alias
user@linux:~$ type ll                 # Kiểm tra type của lệnh
ll is aliased to 'ls -alh'

📜 Bash Scripting cơ bản

backup.sh – Script ví dụ đầy đủ
#!/bin/bash
# Script backup thư mục quan trọng

BACKUP_DIR="/backup"
SOURCE_DIR="/home"
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="${BACKUP_DIR}/home_${DATE}.tar.gz"

# Kiểm tra thư mục backup tồn tại
if [ ! -d "$BACKUP_DIR" ]; then
    mkdir -p "$BACKUP_DIR"
    echo "Created backup directory: $BACKUP_DIR"
fi

# Tạo backup
echo "Starting backup of $SOURCE_DIR..."
tar -czf "$BACKUP_FILE" "$SOURCE_DIR" 2>/dev/null

# Kiểm tra kết quả
if [ $? -eq 0 ]; then
    echo "✓ Backup successful: $BACKUP_FILE"
    ls -lh "$BACKUP_FILE"
else
    echo "✗ Backup failed!" >&2
    exit 1
fi

# Xóa backup cũ hơn 7 ngày
find "$BACKUP_DIR" -name "home_*.tar.gz" -mtime +7 -delete
echo "Old backups cleaned."

🔄 Loops & Conditions

Control structures
# For loop
for server in web1 web2 web3; do
    echo "Pinging $server..."
    ping -c 1 $server &>/dev/null && echo "  UP" || echo "  DOWN"
done

# While loop
count=0
while [ $count -lt 5 ]; do
    echo "Count: $count"
    ((count++))
done

# Case statement
case "$1" in
    start)   systemctl start nginx ;;
    stop)    systemctl stop nginx ;;
    status)  systemctl status nginx ;;
    *)       echo "Usage: $0 {start|stop|status}" ;;
esac

# Functions
check_service() {
    if systemctl is-active --quiet "$1"; then
        echo "$1 is running"
    else
        echo "$1 is stopped"
        return 1
    fi
}
check_service nginx
check_service mysql
LPIC-1 · Topic 106 · Exam 102
🖥️ Giao Diện Người Dùng & Desktops
X Window System, display managers, accessibility
📖
Nội dung chính

🪟 X Window System

X11 & Display
user@linux:~$ echo $DISPLAY
:0
user@linux:~$ xdpyinfo | grep -E "name|version|dimensions"
name of display: :0
X.Org version: 1.21.1.3
dimensions: 1920x1080 pixels
root@server:~# systemctl start gdm      # GNOME Display Manager
user@linux:~$ DISPLAY=:0 xterm &        # Mở terminal trên display :0
LPIC-1 · Topic 107 · Exam 102
👥 Administrative Tasks
Users, groups, cron jobs, localization
📖
Nội dung chính

👤 Quản lý Users & Groups

useradd, usermod, passwd
root@server:~# useradd -m -s /bin/bash -G sudo,www-data john
root@server:~# passwd john
root@server:~# usermod -aG docker john  # Thêm vào group docker
root@server:~# userdel -r john          # Xóa user và home dir
root@server:~# groupadd developers
root@server:~# id john
uid=1001(john) gid=1001(john) groups=1001(john),27(sudo),33(www-data)

# Files quan trọng
root@server:~# cat /etc/passwd  # user:pass:uid:gid:comment:home:shell
root@server:~# cat /etc/shadow  # Password hash (chỉ root đọc được)
root@server:~# cat /etc/group   # group:pass:gid:members

⏰ Cron Jobs

Crontab syntax
# Format: MIN HOUR DAY MONTH WEEKDAY COMMAND
# *=any, */n=every n, a-b=range, a,b=list

user@linux:~$ crontab -e      # Chỉnh sửa crontab của user
root@server:~# crontab -e -u john  # Crontab của john

# Ví dụ crontab entries:
0 2 * * *       /usr/bin/backup.sh           # 2:00 AM mỗi ngày
*/15 * * * *    /usr/local/bin/monitor.sh    # Mỗi 15 phút
0 8 * * 1-5     /home/john/workday.sh        # 8:00 AM Mon-Fri
0 0 1 * *       /usr/bin/monthly-report.sh   # Đầu mỗi tháng
@reboot         /usr/local/bin/startup.sh    # Khi boot

user@linux:~$ crontab -l      # Xem crontab hiện tại
LPIC-1 · Topic 108 · Exam 102
🔧 Hệ Thống & Dịch Vụ
Systemd, logging, MTA, printing, time sync
📖
Nội dung chính

🚀 Systemd Service Management

systemctl commands
root@server:~# systemctl start nginx
root@server:~# systemctl stop nginx
root@server:~# systemctl restart nginx
root@server:~# systemctl reload nginx       # Reload config, không restart
root@server:~# systemctl enable nginx        # Auto-start khi boot
root@server:~# systemctl disable nginx
root@server:~# systemctl status nginx
● nginx.service - A high performance web server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
     Active: active (running) since Mon 2024-01-15 08:01:23; 2h ago
    Process: 1234 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 1235 (nginx)
      Tasks: 5 (limit: 4915)
     Memory: 12.5M

root@server:~# systemctl list-units --type=service --state=running

📋 Logging với journald & rsyslog

journalctl & log files
root@server:~# journalctl -f                  # Follow (như tail -f)
root@server:~# journalctl -u nginx             # Log của service nginx
root@server:~# journalctl --since "1 hour ago"
root@server:~# journalctl -p err               # Chỉ hiện lỗi

# Traditional log files
/var/log/syslog      – System messages (Debian)
/var/log/messages    – System messages (RHEL)
/var/log/auth.log    – Authentication log
/var/log/kern.log    – Kernel log
/var/log/nginx/      – Web server logs
LPIC-1 · Topic 109 · Exam 102
🌐 Networking Fundamentals
IP configuration, hostname, routing, DNS, SSH
📖
Nội dung chính

🔌 Network Configuration

ip & legacy net commands
# ip command (modern – thay thế ifconfig)
root@server:~# ip addr show
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

root@server:~# ip addr add 192.168.1.200/24 dev eth0
root@server:~# ip route show
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel
root@server:~# ip route add default via 192.168.1.1
root@server:~# ip link set eth0 up/down

# Kiểm tra kết nối
user@linux:~$ ping -c 4 google.com
user@linux:~$ traceroute 8.8.8.8
user@linux:~$ ss -tuln          # Socket statistics (thay netstat)
Netid State  Recv-Q Send-Q  Local Address:Port
tcp   LISTEN 0      128          0.0.0.0:22
tcp   LISTEN 0      511          0.0.0.0:80
tcp   LISTEN 0      511          0.0.0.0:443

user@linux:~$ host google.com     # DNS lookup
user@linux:~$ dig +short google.com  # DNS query chi tiết
user@linux:~$ nslookup google.com

🔐 SSH Configuration

SSH client & server
# SSH key-based authentication
user@local:~$ ssh-keygen -t ed25519 -C "john@company.com"
user@local:~$ ssh-copy-id user@remote-server
user@local:~$ ssh -i ~/.ssh/id_ed25519 user@192.168.1.100

# SSH tunnel
user@local:~$ ssh -L 8080:localhost:80 user@remote  # Port forward
user@local:~$ ssh -D 1080 user@remote               # SOCKS proxy

# /etc/ssh/sshd_config – cấu hình SSH server
Port 22
PermitRootLogin no          # Không cho root SSH
PasswordAuthentication no   # Chỉ dùng key
AllowUsers john admin       # Chỉ cho phép user cụ thể
LPIC-1 · Topic 110 · Exam 102
🔐 Bảo Mật Hệ Thống
Security admin, shadow passwords, sudo, PAM, encryption
📖
Nội dung chính

🛡️ Sudo & Privilege Escalation

sudo & sudoers
# /etc/sudoers – LUÔN chỉnh bằng visudo!
root@server:~# visudo

# Cú pháp: user host=(runas) commands
john    ALL=(ALL:ALL) ALL              # john có toàn quyền
deploy  ALL=(www-data) /usr/bin/git   # deploy chạy git với www-data
%admin  ALL=(ALL) NOPASSWD: ALL       # Group admin không cần password
ops     ALL=(ALL) /bin/systemctl      # ops chỉ được dùng systemctl

user@linux:~$ sudo -l           # Xem quyền sudo của mình
user@linux:~$ sudo -u www-data ls /var/www

🔥 Firewall với iptables/nftables

iptables basics
# Xem rules hiện tại
root@server:~# iptables -L -n -v
Chain INPUT (policy ACCEPT)
 pkts bytes target  prot opt in   out  source      destination
  100  5000 ACCEPT  all  --  lo   any  0.0.0.0/0   0.0.0.0/0
   50  3000 ACCEPT  tcp  --  any  any  0.0.0.0/0   0.0.0.0/0   tcp dpt:22

# Thêm rules
root@server:~# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
root@server:~# iptables -A INPUT -p tcp --dport 443 -j ACCEPT
root@server:~# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
root@server:~# iptables -P INPUT DROP   # Mặc định block

# Lưu rules
root@server:~# iptables-save > /etc/iptables/rules.v4
LPIC-2 · Topic 201 · Exam 201
⚡ Linux Kernel
Kernel compilation, modules, kernel options
📖
Nội dung chính

🔨 Kernel Build & Management

Kernel compilation
root@server:~# uname -r
5.15.0-91-generic
root@server:~# uname -a
Linux server 5.15.0-91-generic #101-Ubuntu SMP x86_64 GNU/Linux

# Kernel parameters tại runtime
root@server:~# sysctl -a | head -20
root@server:~# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
root@server:~# sysctl -w net.ipv4.ip_forward=1  # Bật IP forwarding

# Persistent: thêm vào /etc/sysctl.conf
net.ipv4.ip_forward = 1
vm.swappiness = 10
net.core.somaxconn = 1024

root@server:~# sysctl -p    # Áp dụng từ /etc/sysctl.conf

# Xem kernel boot params
root@server:~# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-5.15.0-91 root=UUID=abc123 ro quiet splash
LPIC-2 · Topic 202 · Exam 201
🚀 System Startup & Boot
GRUB2 advanced, init systems, boot troubleshooting
📖
GRUB2 Configuration
GRUB2 Management
# GRUB2 config file locations
/etc/default/grub        – Main settings
/etc/grub.d/             – Scripts để generate grub.cfg
/boot/grub/grub.cfg      – Generated config (KHÔNG edit trực tiếp)

# Chỉnh /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=0
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

# Sau khi chỉnh, generate lại grub.cfg
root@server:~# update-grub          # Debian/Ubuntu
root@centos:~# grub2-mkconfig -o /boot/grub2/grub.cfg  # RHEL

# Reinstall GRUB vào MBR
root@server:~# grub-install /dev/sda
LPIC-2 · Topic 203 · Exam 201
💾 Filesystem & Storage Advanced
LVM, RAID, filesystem tuning, iSCSI
📖
LVM – Logical Volume Manager
LVM Setup
# LVM layers: Physical Volume → Volume Group → Logical Volume

# 1. Tạo Physical Volumes
root@server:~# pvcreate /dev/sdb /dev/sdc
root@server:~# pvdisplay

# 2. Tạo Volume Group
root@server:~# vgcreate data_vg /dev/sdb /dev/sdc
root@server:~# vgdisplay data_vg

# 3. Tạo Logical Volumes
root@server:~# lvcreate -L 20G -n web_lv data_vg
root@server:~# lvcreate -L 50G -n db_lv data_vg
root@server:~# mkfs.ext4 /dev/data_vg/web_lv
root@server:~# mount /dev/data_vg/web_lv /var/www

# Mở rộng LV (khi đầy)
root@server:~# lvextend -L +10G /dev/data_vg/web_lv
root@server:~# resize2fs /dev/data_vg/web_lv  # Mở rộng filesystem (ext4)

# Tạo snapshot LVM (backup)
root@server:~# lvcreate -s -L 5G -n web_snap /dev/data_vg/web_lv
LPIC-2 · Topic 204 · Exam 201
🗄️ Advanced Storage
RAID, mdadm, hardware RAID, storage protocols
📖
Software RAID với mdadm
RAID LevelMin DisksRedundancyPerformanceUse case
RAID 02KhôngGhi/đọc nhanh 2xCần tốc độ, không quan trọng data
RAID 12N-1 diskĐọc nhanh 2xOS, database quan trọng
RAID 531 diskĐọc nhanhFile servers, NAS
RAID 642 disksChậm hơn RAID5Large storage farms
RAID 10450% disksNhanh nhấtDatabase servers
mdadm – Software RAID
# Tạo RAID 5 với 3 disks
root@server:~# mdadm --create /dev/md0 --level=5 \
  --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
root@server:~# cat /proc/mdstat    # Xem trạng thái RAID
md0 : active raid5 sdd[2] sdc[1] sdb[0]
      20953088 blocks super 1.2 level 5, 512k chunk
      [====>................]  resync = 22% finish=3.4min

root@server:~# mdadm --detail /dev/md0
root@server:~# mdadm /dev/md0 --fail /dev/sdc  # Simulate disk failure
root@server:~# mdadm /dev/md0 --remove /dev/sdc
root@server:~# mdadm /dev/md0 --add /dev/sde   # Hot-add new disk
LPIC-2 · Topic 205 · Exam 201
🌐 Advanced Networking
Network troubleshooting, packet analysis, VPN basics
📖
Network Troubleshooting Tools
Advanced network tools
# tcpdump – capture packets
root@server:~# tcpdump -i eth0 port 80 -w capture.pcap
root@server:~# tcpdump -r capture.pcap -A | head -50
root@server:~# tcpdump host 10.0.0.1 and port 443

# netstat/ss – socket statistics
root@server:~# ss -tuanp    # All sockets với process info
root@server:~# ss -s         # Summary statistics

# iptraf, iftop – bandwidth monitoring
root@server:~# iftop -i eth0

# Network bonding/teaming
root@server:~# cat /proc/net/bonding/bond0
# Bonding modes: 0=balance-rr, 1=active-backup, 4=802.3ad(LACP)
LPIC-2 · Topic 206 · Exam 202
📧 Mail Server
Postfix, Dovecot, SMTP/IMAP/POP3, spam filtering
📖
Postfix Mail Server
Postfix configuration
# /etc/postfix/main.cf – cấu hình chính
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, $mydomain
mynetworks = 127.0.0.0/8 192.168.1.0/24
relay_domains = example.com

# Khởi động và kiểm tra
root@server:~# systemctl start postfix
root@server:~# postfix check         # Kiểm tra config
root@server:~# postfix status

# Test gửi mail
root@server:~# echo "Test email" | mail -s "Test" admin@example.com
root@server:~# tail -f /var/log/mail.log  # Theo dõi mail log

# Queue management
root@server:~# mailq              # Xem hàng đợi
root@server:~# postqueue -f       # Flush queue
root@server:~# postsuper -d ALL   # Xóa toàn bộ queue
LPIC-2 · Topic 207 · Exam 202
🌍 DNS Server (BIND)
BIND9, zone files, DNS records, DNSSEC basics
📖
BIND9 DNS Server
BIND9 zone configuration
# /etc/bind/named.conf.local
zone "example.com" {
    type master;
    file "/etc/bind/db.example.com";
};

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192.168.1";
};

# Zone file /etc/bind/db.example.com
$TTL    86400
@   IN  SOA ns1.example.com. admin.example.com. (
                2024011501 ; Serial (YYYYMMDDNN)
                3600       ; Refresh
                1800       ; Retry
                604800     ; Expire
                86400 )    ; Negative TTL

; Name servers
@       IN  NS  ns1.example.com.
@       IN  NS  ns2.example.com.

; A records
@       IN  A   203.0.113.10
ns1     IN  A   203.0.113.10
ns2     IN  A   203.0.113.11
www     IN  A   203.0.113.20
mail    IN  A   203.0.113.30

; MX record
@       IN  MX  10  mail.example.com.

; CNAME
ftp     IN  CNAME   www.example.com.

# Kiểm tra và reload
root@server:~# named-checkconf
root@server:~# named-checkzone example.com /etc/bind/db.example.com
root@server:~# rndc reload
root@server:~# dig @localhost example.com A
LPIC-2 · Topic 208 · Exam 202
🌐 Web Services
Apache2, Nginx, SSL/TLS, virtual hosts, proxies
📖
Apache & Nginx
Virtual Hosts & SSL
# Apache2 Virtual Host (/etc/apache2/sites-available/example.conf)
<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example

    SSLEngine on
    SSLCertificateFile      /etc/ssl/certs/example.crt
    SSLCertificateKeyFile   /etc/ssl/private/example.key

    <Directory /var/www/example>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog  ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/example_access.log combined
</VirtualHost>

# Enable site
root@server:~# a2ensite example.conf
root@server:~# a2enmod ssl rewrite headers
root@server:~# apache2ctl configtest
root@server:~# systemctl reload apache2

# Nginx Virtual Host (/etc/nginx/sites-available/example)
server {
    listen 443 ssl http2;
    server_name example.com www.example.com;
    root /var/www/example;

    ssl_certificate     /etc/ssl/certs/example.crt;
    ssl_certificate_key /etc/ssl/private/example.key;
    ssl_protocols TLSv1.2 TLSv1.3;

    location / {
        try_files $uri $uri/ =404;
    }

    location /api {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

root@server:~# nginx -t && systemctl reload nginx
LPIC-2 · Topic 209 · Exam 202
📂 File Sharing
Samba (Windows shares), NFS (Linux/Unix shares)
📖
Samba & NFS
Samba & NFS configuration
# SAMBA /etc/samba/smb.conf
[global]
    workgroup = COMPANY
    server string = Linux File Server
    security = user

[shared]
    comment = Shared Files
    path = /srv/samba/shared
    valid users = @staff
    read only = no
    create mask = 0664
    directory mask = 0775

root@server:~# smbpasswd -a john    # Thêm Samba user
root@server:~# testparm             # Validate config
root@server:~# systemctl restart smbd nmbd

# NFS Server – /etc/exports
/srv/nfs/data   192.168.1.0/24(rw,sync,no_subtree_check)
/srv/nfs/backup 10.0.0.0/8(ro,sync)

root@server:~# exportfs -ra         # Reload exports
root@server:~# showmount -e localhost

# NFS Client – mount
root@client:~# mount server:/srv/nfs/data /mnt/data
# hoặc trong /etc/fstab:
server:/srv/nfs/data  /mnt/data  nfs  defaults,_netdev  0 0
LPIC-2 · Topic 210 · Exam 202
🔒 Network Security Nâng Cao
OpenVPN, fail2ban, IDS/IPS, hardening
📖
Security Hardening
fail2ban & system hardening
# fail2ban – tự động ban IP brute-force
# /etc/fail2ban/jail.local
[DEFAULT]
bantime  = 3600        # Ban 1 giờ
findtime = 600         # Trong 10 phút
maxretry = 5           # Nếu fail 5 lần

[sshd]
enabled = true
port    = ssh
logpath = %(sshd_log)s

[nginx-http-auth]
enabled  = true
filter   = nginx-http-auth
logpath  = /var/log/nginx/error.log

root@server:~# fail2ban-client status
Status
|- Number of jail:      2
`- Jail list:   nginx-http-auth, sshd
root@server:~# fail2ban-client status sshd
root@server:~# fail2ban-client set sshd unbanip 1.2.3.4

# System hardening checklist
root@server:~# lynis audit system   # Security audit tool
root@server:~# chkrootkit           # Check rootkits
root@server:~# rkhunter --check     # Rootkit hunter

# Disable unused services
root@server:~# systemctl list-units --type=service --state=running
root@server:~# systemctl disable bluetooth cups avahi-daemon

# OpenSSH hardening (/etc/ssh/sshd_config)
Protocol 2
PermitRootLogin no
MaxAuthTries 3
PubkeyAuthentication yes
PasswordAuthentication no
X11Forwarding no
AllowTcpForwarding no
ClientAliveInterval 300
ClientAliveCountMax 2
Checklist bảo mật server production: Disable root SSH, dùng key-based auth, enable firewall, cài fail2ban, cập nhật hệ thống thường xuyên, monitor log, chạy lynis định kỳ.

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master