Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Process in Linux

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

THE UNIVERSITY OF DODOMA

SCHOOL OF INFORMATICS

COLLEGE OF INFORMATICS AND VIRTUAL EDUCATION

COURSE NAME: LINUX/UNIX SYSTEMS ADMINISTRATION AND


MANAGEMENT

COURSE CODE: CS 214

COURSE INSTRUCTOR: MR. IDD

NAME OF STUDENT REGISTRATION NUMBER

NELSON LUZIGA T/UDOM/2016/06671

AMBELE MBIJE T/UDOM/2016/07977

MOSES SANINGA T/UDOM/2016/05890

JOSHUA SYLIAKUS T/UDOM/2016/05861

MASULE YAYI T/UDOM/2016/05876

IHANO MAHAMBO T/UDOM/2016/05889

JOSEPHAT PAUL T/UDOM/2016/05863

GWAKISA FABIANO MINGA T/UDOM/2016/07711

GODLOVE NGOWI T/UDOM/2016/05867

RAYMOND MKINDO T/UDOM/2016/05862

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.

KernelInit ProcessMingettyBash

Parent-Child Process relationship


In Linux Process management there is Parent-Child relationship.
Every process except process is created when another process executes the fork system call.
The process that invoked fork is the parent process and the newly-created process is the child
process. Every process has one parent process, but can have many child processes.
The operating system kernel identifies each process by its process identifier. Process 0 is a
special process that is created when the system boots, after forking a child process process 0
becomes the swapper process. Process 1, known as Init, is the ancestor of every other process in
the system.
A child process in computing is a process created by another process (the parent process).
A child process inherits most of its attributes, such as open files, from its parent. In UNIX, a
child process is in fact created (using fork) as a copy of the parent. The child process can then
overlay itself with a different program as required.
From Parent and Child Process we can have different Process State such as Runnable, Sleep,
Suspended and Zombie Process.

Runnable Active Process


Sleep Process load in memory but hasn’t been active recently
Stopped Process stopped and about to be removed from the computer Memory

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.

Ps aux Ps aux command has three main options


 a-make sure all process is shown
 u-extended usage information
 x-what user process is stated and from
which tty

PS aux -Scree Shoot

5
PStree

6
TOPScreenShoot

Htop Screen Shoot

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.

package manager in linux:


Common Terminal Management Apps Extension
apt-get .deb
Dpkg .deb
Rpm .rpm
Yum .rpm

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.

An update should always be performed before an upgrade or dist-upgrade.

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.

in addition to performing the function of upgrade, dist-upgrade also intelligently


handles changing dependencies with new versions of packages; apt-get has a
"smart" conflict resolution system, and it will attempt to upgrade the most
important packages at the expense of less important ones if necessary.
dist-upgrade
The dist-upgrade command may therefore remove some packages.

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.

used in conjunction with the traditional Debian packaging front-end, dselect.


dselect-upgrade follows the changes made by dselect to the Status field of
dselect-upgrade
available packages, and performs the actions necessary to achieve that state (for
instance, the removal of old and the installation of new 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.

A specific version of a package can be selected for installation by following the


package name with an equals and the version of the package to select. This will
cause that specific version to be located and installed. Alternatively, a specific
distribution can be selected by following the package name with a slash and the
version of the distribution or the Archive name ("stable", "testing", "unstable").

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.

autoremove is used to remove packages that were automatically installed to


autoremove
satisfy dependencies for other packages and are now no longer needed.

downloads a package changelog and displays it through sensible-pager. The


server name and base directory is defined in the APT::Changelogs::Server
changelog
variable. By default, it displays the changelog for the version that is installed.
However, you can specify the same options as for the install command.

DPKG package manager


dpkg is the software at the base of the package management system in the free operating system
Debian and its numerous derivatives. dpkg is used to install, remove, and provide information
about .deb packages.
The Debian package "dpkg" provides the dpkg program, as well as several other programs
necessary for run-time functioning of the packaging system, including dpkg-deb, dpkg-split,
dpkg-query, dpkg-statoverride, dpkg-divert and dpkg-trigger.It also includes the programs such
as update-alternatives and start-stop-daemon. The install-info program used to be included as
well, but was later removedas it is now developed and distributed separately.

11
Dpkg commands:

Syntax Description Example


dpkg -i {.deb package} Install the package dpkg -i zip_2.31-3_i386.deb
Upgrade package if it is
dpkg -i {.deb package} installed else install a fresh copy dpkg -i zip_2.31-3_i386.deb
of package
Install all packages recursively
dpkg -R {Directory-name} dpkg -R /tmp/downloads
from directory
Remove/Delete an installed
dpkg -r {package} package except configuration dpkg -r zip
files
Remove/Delete everything
dpkg -P {package} dpkg -P apache-perl
including configuration files
dpkg -l
List all installed packages,
dokg -l | less
dpkg -l along with package version and
dpkg -l '*apache*'
short description
dpkg -l | grep -i 'sudo'
List individual installed
dpkg -l {package} packages, along with package dpkg -l apache-perl
version and short description
Find out files are provided by
dpkg -L apache-perl
dpkg -L {package} the installed package i.e. list
dpkg -L perl
where files were installed
List files provided (or owned)
by the package i.e. List all files
dpkg -c {.Deb package} inside debian .deb package file, dpkg -c dc_1.06-19_i386.deb
very useful to find where files
would be installed
Find what package owns the file
dpkg -S /bin/netstat
dpkg -S {/path/to/file} i.e. find out what package does
dpkg -S /sbin/ippool
file belong
Display details about package
package group, version,
dpkg -p {package} maintainer, Architecture, dpkg -p lsof
display depends packages,
description etc
Find out if Debian package is
dpkg -s {package} | grep Status dpkg -s lsof | grep Status
installed or not (status)

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.

yum update <package name/s>

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.

yum remove <package name/s>

Used to remove specified packages, along with any other packages dependent on the
packages being removed.

yum provides <file name>

Used to determine which packages provide a specific file or feature.

yum search <keyword>

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.

Rpm package manager


RPM Package Manager (RPM) (originally Red Hat Package Manager; now a recursive acronym)
is a package management system.[The name RPM refers to the following: the .rpm file format,
files in the .rpm file format, software packaged in such files, and the package manager program
itself. RPM was intended primarily for Linux distributions; the file format is the baseline
package format of the Linux Standard Base.

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.

Some of the Commands that support process scheduling are:

sleep command

at command and,

cron command.

The sleep Command


The sleep command is used to halt a script or the execution of a program for a certain time. The
time provided in sleep command is in seconds by default.

Syntax: sleep NUMBER [SUFFIX]

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.

Sleep 30m; echo “hello”;

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.

e.g : root@nelly:#at 3pm tomorrow

warning: commands will be executed using /bin/sh

at>echo “hello Friend”

at><EOT>

job 1 at Sun Feb 1 15:00:00 2018

The cron command


The cron daemon lets you execute the scheduled commands. It reads from configuration file
/etc/crontab.

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.

The synopsis of crontab is given as:

16
Crontab [-u user] file

Crontab [-u user] [ -i ] { -e | -l | -r}

The –e option allows you to edit the current crontab file.

The –i option prompts the user for a yes or no response before performing a task.

The –r option causes the current crontab to be deleted.

The –l option display the current crontab in standard output.

e.g. say you want to provide a backup a line that points to a script

crontab -e

45 15 * * 3 mails -s "sports evening" Billy

4 4 * * 4,7 /home/billy/bin/backup.sh

<--write and quit-->

crontab: installing new crontab

17

You might also like