Skip to content

Latest commit

 

History

History
148 lines (116 loc) · 2.82 KB

File metadata and controls

148 lines (116 loc) · 2.82 KB

Memory Management and System Performance Commands

1. Memory Management Commands

  1. Free Command:
    • free -h: Display memory usage in human-readable format (KB, MB, GB).

      free -h
    • free -g: Display memory usage in gigabytes.

      free -g
    • free -m: Display memory usage in megabytes.

      free -m
    • free -k: Display memory usage in kilobytes.

      free -k

2. System Performance Commands

  1. Vmstat Command:

    • vmstat: Display basic system performance stats (memory, CPU, processes, etc.).

      vmstat
    • vmstat -a: Show active memory and swap usage.

      vmstat -a
    • vmstat -d: Display disk statistics.

      vmstat -d
    • vmstat -s: Display summary of memory, swap, and disk statistics.

      vmstat -s
    • vmstat 4 5: Display performance stats every 4 seconds for 5 iterations.

      vmstat 4 5
    • vmstat -s m 4 5: Display memory statistics every 4 seconds for 5 iterations.

      vmstat -s m 4 5
  2. Iostat Command:

    • iostat: Display input/output statistics for devices and partitions.

      iostat
    • Install iostat if not installed:

      yum install sysstat
    • iostat 4 5: Display I/O statistics every 4 seconds for 5 iterations.

      iostat 4 5

  1. Listing Open Files with lsof

    • Install lsof Command (if not installed):

      yum install lsof
    • To list open files by the user root:

      lsof -u root
    • To list network files (all types of network connections):

      lsof -N -i
    • To list open UDP network connections:

      lsof -n -i UDP
    • To list open TCP network connections:

      lsof -n -i TCP
    • To list open TCP port 22 (usually SSH):

      lsof -n -i TCP:22
    • To list open UDP ports 22, 443, and 90:

      lsof -n -i UDP:22,443,90
    • To list open UDP ports in the range 80-220:

      lsof -n -i UDP:80-220
    • To list open files for process ID 6029:

      lsof -n -p 6029
    • To list open IPv4 network connections:

      lsof -n -i 4
    • To list open IPv6 network connections:

      lsof -n -i 6
    • To get process IDs (PIDs) of files opened by the user Armour:

      lsof -t -u Armour

3. Killing Processes Using kill

  • To kill processes opened by the user Armour using the process IDs (PIDs) retrieved from lsof:
    kill -9 $(lsof -t -u Armour)