AlmaLinux Command Cheat Sheet
This cheat sheet collects the most commonly used commands for day-to-day operations on AlmaLinux 9 / 10, organized by function. Unless otherwise noted, most commands require root privileges or should be prefixed with sudo.
Package Management (DNF)
| Operation | Command |
|---|---|
| Search for a package | dnf search <keyword> |
| Install a package | dnf install <package> |
| Remove a package | dnf remove <package> |
| Upgrade all installed packages | dnf upgrade |
| Check for available updates only | dnf check-update |
| Find the package providing a file/capability | dnf provides <file path or capability> |
| List enabled repositories | dnf repolist |
| List all repositories (including disabled) | dnf repolist --all |
| Clean the cache | dnf clean all |
| Rebuild the metadata cache | dnf makecache |
| View transaction history | dnf history |
| Roll back a specific transaction | dnf history undo <ID> |
| List module streams | dnf module list |
| Enable and install a module stream | dnf module install <module>:<stream> |
| List package groups | dnf group list |
| Install a package group | dnf group install "<group name>" |
| View package information | dnf info <package> |
| List a package's dependencies | dnf repoquery --requires <package> |
Service Management (systemctl)
| Operation | Command |
|---|---|
| Start a service | systemctl start <service> |
| Stop a service | systemctl stop <service> |
| Restart a service | systemctl restart <service> |
| Reload configuration (without interruption) | systemctl reload <service> |
| View service status | systemctl status <service> |
| Enable a service at boot | systemctl enable <service> |
| Disable a service at boot | systemctl disable <service> |
| Enable and start immediately | systemctl enable --now <service> |
| List running units | systemctl list-units |
| List all service units | systemctl list-units --type=service |
| Check whether a service is running | systemctl is-active <service> |
| Check whether a service starts at boot | systemctl is-enabled <service> |
| Reload the systemd configuration | systemctl daemon-reload |
Viewing Logs (journalctl)
| Operation | Command |
|---|---|
| View logs for a specific service | journalctl -u <service> |
| Follow logs in real time | journalctl -f |
| Follow logs for a specific service | journalctl -u <service> -f |
| Filter by priority (e.g. errors) | journalctl -p err |
| View logs after a given time | journalctl --since "2026-06-01 08:00:00" |
| View logs since the current boot | journalctl -b |
| View logs from the previous boot | journalctl -b -1 |
| View disk space used by logs | journalctl --disk-usage |
| Clean logs by size | journalctl --vacuum-size=500M |
| Clean logs by time | journalctl --vacuum-time=2weeks |
Firewall (firewalld)
| Operation | Command |
|---|---|
| View firewall running state | firewall-cmd --state |
| View all rules in the current zone | firewall-cmd --list-all |
| Permanently allow a service | firewall-cmd --permanent --add-service=http |
| Permanently allow a port | firewall-cmd --permanent --add-port=8080/tcp |
| Reload rules to apply permanent config | firewall-cmd --reload |
| View the default zone | firewall-cmd --get-default-zone |
| List all zones | firewall-cmd --get-zones |
| Bind an interface to a zone | firewall-cmd --permanent --zone=public --change-interface=eth0 |
| Add a rich rule | firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="ssh" accept' |
SELinux
| Operation | Command |
|---|---|
| View the current mode | getenforce |
| Temporarily switch to permissive mode | setenforce 0 |
| Temporarily switch to enforcing mode | setenforce 1 |
| View detailed SELinux status | sestatus |
| Restore a file's default context | restorecon -Rv <path> |
| Permanently set a boolean | setsebool -P httpd_can_network_connect on |
| Add a type label to a port | semanage port -a -t http_port_t -p tcp 8080 |
| View SELinux denial records | ausearch -m avc -ts recent |
| Analyze denials and get suggestions | sealert -a /var/log/audit/audit.log |
Networking (NetworkManager)
| Operation | Command |
|---|---|
| List connection profiles | nmcli con show |
| List network devices | nmcli dev status |
| Bring up a connection | nmcli con up <connection> |
| Set a static IP | nmcli con mod <connection> ipv4.addresses 192.168.1.10/24 ipv4.method manual |
| Set DNS | nmcli con mod <connection> ipv4.dns "8.8.8.8 1.1.1.1" |
| View IP addresses | ip addr |
| View the routing table | ip route |
| View listening ports (ss recommended) | ss -tulpn |
Users and Permissions
| Operation | Command |
|---|---|
| Create a user | useradd <username> |
| Set/change a password | passwd <username> |
| Add a user to a supplementary group | usermod -aG wheel <username> |
| View/change password aging | chage -l <username> |
| Safely edit sudoers | visudo |
| Change file permissions | chmod 640 <file> |
| Change file owner and group | chown user:group <file> |
| View ACL permissions | getfacl <file> |
| Set ACL permissions | setfacl -m u:user:rw <file> |
Storage Management
| Operation | Command |
|---|---|
| View the block device tree | lsblk |
| View partition UUID/filesystem | blkid |
| View disk usage (with type) | df -hT |
| View directory usage | du -sh <directory> |
| Mount a filesystem | mount /dev/sdb1 /mnt |
| Make a mount persistent | Edit /etc/fstab |
| Extend a logical volume | lvextend -L +10G /dev/vg0/lv0 |
| Grow an XFS filesystem online | xfs_growfs / |
| Grow an ext4 filesystem online | resize2fs /dev/vg0/lv0 |
Processes and Performance
| Operation | Command |
|---|---|
| View all processes | ps aux |
| Monitor processes in real time | top |
| Enhanced interactive monitoring | htop |
| View memory usage | free -h |
| View system load and uptime | uptime |
| View resource usage by cgroup | systemd-cgtop |
| View resources for a specific process | ps -p <PID> -o %cpu,%mem,cmd |
System Information
| Operation | Command |
|---|---|
| View hostname and system info | hostnamectl |
| Set the timezone | timedatectl set-timezone Asia/Shanghai |
| View the AlmaLinux version | cat /etc/almalinux-release |
| View the kernel version | uname -r |
| View the DNF version | dnf --version |
| View CPU information | lscpu |
| View time and timezone status | timedatectl |
Further Reading
- Firewall Configuration and Management: a detailed walkthrough of firewalld zones, rich rules, and port forwarding.
- Server Security Hardening: a complete practice guide for SELinux, SSH, account, and system hardening.
