Linux (Linux+ Preparation) Study Guide
Linux (Linux+ Preparation) Study Guide
Linux
STUDY GUIDE
2022
1
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
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©
4
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
About Damelin
• 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.
• 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
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©
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.
NQF Level 6
Credits 15
1.4 Outcomes
At the end of this module you should be able to:
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
Individual Assignment 1 20
Individual Assignment 2 20
Online Exam 50
TOTAL
Prescribed Reading
11
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
NAME OF TOPIC FOR THE WEEK AS PER THIS GUIDE AND REFLECTIVE OF LMS
1
Introduction to Linux
2 Linux Installation
3 Linux Installation
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©
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©
Time 150
Android
application (app)
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
Let’s Watch!
Let’s Think!
Quote
16
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
Reading
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©
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©
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
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 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!
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.
Time 150
Advanced Technology
Attachment (ATA)
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©
25
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
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
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
Start installation
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.
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!
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!
34
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
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.
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
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
36
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
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©
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©
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
Reading
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©
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©
45
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
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©
48
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
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!
51
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
Time 150
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:
Reading
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
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:
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
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©
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!
61
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
Time 150
bad blocks
blkid command
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
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
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©
71
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
Time 150
1U server
blade server
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©
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
Reading
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!
79
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
Time 150
alias command
branch
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©
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:
81
22_HE_PT_DP_IT_LNX320_Y3 Damelin©
Let’s Watch!
Let’s Think!
Quote
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!
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
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