Processes & Jobs

Every command you issue to the Linux OS becomes a unique process with its own identification number and most importantly its own area of memory. These individual processes share the resources of the computer through the scheduling software in the Linux Kernel.

The processes being run are maintained in the /proc filesystem. LOTS OF DETAIL

The processes being run on the system can be listed with the ps (process show) command. ps is an unusual command in that it has different options in standard Unix and BSD environments and so to make life easier for people coming from the different environments the BSD flags are used without a leading hyphen whereas the standard Unix flags are placed after a hyphen try the following on your own computer.
BSD Example

ps auxf

Standard Unix example

ps -ef

The BSD flags allow you greater control over what is displayed though the standard Unix flags are more portable.

You can run moe than one process in each shell also, for example read your bash resource controls

view ~/.bashrc

Now suppose there is a command called by this file that you do not know well (eg alias ll='ls -l') and you want to know what it does. You can suspend the view process and run the man alias command to find out more about it. To do this hold down the [CTRL] key and hit the Z key. this sends a signal to the running process known as SIG STOP which suspends the process. You can now run the man command on the command you didn't know. To recover the view session you can type fg (foreground) this will bring the suspended process back to the foreground.
If you want to continue working but have a process you have started run in the background you can suspend it and type bg which will have it run in the background.

To find out what processes are running in the current shell issue the jobs command. This gives you a list of all jobs running or suspended in the current shell. You can retrieve a specific process by foregrounding its number, eg:

[email protected]:~/workspace/HealthCheck_0.2.1b/build/$ jobs
[1]- Stopped less
[2]+ Stopped vim Net/CP/HealthCheck/ (wd: ~/workspace/HealthCheck_0.2.1b/build)
[3] Stopped vim Net/CP/HealthCheck/Service/
[4] Stopped vim ./
[5] Stopped vim Net/CP/
[6] Stopped vim config/tpl/perf_table.tpl
[email protected]:~/workspace/HealthCheck_0.2.1b/build/$ fg 5

This recovers the vim Net/CP/ process

If you know you want to run a command in the background from the start you can cll it with an ampersand after it, this automatically starts it in the background, eg:
~/ $ cat >/dev/audio /media/sounds/scream.raw &

Because Linux is very network friendly there are times when you will be working on a machine that is not local to you. In this situation commands that you need to run in the background can be invoked with nohup. this redirects their output to the nohup.out file and disassociated them from your login session. Thus should something happen to log you out, your command continues to run.

Where the command you need to run is more interactive you can run it within the screen command, this command acts as a layer between your terminal and the command it is running and allows you to recover interrupted sessions by running screen -r. It has a small set of commands

[CTRL]-A c #This creates a new screen session
[CTRL]-A A #Set the name of the current session
[CTRL]-A " # List running sessions
[CTRL]-A d # detatch screen from the current terminal
[CTRL]-A $n # Where n is a number listed by [CTRL]-A " switches to that session