Process in Linux
Process in Linux
Process in Linux
SCHOOL OF INFORMATICS
1
Contents
ACKNOWLEDGEMENT...............................................................................................................2
Process in Linux..............................................................................................................................3
Linux Process...................................................................................................................................3
Parent-Child Process relationship................................................................................................3
Package Management System.........................................................................................................7
package manager in linux:...........................................................................................................7
Apt-get commands.......................................................................................................................8
DPKG package manager................................................................................................................10
Yum package manager..................................................................................................................12
Yum commands..........................................................................................................................12
Rpm package manager...................................................................................................................13
SCHEDULING PROCESSES.......................................................................................................14
The sleep Command...................................................................................................................14
The at Command........................................................................................................................15
The cron command.....................................................................................................................15
2
ACKNOWLEDGEMENT
It is indeed with a great pleasure and immense sense of gratitude that, we acknowledge the help
of these individuals. We are highly indebted to our advisor and lecture MR Idd, for the facilities
provided to accomplish this main task.
We extremely grateful to Departmental staff members and Non-teaching staff members for their
extreme help throughout this task.
Finally we express our heartful thanks to all of our friends who helped us in successful
completion of this task.
3
Process in Linux
A process is an instance of a program running in a computer. In UNIX and some other operating
systems, a process is started when a program is initiated this can be done either by a user
entering a shell command or by another program. Process status is responsible for showing all
CPU activities on the UNIX machine.
Linux Process
When we turn on the machine the first thing to start is the Kernel (Linux Kernel) which is
responsible for starting the first process which known as Init Process. Init Process is now take
responsibilities for all other process after the Kernel start. Then the Mingetty process is started
with the job to start login shell. Bash Process take place to allow users to work with Linux
command line where by we can communicate with the system.
KernelInit ProcessMingettyBash
4
Zombie The process is in difunctional state
In Unix we have four programs that allow us to display a list of processes, the following are a
list of those commands
Ps
Pstree
Top
Htop
PS command is dealing with displaying information about all running process. The PS command
gives a snapshot of the current processes. Ps aux used in BSD style to give the list of process and
there properties and Ps ef used in system V style to do the same functions as Ps aux.
5
PStree
6
TOPScreenShoot
7
Package Management System.
Most modern Unix-like operating systems offer a centralized mechanism for finding and
installing software. Software is usually distributed in the form of packages, kept in repositories.
Working with packages is known as package management. Packages provide the basic
components of an operating system, along with shared libraries, applications, services, and
documentation.
A package management system does much more than one-time installation of software. It also
provides tools for upgrading already-installed packages. Package repositories help to ensure that
code has been vetted for use on your system, and that the installed versions of software have
been approved by developers and package maintainers.
When configuring servers or development environments, it's often necessary look beyond
official repositories. Packages in the stable release of a distribution may be out of date, especially
where new or rapidly-changing software is concerned. Nevertheless, package management is a
vital skill for system administrators and developers, and the wealth of packaged software for
major distributions is a tremendous resource.
Most package systems are built around collections of package files. A package file is usually an
archive which contains compiled binaries and other resources making up the software, along
with installation scripts. Packages also contain valuable metadata, including their dependencies,
a list of other packages required to install and run them.
apt-get is the command-line tool for working with APT software packages.
8
APT (the Advanced Packaging Tool) is an evolution of the Debian .deb software packaging
system. It is a rapid, practical, and efficient way to install packages on your system.
Dependencies are managed automatically, configuration files are maintained, and upgrades and
downgrades are handled carefully to ensure system stability.
Apt-get commands:
resynchronizes the local index of packages files, updating information about new
and updated packages that are available. The indexes are fetched from the
update location(s) specified in /etc/apt/sources.list.
installs the newest versions of all packages currently installed on the system,
using the sources in /etc/apt/sources.list. If a package is currently installed and a
new version is available, it is retrieved and upgraded. Under no circumstances
are installed packages removed, or packages not already installed retrieved. New
upgrade versions of currently installed packages that cannot be upgraded without
changing the install status of another package will be left at their current version.
An update should always be performed first so that apt-get knows which new
versions of packages are available.
The /etc/apt/sources.list file contains the list of locations from where package
files will be retrieved. See also apt_preferences for a mechanism that will
override the general settings for individual packages.
install install installs one or more packages desired for installation or upgrading.
Packages are specified by their package name, not a fully qualified file name (for
instance, in a Debian system, "apt-utils" would be the argument provided, not
9
"apt-utils_0.9.7.7ubuntu4_amd64.deb"). All packages required by the package(s)
specified for installation will also be retrieved and installed. The
/etc/apt/sources.list file is used to locate the desired packages.
Both of the version selection mechanisms can downgrade packages and must be
used with care. You don't want to manually remove a package that another
installed package is dependent on.
identical to install except that packages are removed instead of installed. Note
that removing a package leaves its configuration files on the system. If a plus
remove
sign is appended to the package name (with no intervening space), the identified
package will be installed instead of removed.
identical to remove except that packages are removed and purged (any
purge
configuration files are also deleted).
causes apt-get to fetch source packages. APT will examine the available
packages to decide which source package to fetch. It will then find and download
into the current directory the newest available version of that source package
while respecting the default release, as set with the option APT::Default-
Release, the -t option or per package with the pkg/release syntax.
Source packages are tracked separately from binary packages via deb-src lines in
the sources.list file.
If the --compile option is specified then the package will be compiled to a binary
.deb using dpkg-buildpackage for the architecture as defined by the --host-
source
architecture option. If --download-only is specified then the source package
will not be unpacked.
A specific source version can be retrieved by postfixing the source name with an
equals and then the version to fetch, similar to the mechanism used for the
package files. This enables exact matching of the source package name and
version, implicitly enabling the APT::Get::Only-Source option.
Note that source packages are not installed and tracked in the dpkg database like
binary packages; they are downloaded to the current directory, like source
tarballs.
10
causes apt-get to install/remove packages in an attempt to satisfy the build
dependencies for a source package. By default, the dependencies are satisfied to
build-dep
build the package natively. If desired a host-architecture can be specified with the
--host-architecture option instead.
a diagnostic tool; it updates the package cache and checks for broken
check
dependencies.
download downloads the given binary package into the current directory.
clears out the local repository of retrieved package files. It removes everything
but the lock file from /var/cache/apt/archives/ and
clean /var/cache/apt/archives/partial/. When APT is used as a dselect method, clean
is run automatically. If you don't use dselect you will likely want to run apt-get
clean from time to time to free up disk space.
Like clean, autoclean clears out the local repository of retrieved package files.
The difference is that it only removes package files that can no longer be
downloaded, since they are largely useless. This allows a cache to be maintained
autoclean
over a long period without it growing out of control. The configuration option
APT::Clean-Installed will prevent installed packages from being erased if it is
set to off.
11
Dpkg commands:
12
Yum package manager
YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical
based package management tool for RPM (RedHat Package Manager) based Linux systems. It
allows users and system administrator to easily install, update, remove or search software
packages on a systems. It was developed and released by Seth Vidal under GPL (General
Public License) as an open source, means anyone can allowed to download and access the code
to fix bugs and develop customized packages. YUM uses numerous third party repositories to
install packages automatically by resolving their dependencies issues.
Yum commands :
yum install <package name/s>
Used to install the latest version of a package or group of packages. If no package matches
the specified package name(s), they are assumed to be a shell glob, and any matches are
then installed.
Used to update the specified packages to the latest available version. If no package name/s
are specified, then yum will attempt to update all installed packages.
If the --obsoletes option is used (i.e. yum --obsoletes <package name/s> , yum will process
obsolete packages. As such, packages that are obsoleted across updates will be removed
and replaced accordingly.
yum check-update
This command allows you to determine whether any updates are available for your
installed packages. yum returns a list of all package updates from all repositories if any are
available.
Used to remove specified packages, along with any other packages dependent on the
packages being removed.
This command is used to find any packages containing the specified keyword in the
description, summary, packager and package name fields of RPMs in all repositories.
13
yum localinstall <absolute path to package name/s>
Used when using yum to install a package located locally in the machine.
Commands descriptions
rpm -ivh {rpm-file} nstall the package
rpm -Uvh {rpm-file} Upgrade package.
rpm -ev {package} Erase/remove/ an installed package
rpm –qa Display list all installed packages.
rpm -qi {package} Display installed information along with
package version and short description.
rpm -qc {pacakge-name} Display list of configuration file(s) for a
package.
rpm -qa –last Display list of all recently installed RPMs.
rpm -qR {package} :- Find out what dependencies a rpm file have.
14
SCHEDULING PROCESSES
Scheduling process is the allocation or ordering of a set of tasks on one or several resources or a
plan of carrying out processes at intended times. Since Linux is a multitasking operating system,
scheduling processes involve to when a processes should be executed, in what order and where.
A process scheduler do all the task that involves process scheduling. The Scheduler don’t only
initiate the processes but also decide when one process ceases running so that the other could
begin (ordering processes).
Processes on the computer could be automatic or manual meaning that there are processes that
start automatically during computer startups, this processes aid the computer in doing its works
and those of manual are the process specified (initiated) by the user by typing commands to
manipulate or do different tasks.
sleep command
at command and,
cron command.
Where the suffix could be s for seconds, m for minutes, h for hours, d for days.
Example. Say you are working in an office and you have an appointment that last for 30min, you
can use the sleep command to execute your process after 30min.
The sleep command can also be used to print even files at certain times that you are not around
and even more like logging off your computer or program.
15
The at Command
The at command could be used to run a command at a specified time. The at command can use
different words in specifying time such as noon, midnight, teatime (1600), now, today and
tomorrow.
at><EOT>
It gets information about which programs and when they should run from the system's and users'
crontab entries.
The cron command is very useful in planning process that could occur automatically for a certain
day, week or month.
The cron command has got two parts the crond that is aprocess that starts automatically to run
processes at a fixed time on regular basis when the computer is powered on and crontab which is
a command that helps the user to run or create his/her own schedule.
The crontab file located in master configuration file i.e /etc/crontab is divided into time, followed
by user and lastly the issued command. The time part is divided into minute, hour, day, month
and day of week.
In order the user to issue his own schedule. The user should use the crontab command.
16
Crontab [-u user] file
The –i option prompts the user for a yes or no response before performing a task.
e.g. say you want to provide a backup a line that points to a script
crontab -e
4 4 * * 4,7 /home/billy/bin/backup.sh
17