What to Read to Undertand How to Use the Terminal

Linux List Processes – How to Check Running Processes

Every day, developers use various applications and run commands in the last. These applications tin include a browser, code editor, terminal, video conferencing app, or music player.

For each of these software applications that you open or commands you run, it creates a process or task.

One cute characteristic of the Linux operating arrangement and of modern computers in general is that they provide back up for multitasking. So multiple programs can run at the aforementioned time.

Have you ever wondered how you can bank check all the programs running on your car? Then this article is for yous, as I'll testify you how to list, manage, and kill all the running processes on your Linux machine.

Prerequisites

  • A Linux distro installed.
  • Bones knowledge of navigating around the control-line.
  • A grinning on your confront :)

A Quick Introduction to Linux Processes

A process is an instance of a running estimator program that you can find in a software application or command.

For instance, if yous open your Visual Studio Code editor, that creates a process which will but stop (or dice) in one case you lot terminate or shut the Visual Studio Lawmaking application.

Likewise, when you run a command in the final (like curl ifconfig.me), it creates a process that will just stop when the command finishes executing or is terminated.

How to Listing Running Processes in Linux using the ps Command

You lot tin can listing running processes using the ps command (ps ways process status). The ps command displays your currently running processes in real-time.

To test this, just open your terminal and run the ps control like so:

Screenshot-2021-06-28-at-3.25.33-PM

This will display the procedure for the current vanquish with four columns:

  • PID returns the unique process ID
  • TTY returns the concluding type y'all're logged into
  • Fourth dimension returns the total amount of CPU usage
  • CMD returns the proper noun of the control that launched the process.

Y'all tin can cull to display a certain ready of processes past using any combination of options (like -A -a, -C, -c, -d, -Eastward, -due east, -u, -X, -x, and others).

If y'all specify more than than 1 of these options, then all processes which are matched by at least i of the given options will be displayed.

Screenshot-2021-06-28-at-3.55.10-PM
The ps control manual folio.
Type man ps in your terminal to read the manual for the ps command, which has a consummate reference for all options and their uses.

To display all running processes for all users on your motorcar, including their usernames, and to bear witness processes not attached to your terminal, yous can employ the command beneath:

                ps aux              

Here'due south a breakdown of the command:

  • ps: is the process status command.
  • a: displays data about other users' processes besides every bit your own.
  • u: displays the processes belonging to the specified usernames.
  • x: includes processes that do not accept a controlling terminal.
Screenshot-2021-06-28-at-4.39.05-PM

This will display the process for the current crush with eleven columns:

  • USER returns the username of the user running the process
  • PID returns the unique process ID
  • %CPU returns the percentage of CPU usage
  • %MEM returns the pct memory usage
  • VSV returns the virtual size in Kbytes
  • RSS returns the resident set size
  • TT returns the control final name
  • STAT returns the symbolic process land
  • STARTED returns the time started
  • CMD returns the command that launched the process.

How to List Running Processes in Linux using the meridian and htop Commands

Yous can also use the top task manager command in Linux to run into a real-time sorted list of acme processes that utilize the most memory or CPU.

Type height in your concluding and y'all'll get a issue like the one you see in the screenshot below:

Screenshot-2021-06-28-at-4.27.28-PM
You can blazon q to exit the session.

An alternative to top is htop which provides an interactive system-monitor to view and manage processes. It also displays a real-time sorted listing of processes based on their CPU usage, and yous can easily search, filter, and kill running processes.

htop is not installed on Linux by default, so you need to install it using the control beneath or download the binaries for your preferred Linux distro.

                sudo apt update && sudo apt install htop              

Only type htop in your terminal and you'll go a result similar the i you run across in the screenshot below:

Screenshot-2021-06-29-at-4.49.09-AM

How to Impale Running Processes in Linux

Killing a process means that yous terminate a running application or command. You can impale a process by running the kill command with the process ID or the pkill command with the procedure name like so:

                kill [PID]              

or

                pkill [COMMAND]              

To find the procedure ID of a running procedure, you can use the pgrep command followed by the name of the process like so:

                pgrep iTerm2              

To impale the iTerm2 process in the screenshot higher up, we will apply any of the commands beneath. This will automatically terminate and shut the iTerm2 process (application).

                kill 25781              

or

                kill iTerm2              

Decision

When yous listing running processes, it is usually a long and clustered list. You tin pipage it through less to display the command output ane page at a fourth dimension in your terminal similar then:

                ps aux | less              

or display only a specific procedure that matches a item name like so:

                ps aux | grep Chrome              

I hope that you now sympathize what Linux processes are and how to manage them using the ps, top, and htop commands.

Brand sure to check out the transmission for each command by running man ps, human being summit, or homo htop respectively. The manual includes a comprehensive reference you can check if you need any more help at any point.

Thank you for reading – cheers! 💙



Acquire to code for costless. freeCodeCamp's open source curriculum has helped more than xl,000 people get jobs equally developers. Get started

valentinodiany1971.blogspot.com

Source: https://www.freecodecamp.org/news/linux-list-processes-how-to-check-running-processes/

0 Response to "What to Read to Undertand How to Use the Terminal"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel