This page introduces commands for checking disk space, memory usage, and monitoring running processes.
21. df - Report File System Disk Space Usage
Purpose: The df command (disk free) displays the amount of available and used disk space on file systems.
Syntax: df [OPTIONS] [FILE...]
Key Options:
-h: (human-readable) Displays sizes in powers of 1024 (e.g., G for GB, M for MB).-T: (type) Shows the file system type.
Examples:
df -h df -hT /dev/sda1
22. du - Estimate File Space Usage
Purpose: The du command (disk usage) estimates file space usage. It's useful for finding out how much space a specific file or directory (and its contents) is consuming.
Syntax: du [OPTIONS] [FILE...]
Key Options:
-h: (human-readable) Displays sizes in human-readable format.-s: (summarize) Displays only a total for each argument.-c: (total) Displays a grand total.
Examples:
du -h my_folder/ du -sh /var/log/ du -ch images/ videos/
23. free - Display Amount of Free and Used Memory
Purpose: The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel.
Syntax: free [OPTIONS]
Key Options:
-h: (human-readable) Displays output in a human-readable format (e.g., G for GB, M for MB).-t: (total) Displays a line showing the total of RAM and swap.
Examples:
free -h free -ht
24. top - Display Linux Processes
Purpose: The top command provides a dynamic, real-time view of running processes. It shows CPU usage, memory usage, swap space, and information about individual processes.
Syntax: top
Key Interactions (within top):
q: Quittop.k: Kill a process (prompts for PID).r: Renice a process (change priority).M: Sort by memory usage.P: Sort by CPU usage.
Example:
top
This command opens an interactive, updating display.
25. ps - Report a Snapshot of Current Processes
Purpose: The ps command (process status) displays information about currently running processes. Unlike top, it provides a static snapshot at the moment the command is run.
Syntax: ps [OPTIONS]
Key Options:
aux: Shows all processes for all users, including those not attached to a terminal. (Commonly used combination)-e: Selects all processes.-f: Full-format listing.
Examples:
ps aux ps -ef | grep firefox