0% found this document useful (0 votes)
23 views90 pages

Linux (Linux+ Preparation) Study Guide

This document is a study guide for a Linux module as part of a Diploma in Information Technology at Damelin, detailing the course structure, learning outcomes, and assessment methods. It emphasizes a learning-centered approach that promotes active engagement and collaboration among students. The guide includes prescribed readings, multimedia resources, and a weekly breakdown of topics to be covered throughout the semester.

Uploaded by

thembi malinga
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)
23 views90 pages

Linux (Linux+ Preparation) Study Guide

This document is a study guide for a Linux module as part of a Diploma in Information Technology at Damelin, detailing the course structure, learning outcomes, and assessment methods. It emphasizes a learning-centered approach that promotes active engagement and collaboration among students. The guide includes prescribed readings, multimedia resources, and a weekly breakdown of topics to be covered throughout the semester.

Uploaded by

thembi malinga
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

22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Linux (Linux+ Preparation)

Linux
STUDY GUIDE
2022

1
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Version Issue Date Changes


22 September
[1.0] Set-up of proposal document
2020

Copyright © Educor 2022


All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any
form or by any means, including photocopying, recording, or other electronic or mechanical
methods, without the prior written permission of Educor Holdings. Individual’s found guilty of
copywriting will be prosecuted and will be held liable for damages.

2
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Table of Contents
1 About Damelin ................................................................................................................................ 5
2 Our Teaching and Learning Methodology ...................................................................................... 5
2.1 Icons ........................................................................................................................................ 7
3 Introduction to the Module .......................................................................................................... 10
3.1 Module Information .............................................................................................................. 10
3.2 Module Purpose .................................................................................................................... 10
3.3 Outcomes .............................................................................................................................. 10
3.4 Assessment ........................................................................................................................... 10
3.5 Planning Your Studies / Basic understanding of PC operating systems:............................... 11
4 Prescribed Reading ....................................................................................................................... 11
4.1 Prescribed Book .................................................................................................................... 11
4.2 Recommended Articles ......................................................................................................... 11
4.3 Recommended Multimedia .................................................................................................. 11
5 ......................................................................................................... Error! Bookmark not defined.
5.1 Introduction to Linux ............................................................................................................ 15
5.1.1 Operating Systems ........................................................................................................ 16
5.1.2 Versions of the Linux Operating System ....................................................................... 18
5.1.3 Identifying Kernel Versions ........................................................................................... 20
5.1.4 Licensing Linux .............................................................................................................. 23
5.2 Linux Installation .................................................................................................................. 24
5.2.1 Installing Linux .............................................................................................................. 25
5.2.2 Preparing for Installation .............................................................................................. 31
5.2.3 Understanding Installation Media ................................................................................ 34
5.3 Exploring Linux Filesystems ................................................................................................. 35
5.3.1 Understand and navigate the Linux directory structure using relative
and absolute pathnames .............................................................................................................. 36
5.3.2 Describe the various types of Linux files ....................................................................... 45
5.3.3 View filenames and file types ....................................................................................... 50
5.4 Linux Filesystem Management ............................................................................................ 51
5.4.1 Find files and directories on the filesystem .................................................................. 52
5.4.2 Understand and create linked files ............................................................................... 55
5.4.3 Explain the function of the Filesystem Hierarchy Standard.......................................... 60

3
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

5.5 Linux Filesystem Administration.......................................................................................... 61


5.5.1 Identify the structure and types of device files in the /dev directory .......................... 62
5.5.2 Understand common filesystem types and their features ........................................... 65
5.5.3 Mount and unmount filesystems to and from the Linux directory tree ....................... 69
5.6 Linux Server Deployment ..................................................................................................... 70
5.6.1 Identify the types of hardware present in most server systems .................................. 71
5.6.2 Describe the configuration of SCSI devices and SANs................................................... 75
5.6.3 Explain the different levels of RAID and types of RAID configurations ........................ 77
5.7 Working with the BASH Shell ............................................................................................... 78
5.7.1 Redirect the input and output of a command .............................................................. 79
5.7.2 Identify and manipulate common shell environment variables ................................... 81
5.7.3 Create and export new shell variables .......................................................................... 84
5.2.4 Self-Assessment ............................................................................................................ 86
6 References .................................................................................................................................... 88

4
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

About Damelin

Our Teaching and Learning Methodology


Damelin strives to promote a learning-centred and knowledge-based teaching and learning
environment. Teaching and learning activities primarily take place within academic programmes and
guide students to attain specific outcomes.

• A learning-centred approach is one in which not only lecturers and students, but all
sections and activities of the institution work together in establishing a learning
community that promotes a deepening of insight and a broadening of perspective with
regard to learning and the application thereof.
• An outcomes-oriented approach implies that the following categories of outcomes are
embodied in the academic programmes:
• Culminating outcomes that are generic with specific reference to the critical cross-field
outcomes including problem identification and problem-solving, co-operation, self-
organisation and self-management, research skills, communication skills,
entrepreneurship and the application of science and technology.
• Empowering outcomes that are specific, i.e. the context specific competencies students
must master within specific learning areas and at specific levels before they exit or move
to a next level.
• Discrete outcomes of community service learning to cultivate discipline-appropriate
competencies.

Damelin actively strives to promote a research culture within which a critical-analytical approach and
competencies can be developed in students at undergraduate level. Damelin accepts that students’
learning is influenced by a number of factors, including their previous educational experience, their
cultural background, their perceptions of particular learning tasks and assessments, as well as
discipline contexts.

Students learn better when they are actively engaged in their learning rather than when they are
passive recipients of transmitted information and/or knowledge. A learning-oriented culture that
acknowledges individual student learning styles and diversity and focuses on active learning and
student engagement, with the objective of achieving deep learning outcomes and preparing students
for lifelong learning, is seen as the ideal. These principles are supported through the use of an engaged
learning approach that involves interactive, reflective, cooperative, experiential, creative or
constructive learning, as well as conceptual learning via online-based tools.

Effective teaching-learning approaches are supported by:

• Well-designed and active learning tasks or opportunities to encourage a deep rather than
a surface approach to learning.
• Content integration that entails the construction, contextualization and application of
knowledge, principles and theories rather than the memorisation and reproduction of
information.
• Learning that involves students building knowledge by constructing meaning for
themselves.

5
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

• The ability to apply what has been learnt in one context to another context or problem.
• Knowledge acquisition at a higher level that requires self-insight, self-regulation and self-
evaluation during the learning process.
• Collaborative learning in which students work together to reach a shared goal and
contribute to one another’s learning at a distance.
• Community service learning that leads to collaborative and mutual acquisition of
competencies in order to ensure cross cultural interaction and societal development.
• Provision of resources such as information technology and digital library facilities of a high
quality to support an engaged teaching-learning approach.
• A commitment to give effect teaching-learning in innovative ways and the fostering of
digital literacy.
• Establishing a culture of learning as an overarching and cohesive factor within institutional
diversity.
• Teaching and learning that reflect the reality of diversity.
• Taking multi culturality into account in a responsible manner that seeks to foster an
appreciation of diversity, build mutual respect and promote cross-cultural learning
experiences that encourage students to display insight into and appreciation of
differences.

6
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

1.1 Icons
The icons below act as markers, that will help you make your way through the study guide.

Additional Information
All supplementary and recommended learning resources

Announcements
Important announcements made via myClass

Assessments
Continuous and Summative Assessments

Audio Material
Audio recordings and podcasts

Calculator
Activities that require calculation and equation base solutions

Case Study
Working examples of concepts and practices

Chat
A live chat with your Online Academic Tutor

Discussion Forum
Topic to be explored in the weekly discussion forum

Glossary
Learning activity centered on building a module glossary

7
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Group Assignment
Assignments to be completed with peers

Help
Instructions on how to receive academic support and guidance

Individual Assignment
Assignments to be completed individually

Lesson Material
Learning content in myClass as per the weeks below

Module Information
Important information regarding your module like outcomes, credits,
assessment, and textbooks

Module Welcome
A welcome to the module in myClass to introduce you to the module and
important module information

Outcomes
Learning outcomes you will meet at the end of a section or module

Survey
A poll, feedback form or survey to complete

Practice
Indicates an activity for you to practice what you’ve learnt

Lesson/Virtual Class
Virtual Class links available via myClass

8
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Quote
A thought, quote or important statement from a thought leader in the
specialist field

Reading
Prescribed reading material and module textbooks

Revision
Questions and activities that will support your module revision

Self-Assessment Quiz
Weekly quizzes to complete to self-measure if you have a complete
understanding of the lesson material

Shout Out | Example


Examples and highlights to contextualise the learning material, critical
concepts and processes

Lesson Material
Indicates sections of learning material in myClass

Thinking Point
A question, problem or example posed to you for deeper thinking,
interrogation, and reflection

Time
The allocated time required per week, week and module related to the
module credit structure as per your factsheet

Video
Additional videos, video tutorials, desktop capture/screen recording and
other audiovisual supplementary material

Vocabulary
Important words and their definitions that aid the development of your
specialist vocabulary

9
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Introduction to the Module


Welcome to Linux

Linux—an operating system whose rapid growth has shocked the world by demonstrating the nature
and power of the open source model. Linux continues to grow, so must the number of Linux-
educated users, administrators, developers, and advocates. We now find ourselves in a time in
which Linux education is of great importance to the information technology industry.

1.2 Module Information


Qualification title Diploma in Information Technology

Module Title Linux (Linux+ Preparation)

NQF Level 6

Credits 15

Notional hours 150

1.3 Module Purpose


This book is intended for those who want to learn the Linux operating system, it gives a general
understanding and in-depth knowledge of the functionality of the operating system.

1.4 Outcomes
At the end of this module you should be able to:

Understand and install the Linux operating system.

Use and manipulate the operating system

1.5 Assessment
You will be required to complete both formative and summative assessment activities.

Formative assessment:

These are activities you will do as you make your way through the course. They are designed to help
you learn about the concepts, theories and models in this module. This could be through case studies,
practice activities, self-check activities, study group / online forum discussions and think points.
You may also be asked to blog / post your responses online.

Summative assessment:

10
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

These are activities you will do as you make your way through the course. They are designed to help
you learn about the concepts, theories and models in this module. This could be through case studies,
practice activities, self-check activities, study group / online forum discussions and think points. You
may also be asked to blog / post your responses online. You are required to do two individual
assignments, online multiple choice questions and an online exam.

Mark allocation

The marks are derived as follows for this module:

Individual Assignment 1 20

Individual Assignment 2 20

Online Multiple Choice Questions 10

Online Exam 50

TOTAL

1.6 Planning Your Studies / Resources Required for this Module:

What equipment will I need? • Access to a personal computer and internet.


• Access to academic journals

Prescribed Reading

1.7 Prescribed Book


Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification, 5th edition. ISBN:
9781337569798

1.8 Recommended Articles


Please refer to the additional resources that are mentioned throughout the various weeks.

1.9 Recommended Multimedia


Please refer to the video resources that are mentioned throughout the various weeks.

11
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

NAME OF TOPIC FOR THE WEEK AS PER THIS GUIDE AND REFLECTIVE OF LMS

Weeks WEEKLY TOPICS FOR THE SEMESTER


2022

1
Introduction to Linux

2 Linux Installation

3 Linux Installation

4 Exploring Linux Filesystems

5 Exploring Linux Filesystems

6 Linux Filesystem Management

7 Linux Filesystem Management

8 Linux Filesystem Administration

9 Linux Filesystem Administration

10 Linux Server Deployment

11 Linux Server Deployment

12 Working with the BASH Shell

13 Working with the BASH Shell

Exam
Week

Each Week should be thought of as a “week of content”. If the week is larger, it can be split over two
weeks but we should see that a week is a capsule or episode of learning that can have “consolidating”
learning activities. As such, each “week” will be required to have a prescribed amount of learning
activities and engagements. These are to be embedded within each week and not to be listed at the
end of the week. PLEASE SEE THE EXAMPLE OF WEEK CONTENT.

12
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Prescribed Learning Activities and Engagements:

Video Content At least ONE video resource to be in each subsection of content. This
is be embedded within the content at the appropriate time as per the
learning design.
Podcast At least ONE podcast to be in each week.
The podcast must be seen as supplementary to the learning content
and if a podcast is not available on the specific topics at hand, an
adjunct concept/topic can be used that will broaden the general area
knowledge of the subject matter for the student.
Podcasts should not be selected that are only available on
streaming websites that require a subscription.
Thinking Point At least ONE thinking point should be used within each subsection of
content as a way to pause the movement through content and to
provide the chance for the student to think and concretize their
learning or what they have just read. A thinking point may be a
hypothetical, a personal reflection or a question regarding the
content within a different context (application). A thinking point
must be thorough and engaging enough to draw pause and focus
from the student.
Case Studies A case study should be within each week and can be used in any
relevant subsection of content. The case study should be robust
enough for the student to understand how to apply something or to
see how a function/tool/theory or practice may work in a real world
environment. A case study should be seen as a way for the student
to be reflected in the learning experience and as such, it is advised
that case studies are selected from local/afrocentric contexts and
illustrate our commitment to intersectionality within our teaching
and learning approach and philosophy.
Discussion Forum Each week of study/each week will require at least ONE discussion
forum topics. This can either be embedded within a certain section
of content or it can be at the end of the week content depending on
the requirements of the module as per the subject matter. The
discussion forum topic/question should robust and dense enough for
the student to be engaged and a reference must be made to the fact
that the Discussion Forum topic is live and available within the
module page on myClass.
Example/Practice These are to be used within each section that deals with applied
learning – the application of a process, technique, equation or
function. The example is to be used when an example of a problem
and a solution is provided and the practice is to be used when a
problem is provided for the student to solve.
Vocabulary Vocabulary is to be used within each subsection of content where an
important word, term or definition is provided that students are to
take note of.

13
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Glossary The glossary is an LMS activity function and can be inserted into a
guide where the development of a glossary is required and necessary
for the module. This is to be used mainly within NQF 5 modules as it
speaks to the specific level descriptors of that module.
Additional Resource Each subsection of content must have at least THREE additional
resources. These can be supplementary articles and journals,
mixed/multimedia content such as a respected blog, social media
account, news site, music video or audio recording. The additional
resource must be provided by the study guide author if it is an
“attachment” that will require loading into the LMS.
Prescribed Reading Each subsection must refer to a page, section or chapter in the
prescribed reading for the module. The prescribed reading should
indicate to the student where to locate the texts from which the
subsection has been summarised or written. This may be placed at
the start of the subsection, or at the appropriate point where a
student must leave the study guide/lms and read through a text
section in the prescribed reading.
Quote Each subsection of content should have at least ONE quote that is
from a thought leader in the field, or contextualises a section of
learning for the student. The quote must not be inserted as a graphic
but as plan text with the appropriate graphic alongside it.
Self-Assessment Quiz Each week/week will have a self-assessment quiz for the student.
Within the study guide, the author can refer to the self-assessment
as per the below but must stress that the self-assessment will be live
in the module myClass page for completion.
Referencing

14
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

The Linux Operating System


Linux technical expertise is essential in today’s computer workplace as more
and more companies switch to Linux to meet their computing needs. Thus, it
Purpose
is important to understand how Linux can be used, what benefits Linux offers
to a company, and how Linux has developed and continues to develop.

By the end of this unit, you will be able to:


Learning • Explain the purpose of an operating system
Outcomes • Outline the key features of the Linux operating system
• Describe the origins of the Linux operating systems

Time 150

Android

application (app)

Key Terms artistic license

asymmetric encryption

authentication

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

Section 1

Section 2

Section 3

Section 4

Section

15
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Introduction to Linux

Linux (pronounced "lih-nucks") is an operating system that you use to run


applications a variety of Computing hardware. Similar to other operating
systems, Linux is loaded into the computer Memory when you first turn on your
computer and initialize (or activate) all hardware components. Then it loads the
programs that display the interface. In the user interface, you can run
commands that inform the operating system and other applications to perform
specific tasks. The operating system then uses the Computer hardware to
perform tasks required by applications. Linux can handle thousands of tasks at
once, including allowing multiple users to access the system at the same time.
Therefore, Linux is called Multi-user and multitasking operating system.

Let’s Watch!

Let’s Think!

Quote

1.9.1 Subsection of unit content

16
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Reading

Linux operating system versions

The main component of the Linux operating system is called the Linux kernel.
The Linux kernel and supporting software (called function libraries) are almost
written completely in C programming language, one of the most popular
languages that software developers use when creating programs. While you can
use a variety of software to change the look and feel of Linux, the underlying
kernel is common to all types of Linux. The Linux kernel was developed
continuously; thus, you should understand the version numbers of the Linux
kernel to decide which kernel version is appropriate for your needs. Because the
Linux kernel is directly responsible for controlling the computer’s hardware (via
device drivers), you might sometimes need to upgrade the kernel after installing
Linux to take advantage of new technologies or to fix problems (also known as
bugs) related to your computer’s hardware. Consequently, you need a good
understanding of your system’s hardware to decide which kernel to use.

In some cases, you can use updates in the form of a kernel module or kernel
Patch to deploy or repair kernel supported hardware. Kernel modules and
kernels Fixes are covered later in this book.
Identify the kernel versions
Linux kernel types ( versions ) consist of the following three components:

• Main number
• Minor number
• Revision number
Let's look at an example Linux kernel type, 4.17.6. In this example, Major
Number is the number 4 indicating the major type of the Linux kernel. This The
minor number, represented by the number 17, indicates the minor type of the
Linux kernel. As new features are added to the Linux kernel, the miner number

17
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

is increased. The main number is usually incremented when a main number is


used Core functionality will be implemented when the number of minor releases
peaks number or to designate a major event; For example, kernel 3.0 was
introduced Commemoration of the twentieth anniversary of Linux. Changes to
the Linux kernel are frequent. Much minor changes are represented by a
revision number indicating the most recent changes to the specific type kernel
being released. For example, a 4.17.6 kernel has revision number 6. This kernel
is the sixth type of the 4.17 kernel. Some kernels have more than 100 revisions
due to developers constantly making improvements to the kernel code.
Modern Linux kernels are referenced with major, minor, and revision numbers
as production kernels; have been thoroughly tested by various Linux developers
and are declared stable. Development kernels are not fully tested and involve:
instability; they are tested for vulnerabilities by people who develop Linux
software. Most development kernels add the minor number with the letters -rc
(release candidate) followed by a number indicating the developmental version
kernel. For example, the 4.18-rc3 development kernel is the third release
candidate for:
kernel 4.18; if the Linux developers declare it stable after it has been thoroughly
tested, it will too become the production kernel 4.18.0

18
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Linux license

Businesses often choose Linux as their operating system because of the rules
Linux licensing governs. Unlike most other operating systems, Linux is free
developed and continually improved by a large community of software
developers. For this reason, it is called Open Source Software (OSS) To
understand OSS, you must first understand how the source code is used to
create programs. Source code refers to the list of instructions written by a
software developer to set up a program; sample source code is shown in Figure
1-3.

Once the software creator has written the instructions, the syntax is there
compiled into a format (called machine language) that only your computer's
processor uses understand and perform. To edit an existing program, the
software creator must Modify the syntax and recompile it The format and
structure of the syntax follow certain rules defined by the programming
language in which it was written. Programmers write Linux sources Code in

19
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

many programming languages. After compiling in machine language all


programs look the same for the computer's operating system, regardless of the
programming language in which they are written. As a result, software creators
choose a programming language to create syntax based on ease of use,
functionality and comfort level. The fact that Linux is an OSS operating system
means software creators can read other creators' syntax, modify that syntax to
create software better and redistribute that syntax to other creators who could
improve it further. Like all OSS, Linux syntax should be distributed for free
regardless: the number of changes made. People who develop OSS often use
the Internet to share your syntax, manage software projects and send
comments and bug fixes (errors). In this way, the Internet acts as the glue that
binds them together Linux creators in particular and OSS creators in general.
Here are some implications of the OSS way of developing software:

• The software is developed rapidly through widespread collaboration.


• Software bugs (errors) are detected and fixed quickly.
• Software capabilities evolve rapidly, based on user needs.
• The perceived value of software increases because it is based on usability
and not on the price
As you can imagine, sharing ideas and syntax is beneficial for the software
creators. However, a software company's business model changes dramatically
when: OSS enters the scene. The main problem is this: how can a product be
distributed? Does it generate income freely? After all, without income any
business will fail. The OSS software development process was never designed to
generate revenue straight away. The goal was to help people design better
software through many of the problems associated with traditional software
development, typically caused by: predefined business plans and close
programs. On the contrary, the development of OSS presupposes: that making
software is an art in which a certain problem can be solved in many cases ways.
A software developer could create a program that measures widgets using four
syntax pages, while another developer can create a program that same activity
on a syntax page. One might think this opening up to many ways to solve a
problem would result in a random software development process, but the
sharing of ideas, which is at the heart of OSS development, keeps creators
focused on the best possible solutions. Furthermore, while OSS creators

20
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

contribute their strengths to project, they learn new techniques from other
creators at the same time. Because selling software for profit discourages free
sharing of the asset the code generates OSS revenue indirectly. Businesses
usually make money by selling computer hardware running OSS, selling OSS
customer support or through closed source software programs that run on open
source products such as Linux. The OSS development process is obviously not
the only way to develop and licensing software.
Table 1-2 lists the types of software you are likely to use: These types are
explained in more detail in the next section

Types of open source licenses

Linux adheres to the GNU General Public License (GPL) developed by the Free
Software Foundation (FSF). The GPL requires that the syntax of any software
released under its license must be freely available. In case someone changes it
syntax, such person shall also freely redistribute and retain such syntax free
forever Another type of open source license is the artistic license which provides
this The program's syntax is freely available, but allows the original author of the
syntax to have some control over the changes made to it. So if a developer gets
and improves the syntax of a program, the original author has the right to refuse
these improvements. Due to this limitation, artistic licenses are rarely used
because many creators don't want to work on potentially useless projects. In
addition to the two open source licenses mentioned, there are other types of
open source licenses Source licenses that differ only slightly from each other.
These licenses must be respected of the Open Source Definition, but may

21
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

contain additional terms that do not incorporate the Open Source Terms
definition.

Closed Source License Types

Closed source software can be distributed for free or for a fee; however, the
syntax for the software is not available from the original developers. The
majority of closed source software is sold commercially and bears the
manufacturer's label. Each of these software packages may include a separate
license which is provided free of charge distribution of the program and syntax
in many ways. Another type of closed-source software is freeware, where
software is distributed free of charge, but the syntax is not available. The free
software could also contain licenses restricting syntax distribution. Another
approach to this The closed-source license type is shareware, which has so far
been distributed for free after a certain number of hours of use or to obtain
certain functions of the program, Payment Required. Although freeware and
shareware are generally not distributed Some people mistakenly refer to their
syntax under an open source license Freeware like OSS, provided the syntax is
also free.

Let’s Watch!

Let’s Think! For a complete list of kernels, kernel versions, and their
improvements, see [Link].

Quote

1.9.2 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment. (In myClass)

22
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

The Self-Assessment for this unit is embedded within your Linux module in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

1.9.3 Revision Questions

23
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Linux Installation
This chapter explores the concepts and procedures needed to install a Fedora
Linux system. The latter half of the chapter presents an overview of the

Purpose various components that you will use when interacting with the operating
system, as well as how to enter basic shell commands, obtain help, and
properly shut down the Linux system.

By the end of this unit, you will be able to:


Learning • Prepare for and install Fedora Linux using good practices
Outcomes • Outline the structure of the Linux interface
• Enter basic shell commands and find command documentation

Time 150

Advanced Technology

Attachment (ATA)

Key Terms arguments

B-tree Filesystem (BTRFS)

BASH shell

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

Section 1

Section 2

Section 3

Section 4

Section

24
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Let’s Think! Note: Turning on a computer to load an operating system is


commonly referred to as booting a computer. Because the Linux installation program on
DVD can be loaded when you first turn on the computer, it is referred to as a bootable
DVD.

Preparation for installation

An operating system is just a collection of software that interacts with and


control of device equipment. Thus, all operating systems have a certain
minimum a set of expectations for device hardware to function properly.
Although most The current hardware is sufficient to run the Linux operating
system, but it is important to ensure that a device meets the minimum hardware
expectations before performing an installation. These minimum installation
expectations can be obtained from several sources. If You received the
operating system on DVD, a printed manual or a file on the DVD specify these
expectations. You will also find the minimum hardware expectations there. for
most operating systems on the provider's website.
For Fedora 28 Linux operation System, see minimum hardware expectations at
[Link] or in Table 2-1.

25
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Also, each operating system only supports certain types of hardware


components. While modern Linux distributions support almost all hardware
components available on the market, it is a good idea to check those from a
hardware vendor website to see if the unusual components are compatible with
Linux. Also, there are many Linux distribution websites and computer
manufacturer websites have a Linux Hardware Compatibility List (HCL)
indicating whether the computer and the hardware has Linux driver support

Understanding the installation media

Before performing a Linux installation, you need to acquire Linux. To select


packages and the installer itself. The most common source of this packages are
CD-ROM media. To install from CD-ROM, insert the Linux Disk into your CD-ROM
drive and enable the computer. Most computers automatically search for a
startup program on the CD-ROM immediately after switching on; the computer
can then use the CD-ROM for Linux installation. Alternatively, on most modern
computers, you can manually select: the boot device using a manufacturer-
specific key, such as F12, during the boot order.
Almost all Linux distributions provide a website to download from DVD images
(called ISO images) with the .iso file extension. These ISO images can be written
to a blank writable CD/DVD using disc burning software under Windows, Linux
or Macintosh device, then used to boot your device to boot Linux Facility. In
addition to a standard Linux installation CD-ROM image, many Linux
distributions websites you can download a bootable multimedia DVD image. If
you write a live image of the multimedia DVD to a blank DVD and start the device
from it, fully functional the graphical Linux operating system that you can use is
loaded into RAM. this allows Test the operating system on your device to ensure
that all hardware drivers are present have been correctly detected prior to
installation on permanent storage such as a hard drive or Solid State Drive (SSD).
Once you are satisfied with the functionality of your Linux System loaded from
live media, you can select the corresponding icon on the desktop Start the
installer, which installs the Linux system into permanent storage. If your device
does not have a CD-ROM drive, you can still install Linux using imaging the
default CD-ROM or live media CD-ROM ISO image to a USB flash drive, provided

26
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

yours your device supports booting from a USB flash drive. To make this process
easier, many distributions provide a program and instructions that can be used
for execution the imaging process. For Fedora Linux, you can download and
install Fedora Media Write tool on a Windows or Macintosh system, as shown
in Figure 2-1. When you click Custom image, Fedora Media Writer tool allows
you to download the latest version from Fedora Workstation or Fedora Server,
and an image of a previously downloaded CD-ROM Fedora ISO image on a USB
key. After clicking on Custom Image, select this appropriate CD-ROM ISO image
and target USB flash drive, then click Write to Disc to Start the imaging process.

After the imaging process is complete, you can turn the USB flash drive into a
free USB slot, turn on the device, use the correct key for your device select the
target boot device (eg F12) and then choose the option to boot from yours USB
pen drive. Many servers and workstations today can run multiple operating
systems simultaneously with virtualization software. Several virtualization
software products are available on the market today, including

• Microsoft Hyper-V
• VMware

27
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

• Oracle VM VirtualBox
Any operating system running in virtualization software is called a virtual
machine and the underlying operating system on which the virtualization runs
The software is called the virtual machine host. Figure 2-2 shows a virtual Fedora
Linux Device running Windows 10 operating system with Microsoft Hyper-V
virtualization software.

Let’s Watch!

Let’s Think!

Quote

1.9.4 Subsection of unit content

28
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Reading

To install Linux as a virtual machine, you need to download the standard DVD or the Live Media DVD
ISO image in a directory on your virtual machine host (eg. Window). When you open the virtualization
software and create a new one virtual machine, you can view the file location of the corresponding
ISO image and the Virtualization software boots directly from the ISO image without you having to

29
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

write the ISO image to a DVD or USB flash drive. Figure 2-3 shows the portion
of Hyper-V New Virtual Machine Wizard that allows you to specify the location
of an ISO image showing Fedora 28 installation media.

Install

Installing the Linux operating system involves interacting with an installer,


which asks you for information about the nature of the Linux system Furniture.
Specifically, the Fedora 28 Linux installer includes the general install phase
• Start the installation
• Choose an installation language, localization and system options
• Configuring disk partitions and file systems
• Set up user accounts

Start installation

As mentioned earlier, to perform an installation of Fedora Linux, you can use


your Device with Fedora installation media. When you boot your system from
Standard Fedora installation media, you will be prompted to start the
installation or Perform troubleshooting actions. However, if you boot your

30
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

system from Fedora live media, you will instead be prompted to boot a live
Fedora system (which will later allow to install Fedora), test your installation
media and boot into a live Fedora system or Perform troubleshooting actions
as shown in Figure 2-4.

Select Launch Fedora-Workstation-Live 28 in the basic graphics mode shown in


Figure 2-5 will boot the Fedora system with generic, low resolution video
drivers, which is useful if the Fedora live system does not detect the correct

31
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

driver for your video tab and therefore cannot display a graphical desktop.
Faulty RAM is a common cause of a failed Linux installation. If you run. To
select a memory test as shown in Figure 2-5, the memtest86 utility will start
and a Check your RAM thoroughly for hardware errors, as shown in Figure 2-6.
The Boot from Local Disk option shown in Figure 2-5 is useful if you forget:
remove your Fedora installation media after installation is complete and yours

the system is configured to previously boot an operating system from the DVD
or USB drive search for an operating system on persistent storage. In most
cases, the troubleshooting options shown in Figure 2-5 are unnecessary when
installing Fedora Linux. Accordingly, you can choose Launch Fedora-
Workstation- Live 28 shown in Figure 2-4 to boot a live Fedora system. After
the Fedora system live loaded, you will see a welcome screen asking you to
install Fedora Linux on persistent memory or continue to use the loaded live
Fedora system from the installation media, as shown in Figure 2-7.

32
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

In Figure 2-7, if you choose Install to Hard Drive, the Fedora installer will
Beginning. Alternatively, if you select "Try Fedora", you can explore the
desktop of B. a running Fedora system, and can then choose Install to Hard
Drive from the Activities menu in the upper left corner of the desktop to
launch the Fedora installer.

Let’s Watch!

Let’s Think! Note: Most enterprise environments today take advantage of


virtualization software to run multiple server operating systems concurrently on the same
device hardware. This allows organizations to better utilize their server hardware and
reduce costs. Chapter 6 discusses this use of virtualization.

Quote

33
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

1.9.5 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment.

The Self-Assessment for this unit is embedded within your Linux MODULE in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

1.9.6 Revision Questions

34
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Exploring Linux File systems


An understanding of the structure and commands surrounding the Linux
filesystem is essential for effectively using Linux to manipulate data. In the

Purpose first part of this chapter, you explore the Linux filesystem hierarchy by
changing your position in the filesystem tree and listing filenames of various
types.

By the end of this unit, you will be able to:

Learning • Understand and navigate the Linux directory structure using relative
Outcomes and absolute pathnames
• Describe the various types of Linux files
• View filenames and file types

Time 150

~ metacharacter

absolute pathname

Key Terms binary data file

cat command

cd (change directory)

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

35
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Section 1

Section 2

Section 3

Section 4

Section

The Linux Directory Structure

Fundamental to using the Linux operating system is an understanding of how


Linux stores files on the file system. Typical Linux systems could have thousands
of data and program files; thus, a structure that organizes those files is necessary
to make it easier to find and manipulate data and run programs. Reminder of
the previous chapter that Linux uses a logical directory tree to organize files into
directories (aka Binder). When a user saves files to a specific directory, the files
are physically saved in the file system of a specific partition on a hard drive or
SSD in the computer. More Users are familiar with the directory structure of the
Windows operating system shown in Figure 3-1; Each file system on a hard disk
partition is referenced by a drive letter (such as C: or D:) and has a root (indicated
by the \ character) that contains Subdirectories that together form a hierarchical
tree.

36
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

It is important to correctly describe the absolute pathname in the directory tree;


the absolute path to file or directory is the full path to a specific file or directory
from the root directory. In Figure 3-1, the absolute path for color The directory
is C:\windows\color and the absolute path for the sue directory is D:\home\sue.
In other words, you are referring to C:\windows\color as the colors directory
below the Windows directory under the root of the C drive. Similarly, refer to
D:\home\sue as the sue directory under the home directory under the root of
drive D. Linux uses a similar directory structure, but with no drive letters.
Structure contains a single root (denoted by the character /), with several active
file systems mounted (or mounted) hard disk partitions in different folders in
this folder tree. The folder in which each file system is mounted is transparent
to the user. An example of a Linux directory structure similar to the example
Windows directory the shaft shown in Figure 3-1 is shown in Figure 3-2. Notice
that the subfolder named “Root” in Figure 3.2 differs from the root (/) directory.
You will learn more about the root subfolder in the next section. In Figure 3-2,
the absolute path name for the color folder is / windows / color en the absolute
path name for the sue directory is / home / sue. In other words, you are referring
to in the / windows / color folder as a color folder in the windows folder under
the root of the system (the / sign). Similarly, refer to / home / sue directory as
the sue directory in the home directory at the root of the system.

37
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Changing Directories

change directory When you log in to a Linux system, you are in your home
directory, i.e. a location unique to your user account to store personal files.
Normal users usually have a home directory named after their user account in
the /home directory like in /home/sue. However, the root user has a home
directory named root under root System directory (/root) as shown in Figure 3-
2. Whatever your username You can always refer to your own home directory
using the ~ metacharacter. To confirm which system directory you are in, just
observe the name at the bottom of the shell prompt or run the pwd (print
working directory) command at a command line prompt. If you are logged in as
root user, the following output is displayed on the terminal screen
[root@server1 ~]# pwd
/root
[root@server1 ~]#_
However, if you are logged in as the user sue, you see the following output:
[sue@server1 ~]$ pwd
/home/sue
[sue@server1 ~]$_
To change directories, you can issue the cd (change directory) command with an
argument specifying the destination directory. If you do not specify a destination
directory, the cd command returns you to your home directory:
[root@server1 ~]# cd /home/mary

38
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

[root@server1 mary]# pwd


/home/mary
[root@server1 mary]# cd /etc
[root@server1 etc]# pwd
/etc
[root@server1 etc]# cd
[root@server1 ~]# pwd
/root
[root@server1 ~]#_
You can also use the ~ metacharacter to refer to another user’s home directory
by
appending a user name at the end:
[root@server1 ~]# cd ~mary
[root@server1 mary]# pwd
/home/mary
[root@server1 mary]# cd ~
[root@server1 ~]# pwd
/root
[root@server1 ~]#
In many of the examples discussed above, the argument is specified after the cd
command is an absolute path to a directory, which means the system has all
information needed to find the destination folder because the path name begins
from the root (/) of the system. However, in most Linux commands you can also
do this a relative path instead of an absolute path to reduce typing. A member
of the family pathname is the path name of a destination file or folder relative
to the current folder in the tree. To specify a folder in the current folder, refer
to that folder by name (do not start the path name with a / character). Pointing
a step towards a directory closer to the root of the tree (also known as the

39
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

mother map), use a colon (..). An example of using relative path names to
navigate the directory tree is shown below:
[root@server1 ~]# cd /home/mary
[root@server1 mary]# pwd
/home/mary
[root@server1 mary]# cd ..
[root@server1 home]# pwd
/home
[root@server1 home]# cd mary
[root@server1 mary]# pwd
/home/mary
[root@server1 mary]#_
The preceding example used “..” to move up one parent directory and then used
the word “mary” to specify the mary subdirectory relative to the current
location in the tree; however, you can also move more than one level up or
down the directory tree:
[root@server1 ~]# cd /home/mary
[root@server1 mary]# pwd
/home/mary
[root@server1 mary]# cd ../..
[root@server1 /]# pwd
/
[root@server1 /]# cd home/mary
[root@server1 mary]# pwd
/home/mary
[root@server1 mary]#_

40
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Although absolute pathnames can easily be used as arguments to Relative


commands when specifying the location of a specific file or directory Path names
can save you a lot of typing and reduce the risk of error when you The current
directory is remote from the root directory. Suppose, for example, that the
Current directory is /home/sue/projects/acme/plans and you need to change it
/home/sue/projects/acme directory. If you are using an absolute path name,
type cd / home / sue / projects / acme; however, if you are using a relative path
name, you just need to type cd .. to do the same task because the directory /
home / sue / projects / acme is a parent directory above the current position in
the directory tree. An alternative way to save time by typing path names as
arguments to commands is to use the tab completion function of the BASH shell.
To do it, type enough unique letters from a folder and press the Tab key to start
the BASH shell to find the desired file or directory specified and enter the
appropriate one information. If there is more than one possible match, the
completion of the card warns you with an acoustic signal; pressing the Tab key
again after this beep will give you a list of possible files or folders. Notice the
directory structure in Figure 3-2. To use the tab completion feature, Change the
current directory to /home/sue, type cd /h, then press Tab. This will change the
previous characters on the terminal screen to include cd /home/ (The BASH shell
was able to enter the correct information because the /home directory is the
only directory under the / directory that starts with the letter "h"). So you could
add an s character to the command to make the command line appear cd
/home/s and press Tab again to allow the shell to populate the file remaining
letters. This will bring up the command cd /home/sue/ on the terminal screen
(the sue directory is the only directory that comes with the s under the /home
directory). At this point you can press Enter to run the command and change the
current directory to /home/sue.

Let’s Watch!

Let’s Think! Note: You can also use one dot ( . ) to refer to the current directory.
Although this is not useful when using the cd command, you do use one dot later in this
book.

41
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Quote

1.9.7 Subsection of unit content

Reading

Viewing Files and Directories

So you could add an s character to the command to make the command line
appear cd /home/s and press Tab again to allow the shell to populate the file
remaining letters. This will bring up the command cd /home/sue/ on the
terminal screen (the sue directory is the only directory that comes with the s
under the /home directory). At this point you can press Enter to run the
command and change the current directory to /home/sue.

File Types

Fundamental to viewing files and folders is understanding the different one’s file
types found on most Linux systems. A Linux system can be of different types of
Files; the most 7 common types are the following:

• Text file
• Binary data files
• Executable program files
• Directory files
• Linked files
• Special device files
• Pipes and sockets with name
Most file-locations on a Linux system that contain configuration information are
text file-locations. Another type of file-location is a program that exists on disk

42
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

before it is executed. become in-memory processes. A program is generally


assigned to several Support for binary data file-locations that store information
such as general functions and Chart. Also, directories themselves are actually
file-locations; these are special file-locations serving as placeholders to organize
other file-locations. When you create a directory, there is a file-location placed
on disk to represent this directory. Linked file-locations are file-locations linked
together; they can represent the same data, or they may point to a different file-
location (i.e. a link file-location). Special Device file-locations are rarer than the
other file-location types mentioned, yet they are important for system
administrators because they represent something different System devices,
such as hard drives and serial ports. These device file-locations are used in
connection with commands manipulating devices in the system; special device
The file-locations are usually only found in the /dev directory and are covered in
the following chapters this book. As with special device file-locations, named
pipe file-locations are rare and used mainly by administrators. Named pipes
identify channels that pass information from one process in memory to another,
and in some cases they can be mediated file-locations on disk. Writes to file-
location are processed while another process is reading beside himself to carry
out this sharing of information. Another variation of a named pipe file-location
is a Socket file-location that allows a process on another computer to write to a
file-location on the local computer while another process reads from this file-
location.

Filenames

files on disk. Writes to file are processed while another process is reading beside
himself to carry out this sharing of information. Another variation of a named
pipe file is a Socket file that allows a process on another computer to write to a
file on the local computer while another process reads from this file. Filenames
used by the Windows operating system usually end with a period and three
characters identifying the type of file - for example, [Link] (a text file)
and [Link] (an executable program file). Most files on the hard drive have
Linux systems do not follow this pattern, although some files are present in the
Linux file system contain characters at the end of the filename that indicate the
file type. This The characters are commonly referred to as filename extensions.

43
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Table 3-1 lists the most common Examples of filename extensions and their
associated file types.

Listing Files

Linux hosts a variety of commands that can be used to list files and their types
in different folders on hard disk partitions. By far the most common method for
viewing files consists of using the ls command. Below is an example of a list of
files in root user's home directory:
[root@server1 ~]# pwd
/root
[root@server1 ~]# ls
current myprogram project project12 project2 project4

44
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Desktop myscript project1 project13 project3 project5


[root@server1 ~]#_
The ls command displays all the files in the current directory in columnar format;
however, you can also pass an argument to the ls command indicating the
directory to list if the current directory listing is not required. In the following
example, the files are listed under the /home/bob directory without changing
the current directory.
[root@server1 ~]# pwd
/root
[root@server1 ~]# ls /home/bob
assignment1 file1 letter letter2 project1
[root@server1 ~]#_
Recall from the previous chapter that you can use switches to alter the
behaviour of commands. To view a list of files and their type, use the –F switch
to the ls command:
[root@server1 ~]# pwd
/root
[root@server1 ~]# ls -F
current@ myprogram* project project12 project2 project4
Desktop/ myscript* project1 project13 project3 project5
[root@server1 ~]#_
The ls –F command adds a special character to the end of each filename
displayed to indicate the file type. In the preceding output, note that the
filenames current, desktop, myprogram and myscript have special characters
added names. The @ symbol indicates a linked file, the * symbol indicates an
executable file, the / indicates a subdirectory, the 5 character indicates a socket,
and the | character indicates a named pipe. Other file types have no special
characters added and these can be text files, binary data files, or special device
files. Although the ls –F command is a quick way of getting file type information

45
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

in an easy-to-read format, at times you need to obtain more detailed


information about each file. The ls –l command can be used to provide a long
listing for each file in a certain directory

Each file listed in the preceding example has eight components of information
listed in columns from left to right:
1 A file type character:
• The d character represents a directory.
• The l character represents a symbolically linked file (discussed in Chapter
4).
• The b or c characters represent special device files (discussed in Chapter
5).
• The n character represents a named pipe.
• The s character represents a socket.
• The – character represents all other file types (text files, binary data files).
2 A list of permissions on the file (also called the mode of the file).
3 A hard link count (discussed in Chapter 4).
4 The owner of the file (discussed in Chapter 4).
5 The group owner of the file (discussed in Chapter 4).
6 The file size.
7 The most recent modification time of the file (or creation time if the file was
not modified following creation).

46
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

8 The filename. Some files are shortcuts or pointers to other files and
indicated with an arrow ->, as with the file called “current” in the preceding
output; these are known as symbolic links and are discussed in Chapter 4.
For the file named "Project" in the previous example, you can see that this
file is a normal file because its long list starts with a - character, permissions
are enabled file is rw-r--r--, hardlink count is 1, file owner is root user who
The group owning the file is the root group, the file size is 71 bytes, and the
file has been last modification on April 7 at 9:58 a.m.
The ls -F and ls -l commands are valuable for a user who wants to display Data
Types; however, none of these commands can display all file types with
Characters. To view the file type of any file, you can use the file command; she
Give the file command an argument that specifies the file to scan. You can also
Pass multiple files as arguments or use the * metacharacter to refer to all files
in the file Current directory. An example of using the file command in the root
user's home The directory is as follows:
[root@server1 ~]# pwd
/root
[root@server1 ~]# ls
current myprogram project project12 project2 project4
Desktop myscript project1 project13 project3 project5
[root@server1 ~]# file Desktop
Desktop: directory
[root@server1 ~]# file project Desktop
project: ASCII text
Desktop: directory
[root@server1 ~]# file *
Desktop: directory
current: symbolic link to project12
myprogram: ELF 32-bit LSB executable, Intel 80386, version 1,

47
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

dynamically linked (uses shared libs), stripped


myscript: Bourne-Again shell script text executable
project: ASCII text
project1: ASCII text
project12: ASCII text
project13: empty
project2: ASCII text
project3: ASCII text
project4: ASCII text
project5: ASCII text
[root@server1 ~]#_
As shown in the previous example, the file command can also identify the
Differences between executable file types. The myscript file is a text file that
contains executable commands (aka shell script) while the myprogram The file
is a 32-bit compiled executable program. The file command also identifies empty
files Files like project13 in the previous example. Some filenames in each user's
home directory are important Configuration files or program directories. Since
these files are rarely processed by the This allows users to override the list of
files when they are not normally visible with the ls and file commands.
Remember that filenames for hidden files start with a point ( . ). To display them,
pass the –a option to the ls command. Some Hidden files often seen in the root
user's home directory are displayed The next:

48
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

As mentioned earlier, the character ( . ) refers to the current working directory


and the character ( .. ) refers to the parent directory relative to your current
location in the directory tree. Each of these pointers is considered a special (or
dummy) file when used the ls –a command, since each begins with a dot. You
can also specify multiple options at once for most commands in the Command
line and get the combined functionality of all options. For instance, To show all
hidden files and their file types, you can type:

The above options for the ls command ( –l, –F, –a ) are the most general options
you would use when navigating the Linux directory tree; however, There are
many options available in the ls command that modify the list of files on the file
system. Table 3-2 lists the most common options and their descriptions.

49
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

50
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Let’s Watch!

Let’s Think!

Quote

8.1.1 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment.

The Self-Assessment for this unit is embedded within your Linux MODULE in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

8.1.2 Revision Questions

51
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Linux File system Management


In the previous chapter, you learned about navigating the Linux filesystem as
well as viewing and editing files. This chapter focuses on the organization of
Purpose
files on the Linux filesystem as well as their linking and security. First, you
explore standard Linux directories using the Filesystem Hierarchy Standard.

By the end of this unit, you will be able to:


Learning • Find files and directories on the filesystem
Outcomes • Understand and create linked files
• Explain the function of the Filesystem Hierarchy Standard

Time 150

access control list (ACL)

chattr (change attributes)

Key Terms command

chgrp (change group)

command

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

Section 1

Section 2

Section 3

Section 4

Section

52
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Let’s Watch!

Let’s Think! Note that source (or sources) and destination can be absolute or
Relative pathnames and source may contain wildcards if there are to be multiple files hit.
For example, to move all project files to the proj_files directory, you would could type mv
with argument source project* (to match all files starting with the letters "project") and
the target argument proj_files (relative path to target directory) as shown in the following
output:

8.1.3 Subsection of unit content

Reading

The Filesystem Hierarchy Standard

The thousands of files on a typical Linux system are organized into directories in
the Linux directory tree. It's a complex system that's getting more and more
complex Passed due to the fact that different Linux distributions were free to
place files in different Locations. This meant you could waste a lot of time
looking for one Configuration file on a Linux system that you were unfamiliar
with. To simplify the Task to find specific files, the Filesystem Hierarchy Standard
(FHS) was created. FHS defines a standard set of directories for use by all Linux
and UNIX systems such as: as well as the contents of the file and subfolder of
each folder. This ensures that, why the file name and location follow a standard
convention, a Fedora Linux user: find the correct configuration file on openSUSE
Linux or Hewlett-Packard UNIX computer with little effort. The FHS also offers
the opportunity to Linux software developers to locate files on a Linux system,
regardless of distribution, so they can create software that is not distribution
specific. A complete understanding of the standard types of directories found
on Linux systems are invaluable in locating and managing files and folders; a
53
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

standard The UNIX and Linux directories defined by the FHS and their
descriptions are listed in Table 4-1. These folders are discussed in this chapter
and in subsequent chapters

As mentioned earlier, using a Linux system requires navigating through multiple


directories and Manipulation of the files it contains. Therefore, an efficient Linux
user must understand how to do it. Create directories as needed, copy or move

54
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

files from one directory to another and delete files and directories. These tasks
are commonly referred to as file management tasks. Following is an example of
a directory listing displayed by a user who is logged in as the root user:

As shown in the preceding output, two executable files (myprogram and


myscript), and several project-related files (project*) exist on this example
system. This directory structure is not overloaded and appears clear The format
on the terminal screen includes typical home directories on a Linux system many
more files; Typical Linux users may have over 100 files at home directories. It is
therefore advisable to organize these files in subdirectories depending on the
purpose of the file. Because several project files reside in the root user's home
directory in the above output, you can create a subdirectory called proj_files to
contain project related files and reduce the size of the directory listing. Until do
this, use the mkdir (make directory) command, which takes arguments
specifying the absolute or relative paths of the directories to be created. to make
one proj_files in current folder, you can use mkdir command with a relative path
name:

Now you can move the project files to the proj_files subfolder using mv
command (move). The mv command requires at least two arguments: the
source file / directory and the target file / directory. For example, to move the /
etc / sample1 in the / root directory, you can use the command mv / etc /
sample1 / root. To move multiple files, add a source argument for each file you
want to move and then include the destination folder as the last argument.
Front for example to move the / etc / sample1 and / etc / sample2 files to the /

55
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

root directory, will execute the command mv / etc / sample1 / etc / sample2 /
root.

Let’s Watch!

Let’s Think!

Quote

8.1.4 Subsection of unit content

Reading

In the preceding output, the current directory listing does not show the project
files anymore, yet the listing of the proj_files subdirectory indicates that they
were moved successfully. Another important use of the mv command is to
rename files, which is simply moving a file to the same directory but with a
different filename. To rename the myscript file from earlier examples to
myscript2, you can use the following mv command:

56
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Similarly, the mv command can rename directories. If the source is the name of
a existing directory, it will be renamed with the specified directory name as the
destination. The mv command works like a cut and paste operation, with the file
is copied to a new directory and deleted from the source directory. In some
cases, However, you can keep the file in the source directory and include one
instead Copy file to target directory. You can do this using the cp (copy)
command. Like the mv command, the cp command has at least two arguments.
The first argument specifies the source file / directory to copy and the second
argument specifies the destination file / directory. If multiple files need to be
copied into one destination folder, specify several source arguments, with the
last argument activated the command line which acts as the destination folder.
Each argument can be an absolute or relative pathname and can contain
wildcards or the special metacharacters “.” (which specifies the current
directory) and “..” (which specifies the parent directory). For example, to make
a copy of the file /etc/hosts in the current directory (/root), you can specify the
absolute pathname to the /etc/hosts file (/etc/hosts) and the relative pathname
indicating the current directory ( . ):

You can also make copies of files in the same directory. To make a copy of the
hosts file called hosts2 in the current directory and view the results, type the
following commands:

57
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Despite their similarities, the mv and cp commands work differently on


directories. The mv command renames a directory while the cp command
creates an entire one new copy of the directory and its contents. To copy a
directory full of files in Linux, You must tell the cp command that the copy will
be recursive (files and including subdirectories) with the –r option. The following
example shows Copy the proj_files directory and all its contents to the
/home/user1 directory without and with the –r option:

If the destination is an existing file, both the mv and cp commands warn the user
that: the destination file is overwritten and asks if you want to continue. This is
not a function of the command as it is usually called, but it is a feature of the
default configuration in Fedora Linux because the BASH shell in Fedora Linux
contains aliases for cp and mv commands. When you type mv you are actually
running the mv command with the -i option without realizing it. If the target file
already exists, both the mv command and the The mv command with the –i
option interactively prompts the user to choose whether to overwrite the
existing file. Similarly, when typing the cp command, cp –I the command is
actually executed to prevent files from being accidentally overwritten. To see
the ... alias in the current shell, type alias, as shown in the following output:

58
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

If you use this interactive option, note as interactive mode, then use the –f
(force) option to override the choice, as shown in next example. In this example,
the root user attempts to rename the hosts file with the name "hosts2", a name
already assigned to an existing file. The example shows the the user tries this
task both without and with the -f option for the mv command:

Creating directories, copying and moving files are file management tasks that:
save or create data on your hard drive. To delete files or folders, you need to
use the rm command or the rmdir command. The rm (remove) command
accepts a list of arguments that specify absolute values or the relative paths of
the files to delete. As with most commands, wildcards can be used to simplify
deleting multiple files. After deleting a file the file system, it cannot be restored.
59
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

To delete a directory, you can use the rmdir (delete directory) command;
however, the rmdir command only deletes a directory if it contains no files. Until
delete a folder and the files it contains, you need to use the rm command and
specify: that a folder full of files should be deleted. As explained earlier in this
chapter, you have to use the recursive option (-r) with the cp command to copy
directories; to delete a folder full of files, you can also use a recursive option (–
r) with rm order. For example, if the root user wants to delete the proj_files
subdirectory and all the files it contains without being asked to confirm the
deletion of each file, they could use the rm –rf proj_files command as shown
below: example:

Let’s Watch!

Let’s Think!

60
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Quote

8.1.5 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment.

The Self-Assessment for this unit is embedded within your Linux MODULE in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

8.1.6 Revision Questions

61
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Linux File System Administration


Navigating the Linux directory tree and manipulating files are common tasks
that are performed on a daily basis by all users. However, administrators
must provide this directory tree for users, as well as manage and fix the
Purpose
storage devices that support it. In this chapter, you learn about the various
device files that represent storage devices and the different filesystems that
can be placed on those devices.

By the end of this unit, you will be able to:


Learning • Identify the structure and types of device files in the /dev directory
Outcomes • Understand common filesystem types and their features
• Mount and unmount filesystems to and from the Linux directory tree

Time 150

bad blocks

blkid command

Key Terms block

block devices

cfdisk command

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

62
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Section 1

Section 2

Section 3

Section 4

Section

The /dev Directory

Fundamental to managing the units used to store information is a concept as


these drives are specified by the Linux operating system. Most devices on a Linux
systems (such as disks, terminals and serial ports) are represented by a file on
file the hard drive is called a device file. There is one file per device and these
files are typically: it is located in the / dev directory. Allows you to specify the
devices on the system using the path to the file it represents in the / dev
directory. Recall from Chapter 2 that the first partition on the first
SATA/SCSI/SAS hard disk or SSD is identified by the installation program as sda1.
When working with Linux utilities, you can specify the pathname to the file
/dev/sda1 to refer to this hard disk or SSD. Furthermore, each device file
specifies how data should be transferred to and from the device. There are two
methods for transferring data to and from a device. The first method involves
transferring information character-by-character to and from the device. Devices
that transfer data in this fashion are referred to as character devices. The second
method transfers chunks or blocks of information at a time by using physical
memory to buffer the transfer. Devices that use this transfer method are: called
block devices; they can transfer information much faster than characters'
devices. Device files that represent discs, such as CDs, DVDs, USB flash drives,
hard drives, and SSDs are usually block device files because they are formatted

63
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

with a file system that organizes the available storage space into discrete blocks
that can be written to. tape drive however, most other devices are usually
represented by device files with fonts. To see if a specific device is transmitting
data character by character or Remember that the ls –l command displays a
character c or b in the type Column indicating the file type of the device. To view
the type of the /dev/sda1 file, you can use the following command:
[root@server1 ~]# ls –l /dev/sda1
brw-rw---- 1 root disk 8, 1 Feb 23 16:02 /dev/sda1
[root@server1 ~]#_
From the leftmost character in the preceding output, you can see that the
/dev/sda1 file is a block device file. Table 5-1 lists common device files that you
may find on your Linux system and their types.

64
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

After a typical Fedora Linux installation, you will see hundreds of different ones
device files in the / dev directory representing the devices on the system. this
great device file number on a Linux system does not require a lot of disk space
because: all device files are made up of inodes and not blocks of data;
consequently, the entire contents of the / dev folder is 0 kilobytes in size, unless
it has other normal files stored in it. When using the ls –l command to view
device files, the part of the list describing the file size in kilobytes is replaced by
two numbers: the uppercase number and the small number. The main number
of a device file refers to the device driver for the device in the Linux kernel;

65
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

multiple devices can share the same master number if they are of the same
general type (i.e. two different SATA devices can share the same major number
since they use the same driver in the Linux kernel). Minor The number
designates the respective device itself; for HDD and SSD devices, different minor
numbers are used to represent different partitions as shown in the following
output:

Let’s Watch!

Let’s Think!

Quote

8.1.7 Subsection of unit content

Reading

66
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Together, the device file type (block or character), the master number (device
driver) and secondary (device-specific) number are unique features of each file
on the device. To create a device file, you need to know these three bits:
information. When a device file gets corrupted, it is usually listed as a normal
file rather than a lock or draw a special file. Remember from chapter 4 that you
have the discovery. be able to use / dev - type the command f to search for
normal files in the / dev directory determine if there is corruption. If you have a
damaged device file or If you accidentally delete a device file, the mknod
command can be used to recreate the file Device file if you know the type and
major and minor numbers. An example for Recreate the previously used block
device file /dev/sda1 with a major number of 8 and a The minor number 1 is
shown in the following example:

To view a list of blocking and drawing devices currently used in the system and
their key numbers, you can view the contents of the / proc / devices. See system
block devices, you can view the contents of the / sys / block folder, and to view
detailed information for these block devices (including their main and small
numbers) you can use the lsblk command as shown below:

67
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

68
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

File systems

Remember from Chapter 2 that files must be stored on your hard drive in a
defined format called file system so that the operating system can work on it.

69
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

The guy The file system used determines how files are handled on the physical
hard drive. Each file system can have different file storage methods and
features that allow for this the file system is robust against errors. Although
there are many types of file systems available, all file systems share three
common components, as discussed in Chapter 4: the The superblock, the inode
table and the data blocks. At the structural level, these three Components
work together to organize files and provide fast access and retrieval Data.
Some file systems include a fourth component called Journal which keeps track
of things changes to write to the file system; hence these filesystems so-called
journaling file systems. In case of power failure can check the file system the
journal to complete the changes not made to prevent the file system Power
failure errors. All storage media such as hard drives, SSDs, USB Flash drives and
DVDs must contain a file system before they can be used.

Let’s Watch!

Let’s Think!

Quote

8.1.8 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment.

The Self-Assessment for this unit is embedded within your Linux MODULE in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

70
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

8.1.9 Revision Questions

71
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Linux Server Deployment


In Chapter 2, you examined a standard Linux installation process using
common hardware components and practices. This chapter examines the
Purpose
specialized hardware and software configurations that affect your choices as
you install a Linux server distribution.

By the end of this unit, you will be able to:


Learning • Identify the types of hardware present in most server systems
Outcomes • Describe the configuration of SCSI devices and SANs
• Explain the different levels of RAID and types of RAID configurations

Time 150

1U server

blade server

Key Terms Boxes

B-tree File System (BTRFS)

btrfs command

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

Section 1

Section 2

Section 3

Section 4

Section

72
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Understanding Server Hardware

Recall from Chapter 2 that the minimum hardware requirements for Fedora
Linux include a meager 1GHz CPU, 1GB of RAM, and 10GB of disk space, which
is far lower than most modern operating systems. However, Linux is incredibly
scalable and often configured to work with far more hardware to perform a
specialized set of tasks. For For example, a Linux computer used as an office
workstation usually needs enough RAM to run GNOME and desktop applications
smoothly, as well as a modern processor and plenty Storage space for storing
files, pictures, movies, etc. An Intel Core i5 system with 16 GB of RAM and a 500
GB SSD are typical hardware for a Linux desktop workstation. If The workstation
is intended for personal use or gaming. Expect a high-end graphics card
supported by gaming platforms like Steam. For server computers, the amount
of The hardware should adequately support its intended use. A Linux web server
that processes E-commerce and a database engine can require 128 GB of RAM,
multiple processors and a high SSD capacity to house the operating system, web
server software and database engine. Almost all standard server hardware is
supported by Linux. If you have recently bought some modern server hardware,
most likely your linux distro has all of that the drivers you need. However, if your
system has special hardware (eg. specific Fiber Channel controller), check with
the hardware vendor first to make sure they have one Driver appropriate for
your Linux distribution included (or available for download). The form factor for
server hardware differs from that of other computers. Almost everything servers
within an organization are housed in a rack mount enclosure mounted next to
them other servers on a vertical server storage rack. As a result, these servers
are called rackmount servers. Each rackmount server can run a different
operating system (or more) operating systems if virtualization software is used)
and connect to a shared monitor / keyboard mouse. The shared monitor /
keyboard / mouse often folds into the rack for storage and is used for initial
configuration tasks such as server installation. All the others server management
is performed remotely using remote management methods discussed in chapter
12. Most racks also contain one or more Storage Area Network (SAN) devices
that: provide a large amount of hard drive or SSD storage for the servers in the
rack. They also include one or more Uninterruptible Power Supply (UPS) devices
73
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

to provide: backup battery power to servers and SANs in the rack in the event
of a power failure. The minimum height of a rackmount server is 1.75 inches;
this is called a 1U server. Most 1U servers have up to two hard drives (or SSDs)
and up to two CPUs. Other rack mount servers take up more than one space in
the rack. Their height is a multiple of a 1U server. For example, a 2U server is
twice as tall as a 1U server and often contains up to four CPUs and eight hard
drives (or SSDs). Rackmount servers rarely exceed 4U, but SAN devices are: often
4U or more. Figure 6-1 shows an example rack server configuration with three
1U servers (Web server, file server and firewall server), two 2U servers (database
server and email server), a 2U UPS, a 4U SAN and a management station with
shared monitor / keyboard / mouse.

74
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Let’s Watch!

75
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Let’s Think!

Quote

8.1.10 Subsection of unit content

Reading

Understanding Server Virtualization

Virtualization is the process of running multiple operating systems at the same


time on a single computer and has been used in various capacities since the
inception of Computing in the 1960s. To perform virtualization, you must use
software that allows it hardware to host multiple operating systems. This
software is called a hypervisor, and is used to efficiently handle concurrent
requests for underlying hardware. Type 2 hypervisors are designed to run on an
existing desktop operating system (called host operating system). All other
operating systems (called Guest operating systems or virtual machines) must
access the hardware through the Hypervisor and the underlying host operating
system. Type 2 hypervisors are prevalent today for software testing and
development. A software developer can do this, for example Test a specific
application or web application on a variety of operating systems without require
separate computers. Many college tech courses also take advantage of these
benefits. Type 2 hypervisors to run multiple operating systems in a classroom or
lab Surroundings. In the mid-2000s, a typical server cabinet or data center
contained many people Rack mounted server. To ensure security and stability,
each rack-mounted server contain a single or a small number of separate server
software applications. Frequently, one rack-mounted server hosted the web
server software while another hosted the file sharing services and so on.

76
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Unfortunately, most of these server software applications are used just a small
fraction of actual rack server hardware Provide energy e cooling rackmount
servers was expensive. To solve these problems, many IT administrators
switched to server virtualization, but with a type 1 hypervisor to be sure that
each virtual machine works as efficiently as possible. A type 1 hypervisor it works
directly with the hardware and includes a small operating system to manage
hypervisor configuration and virtual machines. Figure 6-2 shows the difference
between type 1 and type 2 hypervisors.

The Linux kernel has a built-in hypervisor feature called Kernel Virtual
computer (KVM). KVM works with another Linux software package called Quick
Emulator (Qemu) to provide near-native speed for virtual machines using a
process is called binary translation. You can use KVM and Qemu to run virtual
machines from other Linux and similar non-Linux operating systems on a Linux
desktop workstation how type 2 hypervisors are used today. Alternatively, you
can also use a Linux system with only provides KVM and Qemu functionality to
run multiple server VMs Faster; In this configuration, KVM and Qemu operate
as a type 1 hypervisor and the A Linux system is only used to manage the
functionality of the hypervisor. Regardless of the hypervisor used, all virtual
machines save their configuration in a small hypervisor-specific configuration
file. They record the current operation Virtual machine system data in a virtual
disk file. When creating a virtual machine, you must select the size of this
virtual disk file. You must also specify if the space allocated to the virtual hard
disk file is set to a fixed size during this time created (known as thick
provisioning) or dynamically allocated as a virtual machine uses disk space
(called dynamic allocation). For example, if you create a fixed size of 250 GB
virtual disk, then 250 GB will be immediately reserved on the storage device;
however, if you Create a thin provisioned disk, it uses a small virtual disk file

77
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

which can grow 250 GB because the virtual machine stores more data. Thin
provisioning is often preferred for Server virtualization as it saves storage
space on the underlying server storage hardware To create and manage KVM /
Qemu virtual machines, a Linux system must have: virtualization libraries
(libvirt) installed, as well as a program that can use them libraries to perform
virtualization functions. In Fedora 28, KVM and Qemu can be easily configured
and managed using a program called Boxes on the GNOME desktop, but you
can also install other graphical and command line virtual machines and
management tools, such as virsh, virt-install and virt-manager. You can use
Boxes to manage multiple locally hosted KVM/Qemu virtual machines
computer or on other computers on the network using the graphical virtual
network Computer protocol (VNC) or the faster simple protocol for
independent computing Environments protocol (SPICE) and associated QXL
graphics driver framework, which is the default in Fedora 28. Figure 6-3 shows
a SPICE connection to a Windows Server 2016 virtual machine.

78
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Let’s Watch!

Let’s Think!

Quote

8.1.11 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment.

The Self-Assessment for this unit is embedded within your Linux MODULE in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

8.1.12 Revision Questions

79
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Working with the BASH Shell


A solid understanding of shell features is vital to both administrators and
users who must interact with the shell on a daily basis. The first part of this
Purpose
chapter describes how the shell can manipulate command input and output
using redirection and pipe shell metacharacters.

By the end of this unit, you will be able to:


Learning • Identify and manipulate common shell environment variables
Outcomes • Create and export new shell variables
• Edit environment files to create variables upon shell startup

Time 150

alias command

branch

Key Terms cloning

commit

counter variable

Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification,
Prescribed 5th edition. ISBN: 9781337569798
Reading

Section 1

Section 2

Section 3

Section 4

Section

80
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

Working with the BASH Shell

on the command line alongside the command. Command input and output are
represented by labels known as file descriptors. For each command that can be
manipulated by the BASH shell, there are three file descriptors:

• Standard Input (stdin)


• Standard Output (stdout)
• Standard Error (stderr)
The standard input (stdin) refers to the information processed by the command
during execution; This often takes the form of user input typed on the keyboard.
Standard output (stdout) refers to the normal output of a command, whereas
Standard error (stderr) refers to error messages generated by the command.
Both stdin and stderr are displayed on the terminal screen by default. The three
components are shown in Figure 7-1.

81
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

As shown in Figure 7.1, each file descriptor is represented by a number, with


stdin represented by the number 0, stdout represented by the number 1, and
stderr represented by the number 2. Although all three descriptors are available
for any command, not all commands are use any description. The ls / etc / hosts
/ etc / h command used in Figure 7-1 provides: stdout (the list of the / etc / hosts
file) and stderr (an error message indicating that the / etc / h does not exist) to
the terminal screen, as shown in the following output:
[root@server1 ~]# ls /etc/hosts /etc/h
ls: cannot access /etc/h: No such file or directory
/etc/hosts
[root@server1 ~]#_

Let’s Watch!

Let’s Think!

Quote

8.1.13 Subsection of unit content

Reading

Redirection

You can use the BASH shell to redirect stdout and stderr from the terminal
screen to a file in the file system. To do this, add the metacharacter> shell

82
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

followed by absolute or relative path name of the file. For example, to simply
redirect stdout to a file called goodoutput for the command used in figure 7.1,
add the number the file descriptor (1) followed by the redirect symbol> and
the file around the. to drive stdout a (goodoutput), as shown in the following
output:
[root@server1 ~]# ls /etc/hosts /etc/h 1>goodoutput
ls: cannot access /etc/h: No such file or directory
[root@server1 ~]#_
In the preceding output, the stderr is still displayed to the terminal screen
because it was not redirected to a file. The listing of /etc/hosts was not
displayed, however; instead, it was redirected to a file called goodoutput in the
current directory. If the goodoutput file did not exist prior to running the
command in the preceding output, Linux creates it automatically. However, if
the goodoutput file did exist prior to the redirection, the BASH shell clears its
contents before executing the command. To see that the stdout was
redirected to the goodoutput file, you can run the following commands:

83
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

It is important to use separate filenames for the contents of stdout and stderr.
Using the same file name for both will result in data loss during system
attempts to write both contents to the file at the same time:
[root@server1 ~]#ls /etc/hosts /etc/h >goodoutput 2>goodoutput
[root@server1 ~]# cat goodoutput
/etc/hosts
access /etc/h: No such file or directory
[root@server1 ~]#_
To redirect both stdout and stderr to the same file without any loss of data,
you must use special notation. To send stdout to the file goodoutput and
stderr to the same place as stdout, you can do the following:
[root@server1 ~]# ls /etc/hosts /etc/h >goodoutput 2>&1
[root@server1 ~]# cat goodoutput
ls: cannot access /etc/h: No such file or directory

84
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

/etc/hosts
[root@server1 ~]#_
Alternatively, you can send stderr to the file badoutput and stdout to the same
place as stderr:
[root@server1 ~]# ls /etc/hosts /etc/h 2>badoutput >&2
[root@server1 ~]# cat badoutput
ls: cannot access /etc/h: No such file or directory
/etc/hosts
[root@server1 ~]#_
An easier alternative is to use the &> special notation. For example, to redirect
both stdout and stderr to the alloutput file, you could use the following
command:
[root@server1 ~]# ls /etc/hosts /etc/h &>alloutput
[root@server1 ~]# cat alloutput
ls: cannot access /etc/h: No such file or directory
/etc/hosts
[root@server1 ~]#_
In all of the examples used earlier, the contents of the files used to store the
output from commands were cleared prior to use by the BASH shell. Another
example of this is shown in the following output when redirecting the stdout of
the date command to the file date output:
[root@server1 ~]# date >dateoutput
[root@server1 ~]# cat dateoutput
Fri Aug 20 [Link] EDT 2019
[root@server1 ~]# date >dateoutput
[root@server1 ~]# cat dateoutput
Fri Aug 20 [Link] EDT 2019
[root@server1 ~]#_

85
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

To prevent the file from being cleared by the BASH shell and append output to
the existing output, you can specify two > metacharacters alongside the file
descriptor, as shown in the following output:
[root@server1 ~]# date >dateoutput
[root@server1 ~]# cat dateoutput
Fri Aug 20 [Link] EDT 2019
[root@server1 ~]# date >>dateoutput
[root@server1 ~]# cat dateoutput
Fri Aug 20 [Link] EDT 2019
Fri Aug 20 [Link] EDT 2019
[root@server1 ~]#_
You can also redirect a file to the stdin of a command using the <
metacharacter. Because input has only one file descriptor, you do not need to
specify the number 0 before the < metacharacter to indicate stdin, as shown
next:
[root@server1 ~]# cat </etc/issue
\S
Kernel \r on an \m (\l)
[root@server1 ~]#_
In the preceding output, the BASH shell located and sent the /etc/issue file to
the cat command as stdin. Because the cat command normally takes the
filename to display as an argument on the command line (e.g., cat /etc/issue),
you do not need to use stdin redirection with the cat command as in the
previous example. However, some commands only accept files that the shell
passes through stdin. The tr command is one such command that can be used
to replace characters in a file sent via stdin. To replace all of the lowercase r
characters in the /etc/issue file to uppercase R characters, you can run the
following command:
[root@server1 ~]# tr r R </etc/issue
\S

86
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

KeRnel \R on an \m (\l)
[root@server1 ~]#_
The above command does not modify the / etc / issue file; i just need a copy
the / etc / issue file, manipulate it and then send the stdout to the terminal
screen. Save a copy of stdout for later use, you can use stdin and stdout
redirect together:
[root@server1 ~]# tr r R </etc/issue >newissue
[root@server1 ~]# cat newissue
\S
KeRnel \R on an \m (\l)
[root@server1 ~]#_
As for redirecting stdout and stderr in the same command, you need to use
different filenames when redirecting stdin and stdout. In this case, the BASH
shell deletes a pre-existing file before performing the redirect. An example is
shown in the following output:
[root@server1 ~]# sort <newissue >newissue
[root@server1 ~]# cat newissue
[root@server1 ~]#_

Let’s Watch!

Let’s Think!

Quote

87
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

8.1.14 Self-Assessment
Let’s see what you have learned so far by taking this short self-assessment.

The Self-Assessment for this unit is embedded within your Linux MODULE in
myClass. Head on to the quiz to see how you have fared with this section of
content!

Be sure to complete the self-assessment quiz before you move on to the next
section!

8.1.15 Revision Questions

88
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

References
Jason W. Eckert triOS College Linux+ and LPIC-1 Guide to Linux Certification, 5th edition. ISBN:
9781337569798

IMPORTANT TO NOTE FOR EACH Subsection of unit content


Prescriptions for Subsections of Unit Content

Prescribed Learning Activities and Engagements:

Video Content At least ONE video resource to be in each subsection of content. This
is be embedded within the content at the appropriate time as per the
learning design.
Podcast At least ONE podcast to be in each unit.
The podcast must be seen as supplementary to the learning content
and if a podcast is not available on the specific topics at hand, an
adjunct concept/topic can be used that will broaden the general area
knowledge of the subject matter for the student.
Podcasts should not be selected that are only available on
streaming websites that require a subscription.
Thinking Point At least ONE thinking point should be used within each subsection of
content as a way to pause the movement through content and to
provide the chance for the student to think and concretize their
learning or what they have just read. A thinking point may be a
hypothetical, a personal reflection or a question regarding the
content within a different context (application). A thinking point
must be thorough and engaging enough to draw pause and focus
from the student.
Case Studies A case study should be within each unit and can be used in any
relevant subsection of content. The case study should be robust
enough for the student to understand how to apply something or to
see how a function/tool/theory or practice may work in a real-world
environment. A case study should be seen as a way for the student
to be reflected in the learning experience and as such, it is advised
that case studies are selected from local/Afrocentric contexts and
illustrate our commitment to intersectionality within our teaching
and learning approach and philosophy.
Discussion Forum Each unit of study/each week will require at least ONE discussion
forum topics. This can either be embedded within a certain section
of content or it can be at the end of the unit content depending on
the requirements of the module as per the subject matter. The
discussion forum topic/question should robust and dense enough for
the student to be engaged and a reference must be made to the fact

89
22_HE_PT_DP_IT_LNX320_Y3 Damelin©

that the Discussion Forum topic is live and available within the
module page on myClass.
Example/Practice These are to be used within each section that deals with applied
learning – the application of a process, technique, equation or
function. The example is to be used when an example of a problem
and a solution is provided, and the practice is to be used when a
problem is provided for the student to solve.
Vocabulary Vocabulary is to be used within each unit of content where an
important word, term or definition is provided that students are to
take note of.
Glossary The glossary is an LMS activity function and can be inserted into a
guide where the development of a glossary is required and necessary
for the module. This is to be used mainly within NQF 5 modules as it
speaks to the specific level descriptors of that module.
Additional Resource Each subsection of content must have at least THREE additional
resources. These can be supplementary articles and journals,
mixed/multimedia content such as a respected blog, social media
account, news site, music video or audio recording. The additional
resource must be provided by the study guide author if it is an
“attachment” that will require loading into the LMS.
Prescribed Reading Each subsection must refer to a page, section or chapter in the
prescribed reading for the module. The prescribed reading should
indicate to the student where to locate the texts from which the
subsection has been summarised or written. This may be placed at
the start of the subsection, or at the appropriate point where a
student must leave the study guide/lms and read through a text
section in the prescribed reading.
Quote Each subsection of content should have at least ONE quote that is
from a thought leader in the field, or contextualises a section of
learning for the student. The quote must not be inserted as a graphic
but as plan text with the appropriate graphic alongside it.
Self-Assessment Quiz Each unit/week will have a self-assessment quiz for the student.
Within the study guide, the author can refer to the self-assessment
as per the below but must stress that the self-assessment will be live
in the module myClass page for completion.
Referencing

90

You might also like