Linux Operating System Notes
Linux Operating System Notes
Chapter 1
Introduction
1.1
AREAS TO BE ADDRESSED:
HISTORY OF LINUX
FEATURES OF LINUX OS
PRACTICALS:
INSTALLATION
LINUX COMMANDS
SYSTEM ADMINISTRATION
1.2
HISTORY OF LINUX
1.6
UNIX OPERATONG SYSTEM
1.7
Features of Unix OS
Multi-user, multitasking operating
system
It can be used as the master control
program in workstations and servers.
Hundreds of commercial applications
are available
In its heydays, UNIX was rapidly
adopted and became the standard OS
in universities.
1.8
Features of Linux
Support multitasking
Programs consist of one or more
processes, and each process have one or
more threads
It can easily co-exists along with other
Operating systems.
It can run multiple user programs
Individual accounts are protected
because of appropriate authorization
Linux is a replica of UNIX but does not
1.9
Linux vs. Unix
1.11
Linux vs. Unix
Basis of Difference Linux Unix
Viruses Linux has had about 60- There are between 80
100 viruses listed to to 120 viruses reported
date which are currently till date in Unix.
not spreading.
Threat detection Threat detection and Unix users require
solution is very fast longer wait time, to get
because Linux is mainly the proper bug fixing
community driven. So, if patch.
any Linux user posts
any kind of threat, a
team of qualified
developers starts
working to resolve this
threat.
Architectures Initially developed for It is available on PA-
Intel's x86 hardware RISC and Itanium
processors. It is machines.
1.12 available for over
Linux vs. Unix
Basis of Difference Linux Unix
Usage Linux OS can be The UNIX operating
installed on various system is used for
types of devices like internet servers,
mobile, tablet workstations & PCs.
computers.
Versions Different Versions of Different Versions of
Linux are Redhat, Unix are HP-UX, AIS,
Ubuntu, OpenSuse, BSD, etc.
Solaris, etc.
1.14
Limitation of Linux
There's no standard edition of Linux
Linux has patchier support for drivers which
use as Windows.
Many of the programs we are using for
1.16
LINUX FILE SYSTEM
Ext2 does not have journaling feature—
check next slide
On flash drives, usb drives, ext2 is
recommended, as it doesn’t need to do
the over head of journaling.
Maximum individual file size can be from
16 GB to 2 TB
Overall ext2 file system size can be from
2 TB to 32 TB
1.17
LINUX FILE SYSTEM
1. A journaling filesystem keeps a
journal or log of the changes that are
being made to the filesystem during
disk writing that can be used to rapidly
reconstruct corruptions that may occur
due to events such a system crash or
power outage.
1.18
LINUX FILE SYSTEM
1. Ext3
Ext3 stands for third extended file
system.
It was introduced in 2001.
Developed by Stephen Tweedie.
Starting from Linux Kernel 2.4.15 ext3
was available.
The main benefit of ext3 is that it allows
journaling.
1.19
LINUX FILE SYSTEM
1. Ext3
Maximum individual file size can be
from 16 GB to 2 TB
Overall ext3 file system size can be
from 2 TB to 32 TB
1. You can convert a ext2 file system to
ext3 file system directly (without
backup/restore).
1.20
LINUX FILE SYSTEM
1. Ext4
Ext4 stands for fourth extended file
system.
It was introduced in 2008.
Starting from Linux Kernel 2.6.19 ext4
was available.
Supports huge individual file size and
overall file system size.
Maximum individual file size can be
from 16 GB to 16 TB
1.21
LINUX FILE SYSTEM
1. Ext4
Overall maximum ext4 file system size
is 1 EB (exabyte). 1 EB = 1024 PB
(petabyte). 1 PB = 1024 TB (terabyte).
Directory can contain a maximum of
64,000 subdirectories (as opposed to
32,000 in ext3)
You can also mount an existing ext3 fs
as ext4 fs (without having to upgrade
it).
1.22
LINUX FILE SYSTEM
1. Ext4
Several other new features are
introduced in ext4: multiblock
allocation, delayed allocation, journal
checksum. fast fsck, etc.
All you need to know is that these new
features have improved the
performance and reliability of the
filesystem when compared to ext3.
In ext4, you also have the option of
1.23 turning the journaling feature “off”.
LINUX DIRECTORIES
/bin
Bin is an abbreviation of Binaries. It's
just a directory where a user of an
operating system can expect to find
applications.
/boot
The /boot directory contains files
required for starting the system.
1.24
LINUX DIRECTORIES
/dev
/dev contains device files. Many of these
are generated at boot time or even on
the fly. For example, if you plug in a new
webcam or a USB pendrive into your
machine, a new device entry will
automagically pop up here.
/etc
/etc is where configuration files
and directories are located.
1.25
LINUX DIRECTORIES
/home
/home is where you will find the users'
personal directories.
/lib
/lib is where libraries live. Libraries are
files containing code that applications
can use. They contain snippets of code
that applications use to draw windows on
the desktop, control peripherals, or send
files to the hard disk.
1.26
LINUX DIRECTORIES
/media
The /media directory is where external
storage will be automatically mounted
when you plug it in and try to access it.
/mnt
The /mnt directory, however, is a bit of
remnant from days gone by. This is where
you would manually mount storage
devices or partitions. It is not used very
often nowadays.
1.27
LINUX DIRECTORIES
/proc
/proc, like /dev is a virtual directory. It
1.31
LINUX DIRECTORIES
/sys
/sys is another virtual directory
like /proc and /dev and also contains
information from devices connected to
your computer.
/tmp
/tmp contains temporary files, usually
placed there by applications that you are
running.
1.32
LINUX DIRECTORIES
/var
/var contains things like logs in
the /var/log subdirectories. Logs are files
that register events that happen on the
system.
1.33
Standard Linux filesystem hierarchy
1.34
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
FOR THIS CLASS WE WILL INSTALL
FEDORA 30 SERVER.
DUAL BOOT MEANS WE WILL LEAVE
WINDOWS OS INTACT---IN OTHER
WORDS WE WILL HAVE 2 OS IN THE
SAME HDD.
NEXT IS SCREEN SHOTS OF
INSTALLATION PROCEDURE.
1.35
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
1.36
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
1.37
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
1. On the next screen, select the language that will
be used during the installation process and hit
on Continue button.
1.38
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
1. The next screen will present you Fedora Installation
Summary menu. First, click on Keyboard menu, choose your
system keyboard layout and hit on top Done button to complete
this step and go back to main menu, as illustrated in the below
images.
1.39
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
1. Next, hit on Time and Date menu and select your region and
city from the provided map. When you finish, hit on Done button
to return to main installer menu…..THIS interface is different for
fedora 30
1.40
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
1.41
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
In this step, select the disk partition you want to resize in order to
create a new partition that will be used for installing Fedora 27 in
dual-boot with Windows 10.
To resize the partition, right-click on the desired partition and
select Edit -> Resize from the menu.
1.42
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
On the new screen prompt, use the value bar to shrink the
Windows partition to your own desired size and click
on Resize button to apply changes.
1.43
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
The free space resulted after shrinking the Windows partition will
be used for installing Fedora server. Select the free space and hit
on the + button to create a new partition.
1.44
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
On partition settings window, enter the size of the partition, select a file system type,
such as the robust ext4 file system to format the partition, add a label for this partition
and use /(root) as the mount point of this partition.
When you finish hit OK button to apply the new configuration. Use the same procedure
to create the swap partition or other partitions for your system.—this screen shot has no
swap!!!
1.45
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
After you’ve created the partitions, review partition table and press the
top Done button twice to confirm configuration and hit on Accept Changes button
from the pop-up Summary of Changes window to apply storage partition
configurations and return to main menu.
1.46
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
The next step is this: confirm your partitions before Linux proceeds to install itself!!!
1.47
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
To start the installation process, just hit on Begin Installation button, as
illustrated in the following image.
1.48
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
After the installation process starts, click on Root Password menu
from User settings window and setup a strong password for your
system root account. When you finish, hit the Done button to
apply root password and return to initial screen.
1.49
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
Configuring the root password----this is access credentials for the
root user(super admin who can access and edit the root directory
of Linux)
1.50
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
Next, click on User Creation menu, add the name of a new user
and setup a strong password for the new account. To allow root
privileges to this user, make sure you check Make this user
administrator. Also, check the box with Require a password to use
this account and hit on Done button to complete this step.
1.51
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
Wait for the installation process to finish and hit on Quit button to
complete the installation and close the window.
1.52
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
After the installation completes, eject Fedora installation media
and reboot the machine. After reboot, you will be directed to
GRUB menu, where for 5 seconds you can choose what operating
system you want the machine to boot from: Fedora or Windows.
1.53
INSTALLING FEDORA 30 SERVER(DUAL BOOT)
the Fedora 30 is now installed and the journey begins!!!!!!
1.54
DNF Command Examples for Package Management in
Fedora Linux
DNF or Dandified YUM is a fork of YUM package manager. It
was introduced in fedora 18 & on fedora 22, it has now become
default package manager for handling the RPM(Red Hat Package
Manager) packages.
DNF resolves all the problems that has been associated with yum,
like poor performance, high memory usage, slowness for
dependency resolution. DNF can be termed as the next major
version of the YUM package manager. Currently, the most stable
version of DNF is version 2.6.3
DNF is the built in utility to help you download and install
packages in fedora linux
1.56
DNF Command Examples for Package Management in
Fedora Linux
Example:3) Installing a package
Like yum, we use ‘install‘ option followed by package name with
dnf to install, Let’s suppose we want to install web server
package (httpd)
$ sudo dnf install httpd----you will see something like this after
running the command:
1.57
DNF Command Examples for Package Management in
Fedora Linux
Example:4) Removing a package
To remove a package, execute the following from terminal:
$ sudo dnf remove httpd
Or
sudo dnf erase httpd
Output of above command would be something like below:
1.58
DNF Command Examples for Package Management in
Fedora Linux
Example:5) Update a package
Run the following command to update a single package on the
system,
Syntax: dnf update {pkg-name}
$ sudo dnf update httpd
Example:6) Check for full system update
For a system wide update check, execute the following command,
$ sudo dnf check-update----you will something like this:
1.59
DNF Command Examples for Package Management in
Fedora Linux
Example:7) Upgrade all system packages
To upgrade all system packages, run the following:
$ sudo dnf upgrade---you will something like this:
1.60
DNF Command Examples for Package Management in
Fedora Linux
Example:8) List all group packages
Use the following to list all group packages:
$ sudo dnf grouplist----to see packages that are grouped together
e.g desktop packages
Example:9) Installing Group packages
Similar packages are grouped together & can be installed from
single command, rather than using separate commands. To
install a group, run:
$ sudo dnf groupinstall “Network Servers“
Example:10) Removing group packages
To remove a complete group of packages from system, run the
following dnf command,
Syntax: dnf groupremove ‘group_name’
$ sudo dnf groupremove “Network Servers"
1.61
DNF Command Examples for Package Management in
Fedora Linux
Example:11) Search for packages
To look for a particular package from the repositories, execute
Syntax: dnf search {package_name}
Let’s suppose I want to search net-tools package
$ sudo dnf search net-tools
Example:12) Download (don’t not install) a package
There can some scenarios where we require to download the
packages but don’t wish to install. Use the following command to
download package like samba
Syntax : dnf download package_name
$ sudo dnf download samba
1.62
DNF Command Examples for Package Management in
Fedora Linux
Example:13) Show all available packages
To get list of all available packages from repositories, open
terminal & run beneath dnf command
$ dnf list available | more---|(pipe)- redirection that is used
in Linux to send the output of one program to another program
for further processing.
Use ctrl + C to terminate
1.63
DNF Command Examples for Package Management in
Fedora Linux
Example:14) Show only installed packages
Now, if we only require a list of installed packages on the system,
we can get it by executing following command,
$ dnf list installed----you will something like this:
1.64
DNF Command Examples for Package Management in
Fedora Linux
Example:15) Show all installed as well as available packages
To get list of all packages i.e. installed as well as available, run
the following command
$ dnf list---you will see something like this:
1.65
DNF Command Examples for Package Management in
Fedora Linux
Example:16) Removing orphan packages
Orphan packages are those packages that were once installed to
satisfy dependency for some other package but are not required
now. To remove such packages, run:
$ sudo dnf autoremove----what happens next is like this:
1.66
DNF Command Examples for Package Management in
Fedora Linux
Example:17) Synchronize all the packages to latest stable
releases
Run the following command in order to synchronize all the
packages to latest stable releases:
$ sudo dnf distro-sync
1.67
DNF Command Examples for Package Management in
Fedora Linux
Example:18) Reinstall a package
To reinstall a package, if need be, run the following command:
$ sudo dnf reinstall postfix(Mail Transfer Agent (MTA) that can be
used to route and deliver email on aLinux system.)
Example:19) Get list of all DNF commands and options
To get a list of all the available options that can be used with
DNF, run:
$ dnf help----you will get this help:
1.68
BASIC LINUX COMMANDS
COMMAND EXPLANATION
man This command brings up the online Unix
manual. Use it on each of the commands
below.
For Example: man pwd --You will see the
manual for the pwd command.
Pwd(print Shows what directory (folder) you are in.
working In Linux, your home directory is
Directory) /home/particle
COMMAND EXPLANATION
rmdir [dirName ] Removes a directory with the name you gave
ls Lists files.
Ls- al(list all) You'll see a huge list of files that you can't see
with the 'ls' command alone and lots of details.
Cp(copy files) copies a file
Most used options are:
-r copies directories (recursively)-p preserves
permissions, ownership, and timestamps-i prompt
before overwrite-v verbose, show filenames as they are
being copied
Examples:
Makes a copy of file 'debian' and call it 'Debian'
(assuming 'Debian' is not already a directory) $ cp -i
debian Debian
Same as the previous command (the filename defaults
to be the same). $ cp -i debian /tmp
Create a directory called happy and another one called
1.70 sad. Copy the happy directory together with its contents
BASIC LINUX COMMANDS
COMMAND EXPLANATION
1.71
BASIC LINUX COMMANDS
COMMAND EXPLANATION
rm deletes a file from the filesystem, like the "del"
command in DOS.
-d, --directory unlink FILE, even if it is an empty
directory (some systems let superuser unlink non-
empty directories too)-f, --force ignore nonexistent files,
never prompt-i, --interactive prompt before any
removal-P (*BSD only) overwrite file before deletion-r, -
R, --recursive remove the contents of directories
recursively (the force option must often be used to
successfully run rm recursively)-v, --verbose
Example:
To remove a file whose name starts with a `-', for
example `-foo', use one of these commands:
$ rm -- -foo
$ rm ./-foo
1.72
BASIC LINUX COMMANDS
COMMAND EXPLANATION
touch lets you change the date on a file. Can also be used
to create a blank file.
Example:
Change directory to directory happy
Then create a blank file by:
$ Touch tuk
1.73
BASIC LINUX COMMANDS
COMMAND EXPLANATION
du Shows disk usage. Run this command
$du – h
1.74
Useful Commands to Get CPU Information on Linux
Get CPU Info Using cat Command
You can simply view the information of your system CPU by
viewing the contents of the /proc/cpuinfo file with the help of cat
command as follows:
$ cat /proc/cpuinfo
lscpu Command – Shows CPU Architecture Info
The command lscpu prints CPU architecture information
from sysfs and /proc/cpuinfo as shown below:
$ lscpu
How to find fedora 30 server kernel version-use the below
command:
cat /proc/version
To view memory usage:
Run the top command
$top
1.75
Commands for creating users
Step 1: Add the User
It’s just one simple command to add a user. In this case, we’re
adding a user called tuk:
$sudo adduser tuk---creating a new user called tuk
Now set the password for the new user “tuk”
$sudo passwd tuk----assigning a password
Step 2: Grant Root Privileges to the User
We will need to use vim editer to edit a configuration file
Vim modes
Insert Mode- The shortcut is: "i" (insert text where the cursor is)
or "o" (insert text at the beginning of the following line).
After editing the file press esc
To save-:x
To quit without saving-:q!
1.76
Commands for creating users
Run the following command to launch vim editor and make user
tuk a root user
$sudo visudo
Find the following code:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
Click i to get into insert mode
Below that line
Write:
Tuk ALL=(ALL) ALL
1.77
Get a List of All Users using the /etc/passwd File
Local user information is stored in the /etc/passwd file. Each line
in this file represents login information for one user. To open the
file you can either use cat or less:
Type the command:
$sudo cat /etc/passwd
From the output notice the following:
User name
Encrypted password (x means that the password is stored in
the /etc/shadow file)
User ID number (UID)
User’s group ID number (GID)
User home directory
Login shell (defaults to /bin/bash)
1.78
INSTALLING AND CONFIGURING SERVER
PACKAGES
In this section we will begin installing and configuring server
packages
Installing and configuring MYSQL database(mariadb)
The latest MYSQL comes as mariadb
To install the database package run the following command:
at boot.
Run the following commands:
$ mysql_secure_installation
password)
For the rest of the questions answer y for yes
When done, test access using the root user – without a password.
$ mysql -u root
1.82
INSTALLING AND CONFIGURING SERVER
PACKAGES
Verify Apache Web server
Apache ships with a default test page which you can use to verify
if Apache is ready to serve the web content. It is accessed via the
URL, http://<hostname or web-server-host-IP>. Hence, if
everything is fine, when you access the URL above via the
browser, you should land on Fedora Apache test page.
To see the IP address of the fedora server run the command:
$ ifconfig
THE TEST PAGE IS AS SHOWN NEXT
1.83
INSTALLING AND CONFIGURING SERVER
PACKAGES
1.84
ASSIGNMENT 1
INSTALL AND CONFIGURE SAMBA
SERVER PACKAGE
ACCESS IT USING YOUR WINDOWS
MACHINE.
LET ME HAVE THE SCREEN SHOT AS
EVIDENCE
Write the commands you have used to
install and configure samba package
MARKS=20
1.85
Installing and configuring
phpMyAdmin
Before phpMyAdmin is installed the
following must be installed:
Php-installed together with apache
To check the php version run this
command:
$php –v
1.86
Installing and configuring
phpMyAdmin
We will need to configure timezone in
the php configuration file by using
vim editor
This is the command:
Sudo vi /etc/php.ini
Look for this line and set the zone as
shown:
date.timezone = Africa/Nairobi
1.87
Installing and configuring
phpMyAdmin
Install and configure phpMyAdmin on
Fedora 30 server
Run this command to download and
install phpMyAdmin:
$ sudo dnf -y install phpMyAdmin
To check the version of installed
phpMyAdmin run this command:
$ rpm -qi phpMyAdmin
1.88
Installing and configuring
phpMyAdmin
Limit access to phpMyAdmin to your
only trusted networks
Run ifconfig command to check your
network address
Then use vim editor to edit this file:
$ sudo vi
/etc/httpd/conf.d/phpMyAdmin.conf
Edit the Require ip lines – both on
Line 17 and 34 of the file.
1.89
Installing and configuring
phpMyAdmin
Require ip 127.0.0.1 [192.168.18.0/24]-
classful ip of the address to access the
server
Save the changes and restart httpd
service:
$ sudo systemctl restart httpd
Step 3: Access phpMyAdmin interface
Access [http://(your hostname or IP
address)/phpmyadmin/] from your
favorite web browser and network
whitelisted.
1.90
Installing and configuring
phpMyAdmin
You will see such a log in window
1.91
Installing and configuring sendmail
Sendmail is a general purpose email
routing facility used for email transport
over the Internet.
It includes SMTP (Simple Mail Transfer
Protocol) for the mail-transfer and email
delivery. Most of the system
administrators preferred to use Sendmail
server as MTA than other MTAs. You can
also use Sendmail server to send
the email via external SMTPservers like
Gmail, Amazon SES, MailChimp etc.
1.92
Installing and configuring sendmail
Install Sendmail
use the following command to install
Sendmail with other required
packages using yum package
manager:
$ sudo dnf install sendmail sendmail-
cf
1.93
Installing and configuring sendmail
Configure Sendmail on Fedora 30
server
Before starting configuration you
must know about various Sendmail
configuration files that exist in
/etc/mail directory:
access — Allow/Deny other systems
to use Sendmail for outbound emails.
domaintable — Used for domain
name mapping for Sendmail.
1.94
Installing and configuring sendmail
local-host-names — Used to define
aliases for the host.
mailertable — Defined the
instructions that override routing for
particular domains.
virtusertable — Specifies a domain-
specific form of aliasing, allowing
multiple virtual domains to be hosted
on one machine.
1.95
Installing and configuring sendmail
Comment out below line
in /etc/mail/sendmail.mc to allow
receiving email from anywhere.
To comment a line in sendmail.mc,
just put dnl at start of line.
To open the file issue this command:
$sudo vi /etc/mail/sendmail.mc
dnlDAEMON_OPTIONS(`Port=smtp,Ad
dr=127.0.0.1, Name=MTA')dnl
1.96
Installing and configuring sendmail
Add this line also in sendmail.mc
above ‘MAILER’ option
FEATURE(`relay_hosts_only')dnl
The above feature ensures that your
MTA does not become an open relay
to all other hosts within your DNS
domain
Restart Sendmail service
$ sudo systemctl restart sendmail
1.97
Installing and configuring sendmail
test the sendmail:
You have to be a root user to do
this:
To change to root user:
Su –
Then run this command and
check your email address inbox
or spam folder:
#sendmail –s “test mail”
[email protected] </dev/null
1.98
Installing and configuring sendmail
test the sendmail:
You may create a file with email
content:
In your home directory create this
file by using this command:
$ vi email.txt
Once open in the vim editor> click i
to insert text into the file
Subject: Terminal Email send
This is a test email from my sendmail
Just learning the process!
1.99
Installing and configuring sendmail
switch user to root by command
Su –
Then send the test mail by
issuing this command:
#sendmail [email protected]
< /home/dkanyi/email.txt
Check your inbox/spam
1.100
Assignment 2- (30 marks)
install and configure postfix MTA.
Let me have a screen shot of the
configuration and installation
Send yourself a test email and
let me have a screen shot of the
sent email from your inbox
1.101
Assignment 3- (30 marks)
we have used CLI-command line
interface for our fedora 30 server
practical classes.
I need you to install GNOME
desktop Environment.
Launch the Fedora GNOME
desktop(GUI)
Let me have a screen shot of
your desktop as evidence
1.102
Assignment 4- (20 marks)
Attach a USB drive to the machine
bearing fedora 30.
From your putty mount and
access your usb drive
Let me have the screen shots
This is the final assignment
Please note all assignments
amount to 100%
1.103
END OF COURSE
THANK YOU
HOPE YOU LEARNT AND ENJOYED
1.104