How to check background running process in Linux Ubuntu? Here is the background process Linux command to check running process in Linux for a user.
Processes in Linux Ubuntu
Process is a computer program which is a started whenever any command is given to the System. PID or Process Identifier (also known as process ID) is a specific number used by Kernels. The PID is used to uniquely identify an active process by the OS.
Linux processes have the following states:
- Running: The process is either running (it is the current process in the system) or it is ready to run (it is waiting to be assigned to one of the system’s CPUs).
- Waiting: The process is waiting for an event or for a resource. Linux differentiates between two types of waiting process; interruptible and uninterruptible. Interruptible waiting processes can be interrupted by signals whereas uninterruptible waiting processes are waiting directly on hardware conditions and cannot be interrupted under any circumstances.
- Stopped: The process has been stopped, usually by receiving a signal. A process that is being debugged can be in a stopped state.
- Zombie: This is a halted process which, for some reason, still has a task_struct data structure in the task vector. It is what it sounds like, a dead process.
Check Running Process In Ubuntu Linux
There are many process management commands which are used to check check running process in Ubuntu Linux. Some of the most widely used commands are top, htop and ps.
top Command
top command displays Linux processes. The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for processes are all user configurable and that configuration can be made persistent across restarts.
The program provides a limited interactive interface for process manipulation as well as a much more extensive interface for personal configuration — encompassing every aspect of its operation. And while top is referred to throughout this document, you are free to name the program anything you wish. That new name, possibly an alias, will then be reflected on top’s display and used when reading and writing a configuration file.
When started for the first time, you’ll be presented with these traditional elements on the main top screen: 1) Summary Area; 2) Fields/Columns Header; 3) Task Area. There is also an Input/Message line between the Summary Area and Columns Header which needs no further explanation.
The three most important Ids displayed by the top command are:
- PGRP — Process Group Id: Every process is member of a unique process group which is used for distribution of signals and by terminals to arbitrate requests for their input and output. When a process is created (forked), it becomes a member of the process group of its parent. By convention, this value equals the process ID (see PID) of the first member of a process group, called the process group leader.
- PID — Process Id: The task’s unique process ID, which periodically wraps, though never restarting at zero. In kernel terms, it is a dispatchable entity defined by a task_struct. This value may also be used as: a process group ID (see PGRP); a session ID for the session leader (see SID); a thread group ID for the thread group leader (see TGID); and a TTY process group ID for the process group leader (see TPGID).
- PPID — Parent Process Id: The process ID (pid) of a task’s parent.
htop Command
htop command is an interactive process viewer for Linux Ubuntu Systems. Htop is a ncurses-based process viewer for Linux which is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines, as well as viewing them as a process tree, selecting multiple processes and acting on them all at once.
ps Command
ps command displays information about the active processes. It displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulated CPU time in [DD-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD). Note that the output is unsorted by default.
Using ps command
- ps -A: The ps -A command lists all processes running on the system.
- ps -A | less: The “less” command argument is used to limit the result per screen. By default there are too many processes which are displayed on the screen and it is really hard to read at one time. To display the result in less quantity, the command argument “less” is used. Note that when you use “less” argument, you will have to press “enter” to display the next set of processes list. Also, Press q to exit when you’re done.
- ps -A | grep firefox: To find the process details of a specific program (firefox in this example) use the command arguemnt grep. The command would search for the specific process only.
Other examples of using ps command
To see every process on the system using standard syntax:
- ps -e
- ps -ef
- ps -eF
- ps -ely
To see every process on the system using BSD syntax:
- ps ax
- ps axu
To print a process tree:
- ps -ejH
- ps axjf
To see every process running as root (real & effective ID) in user format:
- ps -U root -u root u
Please use Linux terminal commands wisely. If you are not sure about any command, you can read the man page to know more about the specific command.