About The Unix Processes

Explain the Unix Processes.

A process is an instance of running program. If, for example, three people are running the same program simultaneously, there are three processes there, not just one. In fact, we might have more than one process running even with only person executing the program. Every time you issue a command, Unix starts a new process, and suspends the current process (the C-shell) until the new process completes (except in the case of background processes, i.e. Daemon threads.

Unix identifies every process by a Process Identification Number (pid) which is assigned when the process is initiated. When we want to perform an operation on a process, we usually refer to it by its pid. Unix is a timesharing system, which means that the processes take turns running. Each turn is a called a timeslice; on most systems this is set at much less than one second. The reason this turns-taking  approach is used is fairness: We don’t want a 2-second job to have to wait for a 5-hour job to finish, which is what would happen if a job had the CPU to itself until it completed.

Each unix process has two ID numbers assigned to it: Process ID (pid) and Parent process ID (ppid). Each user process in the system has a parent process. Most of the commands that we run have the shell as their parent. Alternatively we can run ps -f command where it lists both process ID and parent process ID.

The ‘ps -x’ command will list all your currently-running jobs. An example is:

PID TT STAT TIME COMMAND
6799 co IW 0:01 -csh[rich] (csh)
6823 co IW 0:00 /bin/sh /usr/bin/X11/startx

The meaning of the column titles is as follows:

PID process identification number
TT controlling terminal of the process
STAT state of the job
TIME amount of CPU time the process has acquired so far
COMMAND name of the command that issued the process

We can terminate a process by using the kill command. We simply find its pid (say by using ps), and then
Type: kill -9 pid

Stream Editor of Unix :

sed (stream editor) is a Unix utility that parses text and implements a programming language which can apply transformations to such text. It reads input line by line (sequentially), applying the operation which has been specified via the command line (or a sed script), and then outputs the line. It was developed Bell Labs, and is available today for most operating systems.[

sed is one of the very early Unix commands built for command line processing of data files. It evolved as the natural successor to the popular grep command. Cousin to the later AWK, sed allows powerful and interesting data processing to be done by shell scripts.

  sed and AWK are often cited as the progenitors and inspiration for Perl. 

The following example shows a typical, and the most common, use of sed, where the -e option indicates that the sed expression follows:

   sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName

In many versions, the -e is not required to precede the expression. The s stands for substitute. The g stands for global, which means that all matching occurrences in the line would be replaced. Theregular expression (i.e. pattern) to be searched is placed after the first delimiting symbol (slash here) and the replacement follows the second symbol. Slash is the conventional symbol.

Unix Tips


 

See Also

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.