I present to you a compilation of the most useful Linux commands for System Information and Monitoring
General Information
Clear terminal screen
Clears the terminal screen, just like the shortcut Control + L
.
clear
Reset terminal session
Resets the current terminal session.
reset
End terminal session
Closes the local or remote (SSH) terminal session and terminates initiated processes.
exit
Resource Management
Show running tasks
Displays a list of running tasks and their resource usage.
top
Show tasks with enhanced resources
Displays more detailed and visual information about running tasks.
htop
RAM status
Displays the status of RAM in megabytes.
free -h
Disk Space
List mounted partitions
Displays a list of the partitions mounted on the system.
df -h
View partition information on the system
Displays information about the partitions and their usage.
lsblk
Size of files and directories
Displays the size of files and directories sorted by size.
ls -lSr | more
Space used by a directory
Estimates the space used by the directory dir1
.
du -sh directory
Size sorted of files and directories
Displays the size of files and directories sorted by size.
du -sk * | sort -rn
System Information
Data of connected users
Displays information about users connected to the system.
who -a
View CPU usage details
Displays CPU usage details for each core.
mpstat -P ALL
Reboot history
Displays the system’s reboot history.
last reboot
System architecture and version
Displays the architecture and version of Linux and the kernel.
uname -a
Loaded kernel
Displays the currently loaded kernel.
lsmod
System hardware components
Displays information about the system hardware.
dmidecode -q
List hard drive partitions
Displays the partitions configured on the system.
cat /etc/fstab
Hard drive features
Displays specific features of the hard drive.
hdparm -i /dev/hda
Show PCI devices
Displays a list of connected PCI devices.
lspci
Show USB devices
Lists the USB devices connected to the system.
lsusb
Kernel loading process events
Displays events during the kernel loading.
tail /var/log/dmesg
System events
Displays logged system events.
tail /var/log/messages
Open files by processes
Displays the list of open files by the current process.
lsof -p $$
Open files in a directory
Displays open files in a specific directory.
lsof /directory
System calls
Displays the system calls made by a process.
strace -c ls >/dev/null
Library calls
Displays the library calls of a specific process.
strace -f -e open ls >/dev/null
Real-time interrupts
Displays system interrupts in real time.
watch -n1 'cat /proc/interrupts'
System Shutdown and Restart
Log out user
Ends the current user’s session.
logout
Shut down the system
Shuts down the system immediately.
shutdown now
Restart the system
Restarts the system immediately.
shutdown -r now
Scheduled shutdown
Schedules a shutdown for a specific hour and minute.
shutdown hours:minutes &
Cancel scheduled shutdown
Cancels a scheduled shutdown.
shutdown -c
Dates
Show system date
Displays the current system date.
date
Year calendar
Displays the calendar for a specific year.
cal year
Month and year calendar
Displays the calendar for a specific month and year.
cal month year