Links, Instances and Processes - Linux


Links are aliases that point to other files that can be on the same filing system (Unix) or across several filing systems. Linking a file is a cross between renaming the file and copying the file to your Home directory. When you link a file, you add a second name to the file, so that, to the operating system it looks like there are two files. A link is actually in a directory, like a file is, but whenever a program tries to get at the file the link represents, Unix sends the program to find the "real" file.

A Soft Link can span file systems (two different servers). If you delete the original file, you delete the Link.

A Hard Link is restricted to two items on the same file system (same server). If you delete either name, the original item is still there under the remaining name only.

You can use a link to shorten typing, linking a file with a long path name to your current directory. For example: if you want to run the file /usr/local/scripts/startup.ksh from your home directory without typing the entire name, you can create a link to it in your home directory called "Startup".

	ln -s  /usr/local/scripts/startup.ksh Startup

"ln" by itself is the command to create a hard link, the "-s" option makes it a soft link.

To delete a link, remove it the way you would an ordinary file using "rm". You are actually just removing the link, not the original file.

Instances and Processes

A process is an execution environment set up by the operating system kernel. A process consists of 3 major components:

  • system data
  • user data
  • program instruction.

Unix is a multi-tasking environment, this means that multiple processes can be run simultaneously. (sometimes processes are called sessions). If a program is being run by more than 1 user at a time, each process that is running the program is called an instance.

Example: If the E-mail reader program "pine" is run, it is considered a process under Unix. If another person runs "pine" at the same time, we say that there are 2 instances of "pine" being operated.

Processes are also called "jobs".

ps - Process Status

In order to see which processes are operating under your account, type "ps". "ps" stands for Process Status and will display all processes that are currently operating.


 16852 1a 0:02 ksh
 16889 1a 0:00 ps

When the "ps" command is entered, a display similar to the above will be displayed.

  • PID - Process ID number: used by the kernel to keep track of the process.
  • TTY - The terminal with which the process is associated with.
  • TIME - CPU time spent running the process (not wall-clock time).
  • COMMAND - The name of the process running.
The "ps" command is very useful in determining if you have safely exited a program. Quite often in Unix, you may get bumped from a process (such as ftp) and end up disconnected. The ftp process may still be running. When you log back on, check to see what processes you have open using "ps".


If you were bumped out or locked up in a process, you can usually escape back to the command line by doing one or all of the following key stroke commands:

 ctlr d  End input (End of file)
 ctrl z  Pause  Job
 ctrl c  Kill job
 ctrl x  Quit program

In order to terminate the process, you would first use the "ps" command to find out if the process is still running and what PID is associated with it.


While using the E-mail package "pine", it locked up and the above key combinations were pressed in a mad frenzy. Fortunately, we were returned to the command line prompt. "ps" was typed in to see what the process status was:


 16852 1a 0:02 ksh
 16889 1a 0:12 pine
 16957 1a 0:12 ps

This indicated that "pine" was still running. In order to terminate or stop "pine", the kill command is used with the PID of the process that we want to terminate:

 kill 16889   This will kill "pine"

Unfortunately, sometimes the kill command by itself will not work on all flavours of UNIX. Sometimes you may have to use some extra options such as:

 kill -kill 16889

You can escalate the "degree" of kill by using the option "-9" and if that doesn't work then perform the kill on steroids "-15":

 kill -9 16889

 kill -15 16889

All Unix systems have the ability to run multiple commands simultaneously. The process that is currently displayed on the screen is said to be running in the foreground. Other processes by the same user are said to be running in the background (not currently displayed on the terminal).

Job Control is used to manage multiple processes and allows users to manipulate foreground and background processes.

To run a process in the background, add "&" to the end of the normal command:

 sleep 120&

In the above example, the sleep command causes the UNIX terminal to do nothing for 120 seconds. The "&" indicates that it is performed in a background process.

Moving a Foreground Process into the Background

In order for a foreground process to be moved into the background, it first must be running in the foreground. Then the foreground process must be stopped using "ctrl z" which is the pause command. Once stopped, the bg (background) command can be used to start the process running again.


 pr index.txt   (prints the file index.txt to standard output)
 ctrl z    (stops process - pauses)
 stopped    (Unix replies with "stopped" message)
 bg    (instructs process to move to the background)
 [1]  pr index.txt  (displays process moved to background)

To display currently running jobs, type:


 [1] RUNNING pr index.txt

Moving a Background Job to the Foreground

To move a background job or process to the foreground, you must know the job number. The number in square brackets [ ] indicates the job number.


 [1] RUNNING pr index.txt

To move the background job to the foreground, use the fg (foreground) command:

 fg OR
  fg1  OR
 fg %1  (1 indicates job number)

This will move job #1 to the foreground. The fg command will be implemented just a little bit different depending on the shell or flavour of Unix run.

If this page has helped you, please consider donating $1.00 to support the cost of hosting this site, thanks.

Return to

TelecomWorld 101

Copyright July 2013 Eugene Blanchard