0% found this document useful (0 votes)
24 views

Unix Module 3

The document discusses Unix files and processes. It covers that everything in Unix is treated as a file, including directories, executables and processes. It describes initializing, tracking and stopping processes using commands like ps, kill and nice. It also discusses setting process priority and viewing running processes with top.

Uploaded by

use others01
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)
24 views

Unix Module 3

The document discusses Unix files and processes. It covers that everything in Unix is treated as a file, including directories, executables and processes. It describes initializing, tracking and stopping processes using commands like ps, kill and nice. It also discusses setting process priority and viewing running processes with top.

Uploaded by

use others01
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/ 40

UNIX/Linux Course

Unix Files and Processes

Copyright Intellipaat. All rights reserved.


Unix Files and Processes

Copyright Intellipaat. All rights reserved.


Agenda
Everything is a File Unix Process Control
01 02 Commands
in UNIX

Copyright Intellipaat. All rights reserved.


Everything is a File in UNIX

Copyright Intellipaat. All rights reserved.


Everything is a File in UNIX

FILES

DIRECTORIES

EXECUTABLES

PROCESSES

Copyright Intellipaat. All rights reserved.


Everything is a File in UNIX
The first character of flags indicates the type of file:

‘-’ represents that it is an ordinary file


FILES

DIRECTORIES

EXECUTABLES

PROCESSES

Copyright Intellipaat. All rights reserved.


Everything is a File in UNIX
The first character of flags indicates the type of file:

‘d’ represents that it is a directory, which is a special


FILES file

DIRECTORIES

EXECUTABLES

PROCESSES

Copyright Intellipaat. All rights reserved.


Everything is a File in UNIX
The first character of flags indicates the type of file:

‘-’ represents that this is also an ordinary file


FILES

DIRECTORIES

EXECUTABLES

PROCESSES

Copyright Intellipaat. All rights reserved.


Everything is a File in UNIX
The first character of flags indicates the type of file:

‘d’ represents that processes are also directories


FILES

DIRECTORIES

EXECUTABLES

PROCESSES

Copyright Intellipaat. All rights reserved.


Unix Process Control Commands

Copyright Intellipaat. All rights reserved.


Unix Process Control Commands
A command issued in unix/linux, starts a new process,
which invokes a 5 digit unique id, called pid.
Using pid, the process can be tracked

This process Using pid the


invokes an pid process can be
unique id tracked

pwd Track

Copyright Intellipaat. All rights reserved.


Initializing a Process
A process can be initialized in two ways,
foreground and background

INITIALIZING A
PROCESS

TRACKING A
PROCESS

STOPPING A Foreground Background


PROCESS Runs in the background allowing other
Every process runs in foreground by
default when it is started processes to run in parallel

OTHER PROCESSES $ ls pwd $ pwd &

Copyright Intellipaat. All rights reserved.


Initializing a Process
All running processes can be tracked using the following
commands:

INITIALIZING A $ ps
PROCESS
Lists out all the running processes
TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Initializing a Process
All running processes can be tracked using the following
commands:

INITIALIZING A $ ps -f
PROCESS
Lists out full formatted information of running processes
TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Initializing a Process
All running processes can be tracked using the following
commands:

INITIALIZING A
PROCESS

TRACKING A
PROCESS
UID: User ID or ID of the user running the process
PID: Process ID
STOPPING A PPID: Parent process ID
PROCESS C: CPU utilization of process
STIME: Start time process
TTY: Terminal type associated with the process
OTHER PROCESSES TIME: CPU time taken by the process
CMD: The command that started this process

Copyright Intellipaat. All rights reserved.


Tracking a Process
All running processes can be tracked using the following
commands:

INITIALIZING A $ ps -aux
PROCESS
Lists out all the running processess for all users
TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Tracking a Process
All running processes can be tracked using the following
commands:

INITIALIZING A $ ps -u [username]
PROCESS
Lists out all the running processess for one user
TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Stopping a Process
In order to stop a foreground running process use the following
command:

INITIALIZING A $ Ctrl + C
PROCESS

In order to stop a background running process use the following


TRACKING A command:
PROCESS

$ kill [TERM SIG] [pid]


STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Stopping a Process

Take a look at the list of terminate signals

INITIALIZING A $ kill -l
PROCESS

TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Stopping a Process
Example, stop the cat command running in background by sending
the kill signal

INITIALIZING A $ cat &


PROCESS

$ kill -9 9922
TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes
The following command is used to see all the running processes
within the working environment of Linux

INITIALIZING A $ top
PROCESS

TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes
The following command is used to start a process and assign it a
priority value (also known as nice value) at the same time

INITIALIZING A $ nice [-nice value] [process]


PROCESS
nice value ranges from -20 to 19, where -20 is of the
TRACKING A highest priority
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES Nice value 0


Default priority 80

Copyright Intellipaat. All rights reserved.


Other Processes

$ nice -19 [command] VS. $ nice --19 [command]

INITIALIZING A
PROCESS

TRACKING A
PROCESS

STOPPING A
PROCESS Nice value 19
Priority is reduced to 99

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes

$ nice -19 [command] VS. $ nice --19 [command]

INITIALIZING A
PROCESS

TRACKING A
PROCESS

STOPPING A
PROCESS Nice value -19
Priority is increased to 61

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes
The following command is used to change the priority of a
process

INITIALIZING A $ renice [-nice value] [process id]


PROCESS

TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes
The following command is used to change the priority of a
process

INITIALIZING A $ renice [-nice value] [process id]


PROCESS
Let’s say, a process is started with a nice value of -10

TRACKING A
$ nice -10 cat &
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes
The following command is used to change the priority of a
process

INITIALIZING A $ renice [-nice value] [process id]


PROCESS
Now we want to modify the priority of the process. How do we do that?

TRACKING A
$ renice -3 11988
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Other Processes
The following command is used to see the amount of available
and used disk space by a file systems

INITIALIZING A $ df
PROCESS

TRACKING A
PROCESS

STOPPING A
PROCESS

OTHER PROCESSES

Copyright Intellipaat. All rights reserved.


Quiz

Copyright Intellipaat. All rights reserved.


Quiz
1. Which command is used to start the cat process in the background?

A. cat &&

B. cat &

C. Both a and b

D. cd. None of the above

Copyright Intellipaat. All rights reserved.


Quiz
1. Which command is used to start the cat process in the background?

A. cat &&

B. cat &

C. Both a and b

D. cd. None of the above

Copyright Intellipaat. All rights reserved.


Quiz
2. Lists out all the running processes for one user

A. ps -u [username]

B. ls -u [username]

Copyright Intellipaat. All rights reserved.


Quiz
2. Which command is used to check which users are logged in to the system?

A. ps -u [username]

B. ls -u [username]

Copyright Intellipaat. All rights reserved.


Quiz
3. Which of the following has lowest priority?

A. Nice value = 4

B. Nice value =-4

C. Nice value = 2

D. Nice value =-2

Copyright Intellipaat. All rights reserved.


Quiz
3. Which of the following has lowest priority?

A. Nice value = 4

B. Nice value =-4

C. Nice value = 2

D. Nice value =-2

Copyright Intellipaat. All rights reserved.


Quiz
4. Which of the following command is used to check the amount of disk space used by
a file system

A. ps

B. ls

C. df

D. None of the above

Copyright Intellipaat. All rights reserved.


Quiz
4. Which of the following command is used to check the amount of disk space used by
a file system

A. ps

B. ls

C. df

D. None of the above

Copyright Intellipaat. All rights reserved.


Quiz
5. Which of the following terminate signal kills the process when used with the kill
command?

A. 1

B. 5

C. 14

D. 9

Copyright Intellipaat. All rights reserved.


Quiz
5. Which of the following terminate signal kills the process when used with the kill
command?

A. 1

B. 5

C. 14

D. 9

Copyright Intellipaat. All rights reserved.


India: +91-7847955955

US: 1-800-216-8930 (TOLL FREE)

[email protected]

24/7 Chat with Our Course Advisor

Copyright Intellipaat. All rights reserved.

You might also like