RHEL frequently used commands

Disk usage
# Disk usage
du -sh /var/log/
# Example output
422M	/var/log/
# Options
-s, --summarize 
-h , --human-readable
-a, --all
--time
Memory usage
# Memory usage
$ free -g

# Example output
              total        used        free      shared  buff/cache   available
Mem:             46           1          43           0           1          44
Swap:            11           0          11
List installed packages
# List installed packages
$ dnf list installed
OR
$ yum list installed
List installed linux version
# List installed linux version
$ cat /etc/os-release
OR
$ lsb_release -a
OR 
$ hostnamectl
List all opened ports
firewall-cmd --list-all
Check user must change passwords
# 
$ chage -l user

# Example output
Last password change					: Feb 27, 2023
Password expires					: Apr 28, 2023
Password inactive					: Jun 02, 2023
Account expires						: never
Minimum number of days between password change		: 7
Maximum number of days between password change		: 60
Number of days of warning before password expires	: 7


# change account password never inactive
$ chage -I -1 user
Check files in specific folder contains certain text pattern
grep -rnw '/path/to/somewhere/' -e 'pattern'
Reference
Scroll to Top