แผนกิจกรรมการศึกษาhealthsci.stou.ac.th/UploadedFile/แผน...ได วางแผนไว ตามข อ 1 โดย 2.1 ศ กษาด
Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ
-
Upload
dennis-armstrong -
Category
Documents
-
view
227 -
download
1
Transcript of Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ
![Page 1: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/1.jpg)
Introduction to Unix Operating System
โดย อ.ณั�ฐกร เฉยศิ�ร�
![Page 2: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/2.jpg)
Agenda An Overview of the UNIX Unix Installation
Pre Install Post Install
Startup & Shutdown Shell & Unix Command File System Account Management Network File System (NFS) Install Additional Software
Package Management Install Form Source Code
Process & Job control
![Page 3: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/3.jpg)
An Overview of the Unix OS
At first, unix was designed to let a number of programmeraccess the same time and share its resource. The importantfeatures that make unix favorite are:
Multitasking Multiuser Portability Unix Tools Unix Communication Library of application software
![Page 4: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/4.jpg)
Application Program
Kernel
Unix Structure
Hardware
![Page 5: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/5.jpg)
Information before install
Size of Memory and Hard Disk Bandwidth and Memory of Video Card Mouse type Host Name Network information such as IP address,
Gateway,Network Address,DNS Server Time Zone Root Password
![Page 6: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/6.jpg)
Choose Installation Class
Core system support Contains the minimum software required to boot and run Solaris.
but not include the OpenWindows software. End-user system support Contains the core system support software plus end user software,
which include OpenWindows and the Common Desktop Environment software.
Developer system support Contains the end-user software plus libraries, include files, man
pages, and programming tools for developing software. Entire distribution. Contains the entire Solaris 8 release. Entire distribution plus OEM system support Contains the entire Solaris 8 release software plus extended hardware support.
![Page 7: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/7.jpg)
Partition Your HDD
Easy for manage All the space on the
disk is available for anyone to use
Allow finer control over such task as a backup
If one file system corrupted the others remain intact
Allow you control amount of storage for allocate type of use
Single VS Mulitple
![Page 8: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/8.jpg)
Partition Scheme
Root (/) swap /usr /var /home
![Page 9: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/9.jpg)
Post Install
Setup Network Connection Install Additional Software Configure others service such as
Printer ,NFS,WWW etc
![Page 10: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/10.jpg)
Network Configuration
Display and configure the network interface using the “ifconfig” command
Ensure that the DNS is configured in file /etc/resolv.conf
Ensure that the routing table is set by command “netstat –r”
Ensure that the gateway is set in file /etc/defaultrouter
![Page 11: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/11.jpg)
Start up
Before the UNIX operating system can perform correctly, there are a number of steps that must be followed
The failure of any one of these can mean that the system will not start.
It is important for the Systems Administrator to be aware of what happens during system startup so that any problems that occur can be remedied.
![Page 12: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/12.jpg)
Booting - consists of the following steps
ROM PhaseBoot Program PhaseKernel initialization Phase Init Phase
![Page 13: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/13.jpg)
Boot ROM Phase
After turn on power to the system, the ROM will display system identification and run self-test diagnostics to verify system hardware
Then the ROM will loads primary boot program called bootstrap program that store in bootblock of a boot device
![Page 14: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/14.jpg)
Boot Program Phase
The boot strap program find and execute the secondary boot program from the file system and load it into memory
After the secondary boot program is loaded, it will load the kernel
![Page 15: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/15.jpg)
Kernel initialization Phase
The kernel initializes itself (Create process control and other data structures)
Load device driver modules Mounts the necessary file system Create the process 0 (swapper) Then, bring the system to “initdefault” state
specified in /etc/inittab
![Page 16: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/16.jpg)
Swapper
The first task for the kernel is to start the swapper process.
The swapper process is the part of the kernel that schedules all other process.
The swapper has process ID of 0 It’s first job is to start up the init process
![Page 17: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/17.jpg)
Init Phase
The kernel start /sbin/init process, which starts other process by reading the /etc/inittab file
The /sbin/init process start the run control scripts
![Page 18: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/18.jpg)
Run Control Script
Each init state has a corresponding series of run control scripts
The init process executes the /sbin/rc<n> script which execute a series of other scripts located in /etc/rc<n>.d directory
All run control scripts are also located in the /etc/init.d directory. These file are linked to run control scripts in /etc/rc<n>.d directory
![Page 19: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/19.jpg)
Run LevelRun level Description
0 Halt the machine
1Single user mode. All file systems mounted, only small set of kernel processes running. only root can login.
2 multi-user mode , without remote file sharing
3multi-user mode with remote file sharing, processes, and daemons
4 undefine
5 used for to start X11 on boot
6 shutdown and reboot
s or S same as single-user mode
![Page 20: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/20.jpg)
Shutdown
A UNIX machine should (almost) never be just turned off.
It is also important for the Systems Administrator to understand what the correct mechanism is to shut a UNIX machine down
There are a number of steps to carry out to ensure that the operating system and many of its support functions remain in a consistent state.
![Page 21: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/21.jpg)
Commands to shut down /usr/sbin/shutdown /sbin/init /usr/sbin/halt /usr/sbin/reboot
Step before shutdown List of all logged-in user by “who” command.
You might sent broadcast message to let user know the system being shutdown
Flush file system buffer to physical disk by “sync” Use Shut Down command
![Page 22: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/22.jpg)
Unix Shell
Unix is a layered operating system. The OS not allow applications accessing the hard
ware directly.
The shell acts as a command interpreter.
It takes each command and passes it to the operati
ng system kernel to be acted upon. And then displ
ays the results of this operation
![Page 23: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/23.jpg)
Relationship for Kernel,Shell and Application
![Page 24: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/24.jpg)
Features provided by the shell
The shell provides you with one or more of the following features.
![Page 25: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/25.jpg)
TTypes of shellypes of shell
There are several different shells available for Unix. The most popular are described here.
• Bourne shell (sh)
• C shell (csh)
• Korn shell (ksh)
• Bourne Again Shell (bash)
![Page 26: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/26.jpg)
Unix CommandUnix Command
A command is a program that tells the Unix system to d
o something.
Usually has the form: command [options] [arguments]
Commands are case sensitive. command and Command
are not the same.
Options and syntax for a command are listed in the ma
n page
![Page 27: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/27.jpg)
Navigation and Directory Control Commands
Command/Syntax What it will do
ls [options] [directory or file] list directory contents or file permissions
cd [directory] change directory
mkdir [options] directory make a directory
pwd print working (current) directory
rmdir [options] directory remove a directory
![Page 28: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/28.jpg)
File Maintenance Commands
Command/Syntax What it will do
chgrp [options] group file change the group of the file
chmod [options] file change file or directory access permissions
cp [options] file1 file2 copy file1 into file2; file2 shouldn't already exist.
This command creates or overwrites file2.
mv [options] file1 file2 move file1 into file2
rm [options] file remove (delete) a file or directory
(-r recursively deletes the directory and its contents)
![Page 29: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/29.jpg)
Miscellaneous commands
Command/Syntax What it will do
cat [options] file concatenate (list) a file
more (or less or pg) [options] file page through a text file
tail [options] file display the last few lines (or parts) of a file
head [-number] file display the first 10 (or number of) lines of a file
which command reports the path to the command or the shell alias in use
who or w report who is logged in and what processes are running
date [options] report the current date and time
grep [options] file search specify pattern in the file
tar [options] file or directory pack and zip file
![Page 30: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/30.jpg)
Unix file type
Regular file. A common file which contains data in text or binary.
Directory file. A file that contains name of other files and point to information on these files.
Symbolic link. A type of file that point to another file.
![Page 31: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/31.jpg)
Unix file type
Character devices file. A type of file use for certain type of devices(read-write data in one character).
Block devices file. A type of file use for certain type of devices(read-write data in block).
FIFO. A type of file that use for interprocess communication,some time call named pipe.
Socket. A type of file that use for network communication.
![Page 32: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/32.jpg)
Regular FileA regular file simply holds data. Perhaps the most common file type found in the Solaris Operating Environment are regular files, which allow you to store many different kinds of data. Regular files can hold ASCII text, binary data, image data, databases, application-related data, and more.
![Page 33: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/33.jpg)
Directory fileDirectories store information that associates file names with inode numbers. Unlike regular files that can hold many different kinds of data, directories can hold only one kind.
![Page 34: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/34.jpg)
Symbolic linkA symbolic link is a file that points to another file. Like directories,symbolic links contain only one kind of data. A symbolic link contains the pathname of the file to which it points.
![Page 35: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/35.jpg)
File type & symbol
Type Symbol
Regular file -
Directory d
Character device c
Block device b
Unix domain socket s
Name pipes p
link file l
![Page 36: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/36.jpg)
File Access Permission
Symbol Permission Means
r Read Can open and read content of file
w WriteCan write to file(Modify content) or delete it
x ExecuteCan execute the file(if it program or shell script)
- Denied Cannot read, write or execute file
![Page 37: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/37.jpg)
Type
d r w x r - x r - -
Owner Group Others
- r w x - - x r - xExample 1
Example 2
22 + 21 + 20
![Page 38: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/38.jpg)
The following example shows the use of the ls –la command to display permission file
![Page 39: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/39.jpg)
Permission and Owner Command
chmod [–R] permission filename
Changes access permission of a file.
chown [-R] username:groupname filename
Changes the ownership of a file.
chgrp [-R] groupid filename
Changes the group ownership of a file.
![Page 40: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/40.jpg)
Account ManagementEvery user on a UNIX machine must have an account.
Components of a user account are:
login name (also called a username). password. The numeric user identifier or UID. The numeric group identifier or GID. home directory. login shell. startup files.
![Page 41: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/41.jpg)
Add use from GUI tools
![Page 42: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/42.jpg)
Configuration files related to user accounts
/etc/passwd the password file, holds most of an account characteristics including username, UID, GID,GCOS information, login shell, home directory
/etc/shadow the shadow password file, a more secure mechanism for holding the password
/etc/group the group file, holds characteristics about a system's groups including group name, GID and group members
![Page 43: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/43.jpg)
Fields in /etc/passwd file
Each line in the /etc/passwd file contains several fields, separated by a colon ( : ) , and is formatted as follows:
username:password:uid:gid:comment:home-directory:loginshell
![Page 44: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/44.jpg)
Fields in /etc/shadow file
Each line in the /etc/shadow file contains several fields, separated by a colon ( : ) , and is formatted as follows:
username:password:lastchange:min:max:warn:inactive:expire
![Page 45: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/45.jpg)
Startup Files Once the home directory is created the startup files can be
copied in or created. Again you should remember that this will be done as the root user and so root will own the files. You must remember to change the ownership.
For exampleThe following is example set of commands that will perform these tasks. mkdir home_directory cp -pr /etc/skel/.* home_directory chown -R login_name home_directory chgrp -R group_name home_directory chmod -R 700 home_directory
![Page 46: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/46.jpg)
The NFS Distributed File SystemThe NFS environment contains the following components: NFS server – A system that contains the file resources to be shared with other
systems on the network. NFS client – A system that mounts the file resources shared over the network a
nd presents the file resources as if they were local.
![Page 47: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/47.jpg)
Configuring the NFS File Server
To set up an NFS server, complete the following steps:
1. Edit the /etc/dfs/dfstab file and add those file resources to be automatically shared whenever the system enters run level 3.
For example: # share -F nfs /usr/share/man
2. Start the NFS server daemons by invoking the following: # /etc/init.d/nfs.server startThis shares the contents of the /etc/dfs/dfstab file.
![Page 48: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/48.jpg)
The NFS Client Setup
1. Use the /usr/sbin/dfshares command to display a server’s available resources.
# dfshares host1
2. Use the /usr/sbin/mount command to access the remote file resource.
# mount host1:/usr/share/man /usr/share/man
3. To unmount the remote file resources from the client by using the /usr/sbin/umount command.
# umount /usr/share/man
![Page 49: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/49.jpg)
Install Software Using Package Management
pkginfo command to display information about the software packages that have been installed
pkgadd command uncompresses and copies files from the installation media to the local system’s disk.
pkgrm command deletes all files associated with that package unless those files are also shared with other packages.
![Page 50: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/50.jpg)
Install Software From Source Code
Tool & Utility for Compile Source codeCompiler & Library (GNUgcc & libgcc)Make (GNUmake)Autoconfigure (GNUautoconfigure)Compress/Uncompress (gzip/gunzip/tar)
![Page 51: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/51.jpg)
Apache Web Server Install
Overview for install apache
$ ./configure --prefix=PREFIX
$ make
$ make install
NOTE: PREFIX by default use
"/usr/local/apache"
![Page 52: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/52.jpg)
Configuration File
Finally you can customize your Apache HTTP server by editing the configuration files
$ vi PREFIX/conf/httpd.conf
$ vi PREFIX/conf/access.conf
$ vi PREFIX/conf/srm.conf
And Statrt web server by
$PREFIX/bin/apachectl start
![Page 53: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/53.jpg)
Most Important Configure
ServerName avalon.bu.ac.th ServerAdmin [email protected] DocumentRoot "/usr/local/apache/htdocs"
*Note ServerRoot and DocumentRoot is difference meaning
![Page 54: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/54.jpg)
A Unix process is an instance of an executing program It has a separate existence from all the other processes on the system we say that each process has its own address space
A unique number known as its process-id or pid
The pid of its parent process is the process which started it, usually a shell
Process & Job control
![Page 55: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/55.jpg)
Process state Processes also have state
One a single-CPU machine, only one process is running
Most processes are sleeping, waiting for input or output to finish
There are a few other odd states: swapped, zombie, or stopped.
![Page 56: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/56.jpg)
Job control The mechanism that shuffle processes from
foreground, background and stopped is known as job control
Job control requires three condition for support
A shell that support job control. The terminal driver in the kernel must support job
control Support for certain job-control signals must be
provided.
![Page 57: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/57.jpg)
Foreground and Background Tasks
Unix allows running processes to be
disconnected from their terminals
Unix has the concept of foreground processes
which are attached to a user's terminal
background processes, which have no terminal
to read from
![Page 58: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/58.jpg)
Job control & process management command
ps - report process status kill - terminate or signal processes
Control process execution jobs - report job status bg - bring job to background process fg - bring job to foreground process stop - stop the job
![Page 59: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/59.jpg)
Signals
Signals are a technique used to notify a process that
some condition has occurred.
Ordinary users can only send signals to their
own processes.
The command to send signal to process is “kill”. example: $ kill -signal processid
![Page 60: Introduction to Unix Operating System โดย อ. ณัฐกร เฉยศิริ](https://reader036.fdocuments.net/reader036/viewer/2022081515/56649e4f5503460f94b46603/html5/thumbnails/60.jpg)
Here are some examples:
$ sleep 100 # Wait for 100 seconds, then go back to shell ctrl-C # Kill sleep process $ sleep 100 & # Wait for 100 seconds in the background $ jobs # Show list of jobs [1] + Running sleep 100 & $ kill SIGSTOP %1 # Stop sleep process (job number 1) $ jobs [1] + Stopped (SIGSTOP) sleep 100 & $ bg %1 # Put sleep in background $ fg %1 # Bring sleep in foreground, reattached # to the terminal