0% found this document useful (0 votes)
16 views17 pages

Linux Module 2 - Incomplete

Uploaded by

Aswin kv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views17 pages

Linux Module 2 - Incomplete

Uploaded by

Aswin kv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Linux Module 2 (Revision Series)

Sem 4 BCA/B.Sc. Computer Science MGU

For Notes download BCA Resources App


Process
• Refers to a program in execution.
• Made up of program instructions, data read from files other program or input
from a system.
• During it’s lifetime, it will use a lot of system resources.
• Uses CPU in the system tot run it’s instructions & system memory to hold it’s data

For Notes download BCA Resources App


Processes in Linux
• Running instance of a command.
• When you issues a command in Linux, it creates or starts a new process.
• Process is identified by it’s process ID
• Process ID is unique
• Once a process is end, another process can reuse that process ID
• While a process is running, it is associated with a particular user account & group
account.
• That account info helps to determine what system resources the process can
access.

For Notes download BCA Resources App


Process States
• Running: the process is either running or it is ready to run
• Waiting (Blocked): Process is waiting for an event or for a resources.
• Two Types of waiting processes:
• 1. Interruptible Process: can be interrupted by signals
• 2. Uninterruptible Process: are waiting directly by hardware conditions &
can’t be interrupted.
• Stopped: The process is completed. This process can be restarted
• Zombie: Halted process or dead process. This process will be terminated &
information will still be available in the process table.

For Notes download BCA Resources App


File Processing Commands
• wc
• Used to display the number of lines, words & character information stored on a file
• Syntax: wc options filename
• Options:
• -l : displays number of lines in the file
• -w: displays number of words in the file
• -c: displays number of bytes in the file
• -m : displays number of characters in the file

• Paste
• Concatenates the content of specified files into single file vertically.
• Used to merge lines of files
• Syntax: paste file1 file2
• Options:
• -d delim : use delim character as delimiter instead of a tab

For Notes download BCA Resources App


Mathematical Commands
• expr
• Used to perform arithmetic operations on integers.
• Can’t handle floating point arithmetic
• Syntax: expr expression
• bc
• Commandline utility that provides all features of simple scientific calculator
• Used to perform arithmetic operations on integers as well as on floating point numbers.
• By default performs integer division. If you required float division then set scale to the number of digits
of precision before the operation.
• factor
• Used to print prime factors of a number
• Number is given from command line or read from standard input.

For Notes download BCA Resources App


Other Commands
• nohup (no hang up)
• If user wants a process that he has executed not to die even when logged out from system, then we can
use this command
• Syntax: nohup command&
• kill
• Used to terminate a process
• Syntax: kill –signal number pid
• By default uses signal number 15 to terminate a process
• To kill a process forcefully use signal number 9 (“Sure kil”)
• ps
• Shows which process are running in a system.
• Syntax: ps options
• Results contain 4 columns.
• PID – process ID
• TTY – terminal type that user is logged into
• Time – Amount of CPU in minutes and seconds that the process is running
• CMD - name of the command that launched the process
For Notes download BCA Resources App
Other Commands
• ps
• To list all process
• Options.
• -A, -e – View all the running processes
• -T – select all processes on this terminal
• -u – to list all processes which are running for specified user.
• Who
• Used to display users who are logged on the system currently.
• Syntax: who options
• Options:
• -b : time of last system boot
• -a : list of all available output for each user on your system
• -d: displays dead processes.
• who am i – tells the username of yours

For Notes download BCA Resources App


Other Commands
• touch
• Used to create empty files
• Does not allow you to store anything in a file
• Also allows you to change the modification & access times of a file to specified time without accessing
or modifying
• Syntax: touch option filename
• Options.
• -a – changes only access time
• -m – changes only modification time.
• find
• Used to locating files which meet the search criteria.
• Syntax: find path_list selection_criteria action
• Recursively examines all files in the directory specified in path_list & matches files based on selection
criteria and takes action specified on those files

For Notes download BCA Resources App


Find command
• Selection criteria
• -name filename : selects file specified
• - user username: selects file owned by the user
• -type d: selects directories.
• Action
• -print : displays the selected files
• -delete : delete those files

For Notes download BCA Resources App


Types of Processes in Linux
1. Parent & child process
• Each process in linux has two ID numbers assigned to it. 1) Process ID 2) Parent Process ID (ppid)
• Each process has a parent process
• When a new process is created, it is a child process.
2. Zombie process
• Process whose execution is completed but still has an entry in process table.
• Usually occurs for child process
• Once parent process reads it’s child’s exit status then zombie process is eliminated from the process table.
3. Orphan Process
• Running process whose parent process has finished or terminated without waiting for the child process to terminate.
• Will be immediately adopted by special init system process once the parent process dies.
4. Daemon process
• Process which runs in background & has no controlling terminal
• Almost no user interaction is required.
• They are system-related background processes that often run with the permissions of root & services requests from
other processes.

For Notes download BCA Resources App


Process Attributes
1. Process ID : unique ID used to refer the process
2. Parent Process ID: the PID of parent process that started this
process
3. Nice number: priority number
4. Terminal: terminal which the process is connected
5. Username: owner of the process.
6. Real & effective group owner: group who owns the process

For Notes download BCA Resources App


Starting a Process
1. Foreground Process: Runs on the screen & need input from user
2. Background Process: Run in background & don’t need user inputs

For Notes download BCA Resources App


Foreground Process
• Referred as interactive processes
• Are initialized & controlled through a terminal session.
• Started by user
• While running in foreground, if program is time consuming then you
won’t be able to run other commands.

For Notes download BCA Resources App


Background Process
• Referred as non-interactive processes
• Are not connected to terminal.
• Other processes can be done in parallel
• You can run other commands
• Simplest way to start a background process is to add an ampersand
(&) at end of the command
• Eg: cp file filecopy&

For Notes download BCA Resources App


Pipes
• Form of redirection that is used in Linux.
• Used to send the output of one program to another program for further
processing.
• Uses the output of one command as input of another command
• Both process are connected using the vertical bar symbol “|”.
• Allows two or more command to combine
• Pipes are unidirectional, data flow from left to right through the pipeline
• Pipes are often used to filter, modify, or manipulate data output of one
command.
• Eg: man ls | more

For Notes download BCA Resources App


Tee command
• Reads the standard input & writes it to both the standard output & one or more
files.
• Basically breaks the output of a program so, it can be displayed & saved in a file.
• Syntax: command 1 | command 2 | tee filename

For Notes download BCA Resources App

You might also like