Sobes.tech
Junior

How to view the list of running processes in Linux?

sobes.tech AI

Answer from AI

There are several main methods:

  • Using the ps command: Allows viewing current processes.

    // Show all processes for all users in BSD format
    ps aux
    
    // Show processes in a tree format
    ps axjf
    
    // Show only processes of the current user in a readable format
    ps -ef
    

    Common fields:

    Field Description
    UID User identifier
    PID Process identifier
    PPID Parent process identifier
    TTY Terminal associated with the process
    CMD Command that started the process
  • Using the top command: An interactive tool that displays processes in real-time, sorted by CPU usage (default).

    // Run top
    top
    
    // Run top with updates every 2 seconds
    top -d 2
    
  • Using the htop command: An improved version of top with a more user-friendly interface and additional features (requires installation).

    // Run htop
    htop
    

The choice of command depends on the required information and user preferences. For quick static viewing, ps is often used; for interactive real-time monitoring, top or htop are preferred.