- How to List Running Processes in Linux: A Beginner’s Guide
- Introduction to Linux Processes
- How to List Running Processes in Linux?
- Utilizing the “ps” Command
- Using the “top” Command
- Running “htop” Command
- Conclusion
- task(1) — Linux man page
- Synopsis
- Description
- Subcommands
- Modifying Subcommands
- Report Subcommands
- Filters
- Attributes and Metadata
- Attribute Modifiers
- Specifying Dates and Frequencies
- Dates
- Frequencies
- Command Abbreviation
- Specifying Descriptions
- Configuration File and Override Options
- Examples
- Files
- Credits & Copyrights
- See Also
How to List Running Processes in Linux: A Beginner’s Guide
Need to view all running processes on your Linux server and discover which consumes your resources the most? Look no further, because, in this article, we’ll explain how to list Linux processes by using several common commands.
Introduction to Linux Processes
A process is the execution of a program. They can be launched when opening an application or when issuing a command through the command-line terminal.
A command can only generate a process. However, an application can run multiple processes for different tasks. For instance, Google Chrome will start a different process each time a new tab is opened.
Each Linux process is assigned a unique PID (process identification number). If there are no possible combinations left, the system can reuse old PIDs for newer processes.
A process can be initiated as a foreground or background process.
By default, all commands that run in the shell will start as foreground processes. As the process occupies the shell, you have to wait until it is finished before executing other commands.
If a command takes too long to complete, you can run it as a background process by adding an ampersand (&) at the end of the command so you can use the shell for other tasks.
Occasionally, processes may consume a lot of resources and need to be killed. Alternatively, times when you may want to change the priority level of a process, so the system will allocate more resources to it. Regardless of the case, all these tasks require you to do the same thing: listing the running processes on Linux.
How to List Running Processes in Linux?
There are several commands that you can use to list running processes: ps, top, and htop.
Utilizing the “ps” Command
The ps (process statuses) command produces a snapshot of all running processes. Therefore, unlike the Windows task manager, the results are static.
When this command is used without any additional argument or option, it will return a list of running processes along with four crucial columns: the PID, terminal name (TTY), running time (TIME), and the name of the command that launches the process (CMD). You can use ps aux to get more in-depth information about your running processes. Here’s a breakdown of each argument:
- a option outputs all running processes of all users in the system.
- u option provides additional information like memory and CPU usage percentage, the process state code, and the owner of the processes.
- x option lists all processes not executed from the terminal. A perfect example of this are daemons, which are system-related processes that run in the background when the system is booted up.
If you want to list Linux processes in a hierarchical view, use the ps -axjf command. In this format, the shell will put child processes under their parent processes.
Aside from those two options, here are some other common examples of the ps command that list running processes in Linux:
- ps -u [username] lists all running processes of a certain user.
- ps -e or ps -A displays active Linux processes in the generic UNIX format.
- ps -T prints active processes that are executed from the terminal.
- Ps -C process_name will filter the list by the process name. In addition, this command also shows all child processes of the specified process.
Using the “top” Command
The top command is used to discover resource-hungry processes. This Linux command will sort the list by CPU usage, so the process which consumes the most resources will be placed at the top.
Unlike the ps command, the output of the top command is updated periodically. That means you’ll see real-time updates for CPU usage and running time. Once the shell returns the list, you can press the following keys to interact with it:
Keys | Functions |
k | Kills a process |
M | Sorts the list by memory usage. |
N | Sorts the list by PID. |
r | Changes the priority of a process. |
h | Displays the help window. |
z | Displays running processes in colors. |
d | Changes the refresh time interval. |
c | Displays the absolute path of a process. |
CTRL+C or q | Stops the top command. |
Keep in mind that the keys above are case sensitive, so be sure not to enable the caps lock.
Running “htop” Command
Both the htop and top command display the same information when listing your Linux processes, but the former offers user-friendly features that are great for everyday process management.
First thing first, the htop command allows you to scroll vertically and horizontally. As such, you can see the complete list of your Linux processes along with their full command lines.
What’s more, the command allows you to use a mouse to select items, kill processes without inserting their PIDs, change the priority of multiple processes easily, and so on.
Unfortunately, most Linux distributions don’t have this command right out of the box, so you need to install it manually.
If you use Ubuntu, you can install htop by running the following command:
Once installed, type htop, and you’ll get a list of all your Linux processes. Just like the previous command, htop also has several keyboard shortcuts:
Keys | Functions |
F9 | To kill a process. |
F8 | Increase the priority of a process. |
F7 | Decrease the priority of a process. |
F6 | Sort processes by any column. |
F5 | Display processes in a tree view. |
F4 | Filter the processes by name. |
F3 | Search for a process. |
F2 | Open htop setup. |
F1 | Display the help menu. |
Conclusion
It is important to know how to list all running processes in your Linux operating system. The knowledge will be useful when you need to manage processes.
Let’s take a look once more at the three commands that you can use to list Linux processes:
- ps command — outputs a static view of all processes.
- top command — displays the real-time list of all running processes.
- htop command — shows the real-time result and is equipped with user-friendly features.
Which command do you prefer? Share your thoughts in the comment section below!
Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.
Источник
task(1) — Linux man page
Synopsis
Description
At the core, taskwarrior is a list processing program. You add text and additional related parameters and redisplay the information in a nice way. It turns into a todo list program when you add due dates and recurrence. It turns into an organized todo list program when you add priorities, tags (one word descriptors), project groups, etc. Taskwarrior turns into an organized to do list program when you modify the configuration file to have the output displayed the way you want to see it.
Subcommands
You can set aliases for frequently used URLs in the .taskrc. push URL Pushes the task database to a remote another location for distributing the changes made by the merge command.
(See annotations above for valid URL syntaxes.) pull URL Overwrites the task database with those files found at the URL.
(See annotations above for valid URL syntaxes.) color [sample | legend] Displays all possible colors, a named sample, or a legend containing all currently defined colors. count [filter] Displays only a count of tasks matching the filter. version Shows the taskwarrior version number help Shows the long usage text. show [all | substring]» Shows all the current settings in the taskwarrior configuration file. If a substring is specified just the settings containing that substring will be displayed. config [name [value | »]] Add, modify and remove settings directly in the taskwarrior configuration. This command either modifies the ‘name’ setting with a new value of ‘value’, or adds a new entry that is equivalent to ‘name=value’:
task config name value
This command sets a blank value. This has the effect of suppressing any default value:
task config name »
Finally, this command removes any ‘name=. ‘ entry from the .taskrc file:
task config name
Modifying Subcommands
If either ‘from’ or ‘to’ contain spaces, you will need to put quotes around the whole thing. ID /from/to/g Performs all substitutions on task description and annotation for fixing mistakes.
If either ‘from’ or ‘to’ contain spaces, you will need to put quotes around the whole thing. edit ID Launches an editor to let you modify all aspects of a task directly. In general, this is not the recommended method of modifying tasks, but is provided for exceptional circumstances. Use carefully. append [attrs] description Appends information to an existing task. prepend [attrs] description Prepends information to an existing task.
Report Subcommands
A report is a listing of information from the task database. There are several reports currently predefined in taskwarrior. The output and sort behavior of these reports can be configured in the configuration file. See also the man page taskrc(5). active [filter] Shows all tasks matching the filter that are started but not completed. all [filter] Shows all tasks matching the filter, including parents of recurring tasks. completed [filter] Shows all tasks matching the filter that are completed. minimal [filter] Provides a minimal listing of tasks matching the filter. ls [filter] Provides a short listing of tasks matching the filter. list [filter] Provides a more detailed listing of tasks matching the filter. long [filter] Provides the most detailed listing of tasks with filter. newest [filter] Shows the newest tasks with filter. oldest [filter]
Shows the oldest tasks with filter overdue [filter] Shows all incomplete tasks matching the filter that are beyond their due date. recurring [filter] Shows all recurring tasks matching the filter. waiting [filter] Shows all waiting tasks matching the filter. blocked [filter] Shows all blocked tasks, that are dependent on other tasks, matching the filter. unblocked [filter] Shows all tasks that are not blocked by dependencies, matching the filter. next [filter] Shows all tasks with upcoming due dates matching the filter.
Filters
A filter is a set of search criteria that the report applies before displaying the results. For example, to list all tasks belonging to the ‘Home’ project:
task list project:Home
You can specify multiple filters, each of which further restrict the results:
task list project:Home +weekend garden
This example applies three filters: the ‘Home’ project, the ‘weekend’ tag, and the description or annotations must contain the characters ‘garden’. In this example, ‘garden’ is translated internally to:
as a convenient shortcut. The ‘contains’ here is an attribute modifier, which is used to exert more control over the filter than simply absence or presence. See ‘ATTRIBUTE MODIFIERS’ for a complete list of modifiers.
Attributes and Metadata
Certain tags (called ‘special tags’), can be used to affect the way tasks are treated. For example, is a task has the special tag ‘nocolor’, then it is exempt from all color rules. The supported special tags are:
+nocolor Disable color rules processing for this task
+nonag Completion of this task suppresses all nag messages
+nocal This task will not appear on the calendar
project:
Specifies the project to which a task is related to. priority:H|M|L|N Specifies High, Medium, Low and No priority for a task. due: Specifies the due-date of a task. recur: Specifies the frequency of a recurrence of a task. until: Specifies the Recurrence end-date of a task. fg: Specifies foreground color. bg: Specifies background color. limit: Specifies the desired number of tasks a report should show, if a positive integer is given. The value ‘page’ may also be used, and will limit the report output to as many lines of text as will fit on screen. This defaults to 25 lines. wait: Date until task becomes pending. depends: Declares this task to be dependent on id1 and id2. This means that the tasks id1 and id2 should be completed before this task. Consequently, this task will then show up on the ‘blocked’ report.
Attribute Modifiers
before (synonyms under, below)
after (synonyms over, above)
none
any
is (synonym equals)
isnt (synonym not)
has (synonym contains)
hasnt
startswith (synonym left)
endswith (synonym right)
word
noword
task list due.before:eom priority.not:L
The before modifier is used to compare values, preserving semantics, so project.before:B list all projects that begin with ‘A’. Priority ‘L’ is before ‘M’, and due:2011-01-01 is before due:2011-01-02. The synonyms ‘under’ and ‘below’ are included to allow filters that read more naturally.
The after modifier is the inverse of the before modifier.
The none modifier requires that the attribute does not have a value. For example:
task list priority:
task list priority.none:
are equivalent, and list tasks that do not have a priority.
The any modifier requires that the attribute has a value, but any value will suffice.
The is modifier requires an exact match with the value.
The isnt modifier is the inverse of the is modifier.
The has modifier is used to search for a substring, such as:
task list description.has:foo
task list foo
which are equivalent and will return any task that has ‘foo’ in the description or annotations.
The hasnt modifier is the inverse of the has modifier.
The startswith modifier matches against the left, or beginning of an attribute, such that:
task list project.startswith:H
task list project:H
are equivalent and will match any project starting with ‘H’.
The endswith modifier matches against the right, or end of an attribute.
The word modifier requires that the attribute contain the whole word specified, such that this:
task list description.word:bar
will match the description ‘foo bar baz’ but does not match ‘dog food’.
The noword modifier is the inverse of the word modifier.
Specifying Dates and Frequencies
Dates
Exact specification task . due:7/14/2008 Relative wording task . due:today
task . due:yesterday
task . due:tomorrow Day number with ordinal task . due:23rd
task . due:3wks
task . due:1day
task . due:9hrs Start of (work) week (Monday), calendar week (Sunday or Monday), month and year
task . due:sow
task . due:soww
task . due:socw
task . due:som
task . due:soy End of (work) week (Friday), calendar week (Saturday or Sunday), month and year
task . due:eow
task . due:eoww
task . due:eocw
task . due:eom
task . due:eoy At some point or later
task . wait:later
task . wait:someday
This sets the wait date to 1/18/2038. Next occurring weekday task . due:fri
Frequencies
daily, day, 1d, 2d, . Every day or a number of days. weekdays Mondays, Tuesdays, Wednesdays, Thursdays, Fridays and skipping weekend days. weekly, 1w, 2w, . Every week or a number of weeks. biweekly, fortnight Every two weeks. quarterly, 1q, 2q, . Every three months, a quarter, or a number of quarters. semiannual Every six months. annual, yearly, 1y, 2y, . Every year or a number of years. biannual, biyearly, 2y Every two years.
Command Abbreviation
is an unambiguous abbreviation for
could be list, ls or long.
Specifying Descriptions
$ task add «quoted ‘ quote»
$ task add escaped \’ quote
The argument — (a double dash) tells taskwarrior to treat all other args as description:
$ task add — project:Home needs scheduling
In other situations, the shell sees spaces and breaks up arguments. For example, this command:
is broken up into several arguments, which is corrected with quotes:
Configuration File and Override Options
/.taskrc . The default configuration file can be overridden with task rc:
Specifies an alternate configuration file. task rc. : . Specifies individual configuration file overrides.
Examples
For examples please see
the task tutorial man page at
or the online documentation
Files
/.taskrc User configuration file — see also taskrc(5).
/.task The default directory where task stores its data files. The location can be configured in the configuration file.
/.task/pending.data The file that contains the tasks that are not yet done.
/.task/completed.data The file that contains the completed «done» tasks.
/.task/undo.data The file that contains the information to the «undo» command.
Credits & Copyrights
This man page was originally written by P.C. Shyamshankar, and has been modified and supplemented by Federico Hernandez.
Thank also to T. Charles Yun.
Taskwarrior is distributed under the GNU General Public License. See http://www.gnu.org/licenses/gpl-2.0.txt for more information.
See Also
For more information regarding taskwarrior, the following may be referenced: The official site at The official code repository at You can contact the project by writing an email to
Источник