How To Manage List Processes In Linux ?

Question

How To Manage List Processes In Linux ?

solved 0
admin 2 years 2022-12-23T18:23:07+00:00 1 Answer 274 views 1

Answer ( 1 )

    0
    2022-12-23T18:32:38+00:00

    [ ps  ] and [ top ] are the common cmd in lunix to manager processes

    ps  (Process Statuses)

    $ ps a: lists all processes on all shells of your server

    $ ps u [username] OR $ ps ef | grep USERNAME: if you want to list processes on Linux for a specific user from a different shell

    $ ps u: adds other useful information, such as virtual memory size (VSZ), resident set size (RSS) and process identification number (PID)

    $ ps x: identifies processes that usually run in the background and were started at boot time, because they have no controlling terminal

    Commands (not just ps commands) are case sensitive. Check out the following commands that are the same in make-up, but will list different processes on Linux.

    $ ps ef: will produce processes that include the command that called up the process, PID, User Identification Number (UID), parent process identification number (PPID), and some information about start and run times.

    $ ps eF: in addition to the information above, using a capital ‘F’ will also produce RSS, the name of the processor running the process and the overall size of the process (SZ).

    Perhaps the linear format is not effective. Change the format to a tree-based one with pstree.

     

    How to use the ‘top’ command

    Top commands are ideal if your goal is to list processes on Linux to identify which ones are using up the most resources. It is this fact that adds a dynamic element to top commands because the list is adjusted according to the demands of your processes.

    To list processes using top, the command is $ top.

     

    Ranking Priority

    You can choose whether to list processes according to how much CPU or memory is being used per process.

    Shift + m: list according to memory use

    Shift + p: list according to CPU use (default)

    Ctrl + C OR q: exists top

    Process States

    1. Running/Runnable (R): the former is currently active, but the latter is awaiting a slot so it can begin performing its process
    2. Sleeping (D): awaiting another process (an event) or resource to continue its process. There are two types of Interruptible Sleep (S) and Uninterruptible Sleep (D)
    3. Stopped (T): a paused process that is awaiting prompt to either continue (SIGCONT) or officially stop (SIGKILL)
    4. Zombie (Z): awaiting action from the parent process to officially complete process

    top Processes

    $ top u [username]: lists processes for a specific user

    $ top p [PID]: lists the processes for a specific PID

    $ top i: will not list processes in zombie state

    Listing some processes in Linux can be brought about by pressing just one key (remember these are case sensitive):

    k: kills process (you will need its PID)

    c: reveals the full path of a program (by default this is not the case); pressing c will return you to default if in full path view

    d: changes refresh time (default refresh time is three seconds)

    r: changes the priority of a process (nice values that are negative get a higher priority than positive numbers; all processes begin with a value of 0)

    R: reverses the default list order (changes from descending to ascending order)

    N: sorts by PID

     

    Variations of top

    A popular version of ‘top’ is htop. While top is installed by default, you will need to install htop should you wish to use it. It allows you to interact with the interface and can be personalized or manipulated to get different colors.

    On the whole, it comes with the same functionality as top but uses the function keys to bring about results. First, installing it is as simple as entering a line of code in a command prompt:

    sudo apt-get install htop

    Now that it is installed, here are some of the actions you can carry out using function keys:

    F9: kills highlighted process

    F5: changes display to tree mode

    F3: allows for searching for a process

    “ntop” is another variation geared towards a different target audience. It shows network usage instead of process usage, so both can work in tandem. Because it is web-based, a browser is needed to access its terminal. There is some configuring that is required before it can be used successfully as well.

    References:

    https://monsterhost.com/manage-running-list-processes-in-linux/

    Best answer

Leave an answer