Linux Process

A process is a program in execution.  It consists of the executing programing code, a set of resources such as opened files, internal kernel data, an address space, one or more threads of execution and a data section containing global variables.

Process Descriptors

Each process has process descriptors associated with it. These hold the information used to keep track of a process in memory. Among the various pieces of information stored about a process are its PID, state, parent process, children, siblings, processor registers, list of open files and address space information.

To see all processes on a system, you can type "ps aux | less"

ps

To see all nonroot process type "ps -U root -u root -N".

nonroot

To see all of your processes type "ps -u $USER".

userprocesses

How to background a process in Mosaic Linux

Sometimes a user wishes to run a process but be able to still do other things while the process runs in the background. This is actually very simple and efficient on Linux. To do this, one must first start a process (for example type "Top").

process1

Once the program has started, press Ctrl-Z to suspend the program.

process2

Next enter the background command to resume running of this program in the background: "bg".

process3

To bring the process back into the foreground just type the command "fg" for foreground.

process4

Once "fg" is entered the process top will return to the foreground as shown below.

process5

If you wish to see current jobs running, just enter "jobs" in the command console.

Detaching/attaching to a process

Some users wish to completely detach a running process from the display screen while it is still running. They also want to be able to reattach to check on the progress of the process because once you detach from the process there is no notification when the process has been completed.

To first detach you must start a process and again "top" will be used.

process6

Once the program has started, press Ctrl-Z to suspend the program.

process7

To detach from the screen type "screen –m –d –S nameofscreen top". While you are detached the program continues running. The shortcut to do this is "[Ctrl]-[A] d". The shortcut will only work if screen is already running

process8

If done correctly, the process should disappear and you should be able to use the terminal again.

process9

To reattach the screen you must type: "screen –r nameofscreen" .

process10

If you have done this correctly, then the top process would appear in the terminal once again and your terminal command console will look as follows.

process11

Please note the following information as it will help you with the background/foreground/attach/detach process. You will want to use the foreground/background commands if you wish to stay logged in but want to run multiple jobs. You should use the detach/attach commands if you wish to log off Mosaic Linux while running a job. The detach/attach options are only available on the Linux X-servers while any user can background a process on a Mosaic Linux desktop or X-server. If you plan on running a long job on a system, be sure to detach/attach a job on a compute server. If you log out you can reattach a job in the same manner you would as if you were still logged in. Other users however will not be able to reattach the job to their terminal command console session.