Linux offers a wide range of commands to access system details. This cheat sheet helps you quickly check key parameters such as CPU load, available memory, disk status, and other useful details.
Process Monitoring
- top – displays active processes, CPU load, memory usage, and other parameters in real time.
- htop – a more user-friendly version of top with a graphical interface (install separately: sudo apt install htop for Debian/Ubuntu or sudo yum install htop for CentOS/RHEL).
Memory Usage
- free -m – shows available, used, and free RAM in megabytes.
- vmstat 1 – updates CPU, memory, and I/O usage statistics every second.
Disk Information
- df -h – presents disk space utilization for all file systems in an easy-to-read format (including size units like KB, MB, GB).
- du -sh * – provides the total size of each file and directory in the current location (-s restricts output to summary values, -h ensures readability).
- lsblk – displays all connected storage devices along with their partitions.
System Information
- uname -a – outputs comprehensive details about the system and kernel.
- cat /etc/os-release – reveals the installed operating system's version and related details.
- hostnamectl – delivers in-depth system insights, including the hostname and OS distribution version.
System Uptime
- uptime – shows how long the system has been running, the number of users, and average CPU load.
- who -b – displays the date and time of the last system reboot.
User Information
- whoami – prints the username of the currently logged-in user.
- id – provides the current user's UID (User ID) and GID (Group ID).
- w – displays a list of active users along with their session details.
Network Information
- ip a – lists network interfaces and their IP addresses.
- netstat -tulnp – shows listening ports and active connections (if netstat is missing, install net-tools).
- ss -tulnp – a modern alternative to netstat for viewing network connections.
Conclusion
These commands help you quickly retrieve system information in Linux. For convenience, you can create aliases in the .bashrc file, such as:
- alias meminfo='free -m'
- alias diskinfo='df -h'
- alias sysinfo='uname -a'
Now, simply type meminfo, diskinfo, or sysinfo to get the necessary data faster!