Unix Tutorial 3 : Processes Control Commands

Unix Processes

A process is a context in which a program executes. Every time when a command or program is run, a new process is created. The process is active for as long as the program is in an active state.
For Example, if we are executing the cat command then a process named “cat” is generated.
Each time a new process is created, the Kernel assigns a unique identification number called the PID i.e. process identification number) which lies in between 0 to 32,767. Other properties of processes include their PPID (Parent PID), TTY (the controlling terminal from where they were launched), UID (the user id that owns this process) and GID (the group that is associated with the process).
In Unix, the processes have a hierarchical relationship, where a parent process spawns the  child processes. The ‘init’ process is the grandfather process of all the other processes. In some cases, where the parent process is killed before the child process, the child is called an orphan process.

#1) Foreground Process

A process that is launched from a terminal and disallows further commands until it completes. In such a process, the stdin and stdout are attached to the terminal by default.

#2) Background Process

It is a process that was launched from a terminal, but is run in the background, thus allowing further commands while it runs. In such a process, the stdin and stdout should typically be redirected so they don’t interfere with other foreground processes.

#3) Daemon Process

It is a process that is not associated with a terminal session. Such processes are usually launched for system services such as networking and printing.
In this tutorial, we will cover control commands, as well as the other commands that are used to manipulate the processes.

Control Commands

These commands are a two-key combination where a letter is pressed simultaneously with the ‘Ctrl’ key.
  • Control-C: This command terminates the currently running foreground process.
  • Control-D: This command terminates the currently running login or terminal session.
  • Control-Z: This command suspends the currently running foreground process to the background.
Other Commands:
Commandps - displays a snapshot of all current processes
Common Syntax
$ ps [options]
Example$ ps -ef  
Show every process running, formatted as a table


Command
top - displays a live status of current processes
Common Syntax
$ top [options]
Example$ top
Show a live view of all current processes

Command
bg - resume a background suspended a job
Common Syntax
$ bg [job_spec …]
Example$ xterm
Ctrl-Z
$ bg
Continue running a job that was previously suspended (using Ctrl-Z) in the background
Command
fg - bring a background job to the foreground
Common Syntax
$ fg [job_spec]
Example$ xterm
Ctrl-Z
$ bg
$ fg 

Bring a previous background job to the foreground
Command
clear – clear a terminal screen
Common Syntax
$ clear
Example$ clear
Clear all prior text from the terminal screen
Command
history – print history of commands in the current session
Common Syntax
$ history [options]
Example$ history
Show list of previous commands that were entered

Comments

Popular posts from this blog

Hive Tutorial 31 : Analytic Functions

Hive Tutorial 37 : Performance Tuning