6 Important Linux Commands For DevOps

6 Important Linux Commands For DevOps

1. top command

The top (table of processes) command shows a real-time view of running processes in Linux and displays kernel-managed tasks. The command also provides a system information summary that shows resource utilization, including CPU and memory usage.

No alt text provided for this image
phoenixnap.com


Here are the features that top command displays on its terminal,

  • PID: Shows task’s unique process id.
  • PR: The process’s priority. The lower the number, the higher the priority.
  • VIRT: Total virtual memory used by the task.
  • USER: User name of owner of task.
  • %CPU: Represents the CPU usage.
  • TIME+: CPU Time, the same as ‘TIME’, but reflecting more granularity through hundredths of a second.
  • SHR: Represents the Shared Memory size (kb) used by a task.
  • NI: Represents a Nice Value of task. A Negative nice value implies higher priority, and positive nice value means lower priority.
  • %MEM: Shows the Memory usage of task.
  • RES: How much physical RAM the process is using, measured in kilobytes.
  • COMMAND: The name of the command that started the process.

2. free command

The Linux free command outputs a summary of RAM usage, including total, used, free, shared, and available memory and swap space. The command helps monitor resource usage and allows an admin to determine if there's enough room for running new programs.

No alt text provided for this image
pheonixnap.com

The free command takes the following syntax:

$ free [options]

  • Column: Description
  • total: Total RAM amount available on the system.
  • used: Memory currently in use by processes.
  • free: Unused memory, free.
  • shared: Memory shared by multiple processes.
  • buff/cache: Memory in use by the kernel (for buffers, page cache, and slabs).
  • available: Estimated memory amount available for starting new applications, excluding swap

3. vmstat command

The vmstat command (short for virtual memory statistics) is a built-in monitoring utility in Linux. The command is used to obtain information about memory, system processes, paging, interrupts, block I/O, disk, and CPU scheduling. Users can observe system activity virtually in real-time by specifying a sampling period. All these functionalities makes the command vmstat also known as virtual memory statistic reporter.

The command helps you identify performance bottlenecks and diagnose problems in your system.

No alt text provided for this image
pheonixnap.com

Important fields are ‘free’ under memory and ‘si’, ‘so’ under the swap column. 

  • Free: It specifies the amount of free memory/idle memory spaces which are not being used.
  • si: Memory that is swapped in every second from disk in kilobytes.
  • so: Memory that is swapped out every second to disk in kilobytes.
  • In the given figure we can see the process, memory, swap in memory, swap out memory, io, system, and cpu update. 


4. iostat command

The iostat command in Linux is used for monitoring system input/output statistics for devices and partitions. It monitors system input/output by observing the time the devices are active in relation to their average transfer rates.

No alt text provided for this image
pheonixnap.com

The first section contains CPU report: 

  • %user : It shows the percentage of CPU being utilization that while executing at the user level.
  • %nice : It shows the percentage of CPU utilization that occurred while executing at the user level with a nice priority.
  • %system : It shows the percentage of CPU utilization that occurred while executing at the system (kernel) level.
  • %iowait : It shows the percentage of the time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
  • %steal : It shows the percentage of time being spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing by another virtual processor.
  • %idle : It shows the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

The second section of the output contains device utilization report: 

  • Device : The device/partition name is listed in /dev directory.
  • tps : The number of transfers per second that were issued to the device. Higher tps means the processor is busier.
  • Blk_read/s : It shows the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second.
  • Blk_wrtn/s : The amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second.
  • Blk_read : It shows the total number of blocks read.
  • Blk_wrtn : It shows the total number of blocks written.

5. lsof command

The lsof command stands for LiSt Open Files and provides a list of files that are opened. Basically, it gives the information to find out the files which are opened by which process. With one go it lists out all open files in output console.

No alt text provided for this image
geeksforgeeks.org

Here, you observe there are details of files which are opened. Process Id, the user associated with the process, FD(file descriptor), size of the file all together gives detailed information about the file opened by the command, process ID, user, its size etc. 

  • FD represents as File descriptor.
  • cwd : Current working directory.
  • txt : Text file.
  • mem : Memory file.
  • mmap : Memory mapped device.

6. fdisk command

fdisk also known as format disk is a dialog-driven command in Linux used for creating and manipulating disk partition table. It is used for the view, create, delete, change, resize, copy and move partitions on a hard drive using the dialog-driven interface. 

No alt text provided for this image
geeksforgeek.org

fdisk allows you to create a maximum of four primary partitions and the number of logical partition depends on the size of the hard disk you are using. It allows the user: 

  • To Create space for new partitions.
  • Organizing space for new drives.
  • Re-organizing old drives.
  • Copying or Moving data to new disks(partitions).


Credit:

geeksforgeeks.org

phoenixnap.com

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics