0% found this document useful (0 votes)
18 views84 pages

Linux 4th It

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)
18 views84 pages

Linux 4th It

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
You are on page 1/ 84

4th-IT

Linux

Eng. Shayma Taref

4th-IT
CIS-College

Chapter1: introduction to Linux.

1.1 Linux is Everywhere


Linux is everywhere; Linux jobs are everywhere. There is a demand for Linux skills in just about
every industry and job category on the planet, and not enough Linux talent to meet this growing
demand. It’s also fun and rewarding to work with something that’s so much a part of our modern
lives yet which so few people understand.

Every time you execute a search on the internet, watch a video on your phone or order something
online, that’s likely Linux at work. It epitomizes a whole that is greater than the sum of its parts, a
vast undertaking, done voluntarily, by some of the smartest people on the planet.
While your journey will be ongoing, be comforted that you are learning a set of technologies,
commands, and methods that have stood the test of time. Linux utilizes and expands upon many of
the commands and ways of accomplishing computing that UNIX began, with a rate of change per
year that’s very manageable. Now, some 30+ years on, many of those learned commands are still
active and used every day by sysadmins, dev ops, and architects. Linux is a revolution of evolution,
allowing you to learn the majority once and keep up with the small percentage of changes in a
continual learning process.

1
CIS-College

1.2 Linux is a Kernel


The definition of the word Linux depends on the context in which it is used. Linux means
the kernel of the system, which is the central controller of everything that happens on the computer.
When most people refer to Linux, they are really referring to a combination of software
called GNU/Linux, which defines the operating system. GNU is the free software that provides open
source equivalents of many common UNIX commands. The Linux part of this combination is
the Linux kernel, which is the core of the operating system. The kernel is loaded at boot time and
stays running to manage every aspect of the functioning system.

The story of Linux begins with UNIX, an operating system developed at AT&T Bell Labs in the 1970s
Linux started in 1991 as a hobby project of Linus Torvalds

2
CIS-College

1.3 Linux is Open Source


Historically, most software has been issued under a closed-source license, meaning that you get the
right to use the machine code, but cannot see the source code. Often the license explicitly says that
you may not attempt to reverse engineer the machine code back to source code to figure out what it
does!
The development of Linux closely parallels the rise of open source software. Open source takes a
source-centric view of software. The open source philosophy is that you have a right to obtain the
software source code and to modify it for your own use.

1.4 Linux Has Distributions


People that say their computer runs Linux usually refer to the kernel, tools, and suite of applications
that come bundled together in what is referred to as a distribution.
Take Linux and the GNU tools, add some user-facing applications like a web browser and an email
client, and you have a full Linux system. Individuals and even companies started bundling all this
software into distributions almost as soon as Linux became usable. The distribution includes tools
that take care of setting up the storage, installing the kernel, and installing the rest of the software.
The full-featured distributions also include tools to manage the system and a package manager to
help you add and remove software after the installation is complete.

1.5 Linux Embraces the CLI


Typically operating systems offer both GUI and CLI interfaces. However, most consumer operating
systems (Windows, macOS) are designed to shield the user from the complexity of the CLI. The
Linux community is different in that it positively celebrates the CLI for its power, speed and ability to
accomplish a vast array of tasks with a single command line instruction.
When a user first encounters the CLI, they can find it challenging because it requires memorizing a
dizzying amount of commands and their options. However, once a user has learned the structure of
how commands are used, where the necessary files and directories are located and how to navigate
the hierarchy of a filesystem, they can be immensely productive. This capability provides more
precise control, greater speed and the ability to easily automate tasks through scripting.
Furthermore, by learning the CLI, a user can easily be productive almost instantly on ANY
distribution of Linux, reducing the amount of time needed to familiarize themselves with a system
because of variations in a GUI.

3
CIS-College

BENFITS OF LUNIX

1.1 Linux is Everywhere


1.2 Linux is a Kernel
1.3 Linux is Open Source
1.4 Linux Has Distributions
1.5 Linux Embraces the CLI

Summary:
1- Linux means the kernel of the system, which is the central controller of everything that
happens on the computer.
2- They are really referring to a group of programs called GNU/Linux,
3- GNU is the free software that provides open source equivalents to many common UNIX
commands.
4- The development of Linux closely parallels the rise of open source software.
5- The open source philosophy is that you have a right to obtain the software source code and
to modify it for your own use.
6- People that say their computer runs Linux usually refer to the kernel, tools, and suite of
applications that come bundled together in what is referred to as a distribution.

7- by learning the CLI, a user can easily be productive almost instantly on ANY distribution of
Linux

4
CIS-College

Chapter 2: Operating Systems

2.1 Operating Systems


An operating system is software that runs on a computing device and manages the hardware and
software components that make up a functional computing system
Modern operating systems don’t just manage hardware and software resources, they schedule
programs to run in a multi-tasking manner (sharing the processor so that multiple tasks can occur
apparently simultaneously), provide standard services that allow users and programs to request
something happen (for example a print job) from the operating system, and provided it’s properly
requested, the operating system will accept
the request and perform the function needed.
Desktop and server operating systems are by nature more complex than an operating system that
runs on a single-purpose device such as a firewall, or a mobile phone. From a simple set-top box
that provides a menu interface for a cable provider, to supercomputers and massive, parallel
computing clusters, the generic term operating system is used to describe whatever software is
booted and run on that device.

5
CIS-College

computing system

Computer users today have a choice mainly between three major operating systems: Microsoft
Windows, Apple macOS, and Linux.

6
CIS-College

2.2 Linux Distributions


Red Hat

Red Hat started as a simple distribution that introduced the Red Hat Package Manager (RPM). The
developer eventually formed a company around it, which tried to commercialize a Linux desktop for
business. Over time, Red Hat started to focus more on the server applications, such as web- and file-
serving and released Red Hat Enterprise Linux (RHEL), which was a paid service on a long release cycle.

SUSE

SUSE, originally derived from Slackware, was one of the first comprehensive Linux distributions, it has
many similarities to Red Hat Enterprise Linux. The original company was purchased by Novell in 2003,
which was then purchased by the Attachmate Group in 2011.

Android

Linux is a kernel, and many of the commands covered in this course are actually part of the GNU
package. That is why some people insist on using the term GNU/Linux instead of Linux alone.

Android, sponsored by Google, is the world’s most popular Linux distribution. It is fundamentally
different from its counterparts. Android uses the Dalvik virtual machine with Linux, providing a robust
platform for mobile devices such as phones and tablets.

Summary
1- An operating system is software that runs on a computing device and manages the hardware
and software components that make up a functional computing system
2- Computer users today have a choice mainly between three major operating
systems: Microsoft Windows, Apple macOS, and Linux.
3- Linux Distributions: Red hat, SUSE, Android

7
CIS-College

8
CIS-College

9
CIS-College

10
CIS-College

11
CIS-College

12
CIS-College

13
CIS-College

Chapter 3 - Working in Linux

3.1 Navigating the Linux Desktop


To be a Linux systems administrator, it is necessary to be comfortable with Linux as a desktop
operating system and have proficiency with basic Information and Communication Technology
(ICT) skills.
Using Linux for productivity tasks, rather than depending on Windows or Macintosh systems.
Most Linux distributions allow users to download a “desktop” installation package that can be
loaded onto a USB key. This is one of the first things aspiring system administrators should do;
download a major distribution and load it onto an old PC.
The Linux desktop should be familiar to anyone who has used a PC or Macintosh with icons to
select different programs and a “settings” application to configure things like user accounts, WiFi
networks, and input devices. After familiarizing oneself with the Linux Graphical User Interface
(GUI), or desktop, the next step is learning how to perform tasks from the command line.

14
CIS-College

3.1.1 Getting to the Command Line


The command line interface (CLI) is a simple text input system for entering anything from single-
word commands to complicated scripts. Most operating systems have a CLI that provides a direct
way of accessing and controlling the computer.

Each Linux desktop distribution is slightly different, but the application terminal or x-term will open
a terminal window from the GUI. While there are subtle differences between the
terms console and terminal window sessions, they are all the same from an administrator’s
standpoint and require the same knowledge of commands to use.

15
CIS-College

3.2 Applications
Applications make requests to the kernel and in return receive resources, such as memory, CPU,
and disk space. If two applications request the same resource, the kernel decides which one gets it,
and in some cases, kills off another application to save the rest of the system and prevent a crash.

The kernel also abstracts some complicated details away from the application. For example, the
application doesn’t know if a block of disk storage is on a solid-state drive, a spinning metal hard
disk, or even a network file share. Applications need only follow the kernel’s Application
Programming Interface (API) and therefore don’t have to worry about the implementation details.

The kernel also handles the switching of applications, a process known as multitasking. A computer
system has a small number of central processing units (CPUs) and a finite amount of memory. The
kernel takes care of unloading one task and loading a new one if there is more demand than
resources available.

When we, as users, think of applications, we tend to think of word processors, web browsers, and
email clients, however, there are a large variety of application types. The kernel doesn’t differentiate
between a user-facing application, a network service that talks to a remote computer, or an internal
task.

3.2.1 Major Applications


Linux software generally falls into one of three categories:

• Server Applications

Software that has no direct interaction with the monitor and keyboard of the machine it runs
on. Its purpose is to serve information to other computers, called clients. Sometimes server
applications may not talk to other computers but only sit there and crunch data.

• Desktop Applications

Web browsers, text editors, music players, or other applications with which users interact
directly. In many cases, such as a web browser, the application is talking to a server on the
other end and interpreting the data. This is the “client” side of a client/server application.

• Tools

A loose category of software that exists to make it easier to manage computer systems.
Tools can help configure displays, provide a Linux shell that users type commands into, or
even more sophisticated tools, called compilers, that convert source code to application
programs that the computer can execute.

16
CIS-College

3.2.2 Server Applications


Linux excels at running server applications because of its reliability and efficiency. The ability to
optimize server operating systems with just needed components allows administrators to do more
with less, a feature loved by startups and large enterprises alike.

3.2.2.1 Web Servers


One of the early uses of Linux was for web servers. A web server hosts content for web pages,
which are viewed by a web browser using the HyperText Transfer Protocol (HTTP) or its
encrypted flavor, HTTPS. The web page itself can either be static or dynamic. When the web
browser requests a static page, the web server sends the file as it appears on disk. In the case of a
dynamic site, the request is sent by the web server to an application, which generates the content.
WordPress is one popular example. Users can develop content through their browser in the
WordPress application, and the software turns it into a fully functional dynamic website.
Apache is the dominant web server in use today. Apache was originally a standalone project, but
the group has since formed the Apache Software Foundation and maintains over a hundred open
source software projects. Apache HTTPD is the daemon, or server application program, that
“serves” web page requests.
Another web server is NGINX, which is based out of Russia. It focuses on performance by making
use of more modern UNIX kernels and only does a subset of what Apache can do. Over 65% of
websites are powered by either NGINX or Apache.

3.2.2.2 Private Cloud Servers


As individuals, organizations, and companies start to move their data to the cloud, there is a growing
demand for private cloud server software that can be deployed and administered internally.
The ownCloud project was launched in 2010 by Frank Karlitschek to provide software to store,
sync and share data from private cloud servers. It is available in a standard open source GNU
AGPLv3 license and an enterprise version that carries a commercial license.
The Nextcloud project was forked from ownCloud in 2016 by Karlitschek and has been growing
steadily since then. It is provided under a GNU AGPLv3 and aims for “an open, transparent
development process.”
Both projects focus on providing private cloud software that meets the needs of both large and small
organizations that require security, privacy, and regulatory compliance. While several other projects
aim to serve the same users, these two are by far the largest in terms of both deployment and
project members.

17
CIS-College

3.2.2.3 Database Servers


Database server applications form the backbone of most online services. Dynamic web applications
pull data from and write data to these applications. For example, a web program for tracking online
students might consist of a front-end server that presents a web form. When data is entered into the
form, it is written to a database application such as MariaDB. When instructors need to access
student information, the web application queries the database and returns the results through the
web application.
MariaDB is a community-developed fork of the MySQL relational database management system. It
is just one of many database servers used for web development as different requirements dictate the
best application for the required tasks.
A database stores information and also allows for easy retrieval and querying. Some other popular
databases are Firebird and PostgreSQL. You might enter raw sales figures into the database
and then use a language called Structured Query Language (SQL) to aggregate sales by
product and date to produce a report.

3.2.2.4 Email Servers


Email has always been a widespread use for Linux servers. When discussing email servers, it is
always helpful to look at the 3 different tasks required to get email between people:

• Mail Transfer Agent (MTA)

The most well known MTA (software that is used to transfer electronic messages to other
systems) is Sendmail. Postfix is another popular one and aims to be simpler and more
secure than Sendmail.

• Mail Delivery Agent (MDA)

Also called the Local Delivery Agent, it takes care of storing the email in the user’s
mailbox. Usually invoked from the final MTA in the chain.

• POP/IMAP Server

The Post Office Protocol (POP) and Internet Message Access Protocol
(IMAP) are two communication protocols that let an email client running on your computer
talk to a remote server to pick up the email.

18
CIS-College

3.2.2.5 File Sharing


For Windows-centric file sharing, Samba is the clear winner. Samba allows a Linux machine to look
and behave like a Windows machine so that it can share files and participate in a Windows domain.
Samba implements the server components, such as making files available for sharing and certain
Windows server roles, and also the client end so that a Linux machine may consume a Windows file
share.
The Netatalk project lets a Linux machine perform as an Apple Macintosh file server. The native
file sharing protocol for UNIX/Linux is called the Network File System (NFS). NFS is usually
part of the kernel which means that a remote file system can be mounted (made accessible) just like
a regular disk, making file access transparent to other applications.
As a computer network becomes more substantial, the need for a directory increases. One of the
oldest network directory systems is the Domain Name System (DNS).
The DNS is focused mainly on computer names and IP addresses and is not easily searchable.
Other directories have sprung up to store information such as user accounts and security roles.
The Lightweight Directory Access Protocol (LDAP) is one common directory system
which also powers Microsoft’s Active Directory. In LDAP, an object is stored in a tree, and the
position of that object on the tree can be used to derive information about the object and what it
stores. For example, a Linux administrator may be stored in a branch of the tree called “IT
Department,” which is under a branch called “Operations.” Thus one can find all the technical staff
by searching under the “IT Department” branch. OpenLDAP is the dominant program used in
Linux infrastructure.
One final piece of network infrastructure to discuss here is called the Dynamic Host
Configuration Protocol (DHCP).

19
CIS-College

3.2.3 Desktop Applications


The Linux ecosystem has a wide variety of desktop applications. There are games, productivity
applications, creative tools, web browsers and more.

3.2.3.1 Email
The Mozilla Foundation came out with Thunderbird, a full-featured desktop email client.
Thunderbird connects to a POP or IMAP server, displays email locally, and sends email through an
external SMTP server.

3.2.3.2 Creative
For the creative types, there is Blender, GIMP (GNU Image Manipulation Program),
and Audacity which handle 3D movie creation, 2D image manipulation, and audio editing
respectively. They have had various degrees of success in professional markets.

3.2.3.3 Productivity
Use of common open source applications in presentations and projects is one way to strengthen
Linux skills. The basic productivity applications, such as a word processor, spreadsheet, and
presentation package are valuable assets. Collectively they’re known as an office suite, primarily
due to Microsoft Office, the dominant player in the market.
LibreOffice is a fork of the OpenOffice (sometimes called OpenOffice.org) application suite.
Both offer a full office suite, including tools that strive for compatibility with Microsoft Office in both
features and file formats.

20
CIS-College

LibreOffice can also work with other file formats, such as Microsoft Office or Adobe Portable
Document Format (PDF) files. Additionally, through the use of extensions, LibreOffice can be
made to integrate with Wiki software to give you a powerful intranet solution.

3.2.3.4 Web Browsers


Linux is a first class citizen for the Mozilla Firefox and Google Chrome browsers. Both are
open source web browsers that are fast, feature-rich, and have excellent support for web
developers.

21
CIS-College

3.3 Console Tools


Historically, the development of UNIX shows considerable overlap between the skills of software
development and systems administration. The tools for managing systems have features of
computer languages such as loops (which allow commands to be carried out repeatedly), and some
computer programming languages are used extensively in automating systems administration tasks.
Thus, one should consider these skills complementary, and at least a basic familiarity with
programming is required for competent systems administrators.

3.3.1 Shells
At the basic level, users interact with a Linux system through a shell whether connecting to the
system remotely or from an attached keyboard. The shell’s job is to accept commands, like file
manipulations and starting applications, and to pass those to the Linux kernel for execution. ⁠ The
Linux shell provides a rich language for iterating over files and customizing the environment, all
without leaving the shell. For example, it is possible to write a single command line that finds files
with contents matching a specific pattern, extracts useful information from the file, then copies the
new information to a new file.
Linux offers a variety of shells to choose from, mostly differing in how and what can be customized,
and the syntax of the built-in scripting language. The two main families are the Bourne shell and
the C shell. The Bourne shell was named after its creator Stephen Bourne of Bell Labs. The C shell
was so named because its syntax borrows heavily from the C language. As both these shells were
invented in the 1970s, there are more modern versions, the Bourne Again Shell (Bash) and
the tcsh (pronounced as tee-cee-shell). Bash is the default shell on most systems, though tcsh is
also typically available.
Programmers have taken favorite features from Bash and tcsh and made other shells, such as
the Korn shell (ksh) and the Z shell (zsh). The choice of shells is mostly a personal one; users
who are comfortable with Bash can operate effectively on most Linux systems. Other shells may
offer features that increase productivity in specific use cases.

3.3.2 Text Editors


Most Linux systems provide a choice of text editors which are commonly used at the console to edit
configuration files. The two main applications are Vi (or the more modern Vim) and Emacs. Both
are remarkably powerful tools to edit text files; they differ in the format of the commands and how
plugins are written for them. Plugins can be anything from syntax highlighting of software projects to
integrated calendars.
Both Vi and Emacs are complex and have a steep learning curve, which is not helpful for simple
editing of a small text file. Therefore, Pico and Nano are available on most systems and provide
very basic text editing.

22
CIS-College

3.7.1 Linux in the Cloud


Linux plays a pivotal role in cloud computing. It powers 90% of the public cloud workload, most
virtual servers are based on some version of the Linux kernel, and Linux is often used to host the
applications behind cloud computing services. So what makes Linux uniquely suited to enabling
cloud computing?
Flexibility
Cloud computing provides the capability to provision IT resources quickly and at any time.
As a result, cloud computing must compensate for the fact that each organization has a unique,
evolving set of resource requirements.
Linux stands out here because it is highly adaptable. For starters, Linux is modular by design, and at
the center of an enormous ecosystem of open source applications providing endless configuration
options to suit various systems and use cases. On top of that, Linux scales efficiently, allowing it to
run anything from a tiny remote sensor to an entire server farm.
Accessibility
In a traditional environment, IT resources are accessed from dedicated devices, such as a desktop
or a laptop. In cloud computing, applications and data reside centrally and are accessed from
anywhere over a network from any device, such as desktop, mobile, or thin client, and there is a
version of Linux for every single one of these devices.
Cost-Effective
Cloud computing is attractive as it has the potential for consumers to reduce their IT costs. In cloud
computing, consumers can unilaterally and automatically scale IT resources to meet workload
demand, thereby eliminating overhead from underutilized resources. Additionally, the expenses
associated with IT configuration, management, floor space, power, and cooling are reduced.
Manageability
While Linux began as a niche operating system, its widespread presence in the IT industry has
made Linux use and administration a necessary skill for IT professionals. It is becoming increasingly
easy for cloud vendors and consumers to acquire the necessary talent, or reallocate existing team
members.
The nature of Linux, built on the C programming language, also lends itself to automated
management tools. A significant portion of Linux servers operating in the cloud are created and
managed by automated management programs rather than human operators. This process frees up
administrators to monitor computing operations rather than manually configuring and updating
systems.
Security
When using a cloud solution, especially a public cloud, an organization may have concerns related
to privacy, external threats, and lack of control over the IT resources and data.
Linux can help offset these issues because it is one of the most secure and reliable operating
systems available.

23
CIS-College

Virtualization
Virtualization is one of the most significant advancements that has contributed to the enablement
cloud of computing.
Linux is a multi-user operating system, which means that many different users can work on the
same system simultaneously and for the most part can’t do things to harm other users. However,
this does have limitations – users can hog disk space or take up too much memory or CPU
resources and make the system slow for everyone. Sharing the system in multi-user mode also
requires that everyone run as unprivileged users, so letting each user run their own web server, for
example, is challenging.
Virtualization is the process where one physical computer, called the host, runs multiple copies of an
operating system, each copy called a guest. These guest images can be pre-configured for specific
functions to allow rapid deployment, often automatically, when needed. The host system runs
software called a hypervisor that switches resources between the various guests just like the Linux
kernel does for individual processes. With bare metal hypervisors, the hypervisor runs directly on
computer hardware rather than on top of an OS freeing up more resources for guest images.
like VMWare and Openbox, you can now take a powerful CPU and by using it to run multiple
virtual machines administrators can optimize usage of physical resources and dramatically reduce
costs over the previous one-machine, one-OS data center model.
Since it is possible to run multiple instances of an operating system on one physical machine and
connect to it over the network, the location of the machine doesn’t matter. Cloud computing takes
this approach and allows administrators to have virtual machines in a remote data center owned by
another company, and only pay for the resources used. Cloud computing vendors can take
advantage of scales of economy to offer computing resources at far lower prices than operating an
on-site data center.
Containers and Bare Metal Deployments
With the rise of containerization technologies like Docker and Kubernetes application software is
now being written that runs in a serverless environment. Essentially, programmers are creating
software that does one single function of a system (like database processing or storage) that runs in
a container. These containers are organized in pods that run within a node and can talk with each
other, and the outside world if needed. Nodes, in turn, are organized and controlled by a master
node that provides services to each component within the structure. Building applications in this way
decouples each of the components from the others, and from the overhead of running an OS. Since
each piece of the puzzle can be automatically destroyed and recreated by the master node they no
longer need to be as robust as software that runs on top of an OS. Although these new programming
architectures are in many ways bypassing the need for a traditional OS the underlying technology
that makes them work is still Linux. So, working in Linux will increasingly be working within a
development team that draws on the disciplines of programming, database design, networking, and
systems administration to create the systems of the future.

24
CIS-College

Summary
1- Using Linux for productivity tasks, rather than depending on Windows or Macintosh
systems.
2- Most Linux distributions allow users to download a “desktop” installation package that
can be loaded onto a USB key. This is one of the first things aspiring system
administrators should do; download a major distribution and load it onto an old PC.

3- The command line interface (CLI) is a simple text input system for entering anything from
single-word commands to complicated scripts. Most operating systems have a CLI that
provides a direct way of accessing and controlling the computer.
4- Each Linux desktop distribution is slightly different, but the application terminal or x-
term will open a terminal window from the GUI.
5- Applications make requests to the kernel and in return receive resources, such as memory,
CPU, and disk space.
6- Linux software generally falls into one of three categories:

Server Applications

Software that has no direct interaction with the monitor and keyboard of the machine it runs
on. Its purpose is to serve information to other computers, called clients. Sometimes server
applications may not talk to other computers but only sit there and crunch data.

Desktop Applications

Web browsers, text editors, music players, or other applications with which users interact
directly. In many cases, such as a web browser, the application is talking to a server on the
other end and interpreting the data. This is the “client” side of a client/server application.

Tools

A loose category of software that exists to make it easier to manage computer systems.
Tools can help configure displays, provide a Linux shell that users type commands into, or
even more sophisticated tools, called compilers, that convert source code to application
programs that the computer can execute.

25
CIS-College

7- 3 different tasks required to get email between people:

• Mail Transfer Agent (MTA)

The most well known MTA (software that is used to transfer electronic messages to other
systems) is Sendmail. Postfix is another popular one and aims to be simpler and more
secure than Sendmail.

• Mail Delivery Agent (MDA)

Also called the Local Delivery Agent, it takes care of storing the email in the user’s
mailbox. Usually invoked from the final MTA in the chain.

• POP/IMAP Server

The Post Office Protocol (POP) and Internet Message Access Protocol
(IMAP) are two communication protocols that let an email client running on your computer
talk to a remote server to pick up the email.

8- At the basic level, users interact with a Linux system through a shell whether connecting to
the system remotely or from an attached keyboard.
9- Most Linux systems provide a choice of text editors which are commonly used at the console
to edit configuration files.
10- Linux plays a pivotal role in cloud computing. It powers 90% of the public cloud workload,
most virtual servers are based on some version of the Linux kernel
11- , Linux scales efficiently, allowing it to run anything from a tiny remote sensor to an entire
server farm.
12- The nature of Linux, built on the C programming language, also lends itself to automated
management tools.
13- Linux is a multi-user operating system
14- Docker and Kubernetes application software is now being written that runs in
a serverless environment

26
CIS-College

Chapter 4 - Open Source Software and


Licensing

4.1 Introduction
Software projects take the form of source code, which is a human-readable set of computer
instructions. Since source code is not understood directly by the computer, it must be compiled into
machine instructions by a compiler. The compiler is a special program that gathers all of the source
code files and generates instructions that can be run on the computer, such as by the Linux kernel.

The development of Linux closely parallels the rise of open source software. Early on there was
shareware, freely available programs where users did not necessarily have access to the source
code. There were a lot of good things about this, but it was also problematic because malicious
programs could be disguised as innocent-looking games, screensavers, and utilities.
Soon, Linux servers and open source programs began to outperform the expensive, proprietary
systems already in place.

Open source software is a collaboration of different people with different needs and backgrounds all
working together to make something better than any one of them could have made individually.
Standards are what makes this possible, and the many organizations that create, maintain and
promote them are integral to the industry.

27
CIS-College

4.2 Open Source Licensing


When talking about buying software, there are three distinct components:

• Ownership – Who owns the intellectual property behind the software?


• Money Transfer – How does money change hands, if at all?
• Licensing – What do you get? What can you do with the software? Can you use it on only
one computer? Can you give it to someone else?

In most cases, the ownership of the software remains with the person or company that created it.
Users are only granted a license to use the software; this is a matter of copyright law. The money
transfer depends on the business model of the creator. It’s the licensing that differentiates open
source software from closed source software.

28
CIS-College

4.2.3 Creative Commons


FOSS licenses are mostly related to software. People have placed works such as drawings and
plans under FOSS licenses, but this was not the intent.
When software has been placed in the public domain, the author has relinquished all rights,
including the copyright on the work. In some countries, this is the default when the work is done by a
government agency. In some countries, copyrighted work becomes public domain after the author
has died and a lengthy waiting period has elapsed.
The Creative Commons (CC) organization has created the Creative Commons Licenses which try
to address the intentions behind FOSS licenses for non-software entities. CC licenses can also be
used to restrict commercial use if that is the desire of the copyright holder. The CC licenses are
made up of the following set of conditions the creator can apply to their work:
• Attribution (BY) – All CC licenses require that the creator must be given credit, without
implying that the creator endorses the use.
• ShareAlike (SA) – This allows others to copy, distribute, perform, and modify the work,
provided they do so under the same terms.
• NonCommercial (NC) – This allows others to distribute, display, perform, and modify the
work for any purpose other than commercially.
• NoDerivatives (ND) – This allows others to distribute, display, and perform only original
copies of the work. They must obtain the creator’s permission to modify it.

29
CIS-College

Summary

1- FOSS licenses are mostly related to software. People have placed works such as drawings and
plans under FOSS licenses, but this was not the intent
2- Creative Commons
An organization created to address the intentions behind FOSS licenses for non-software
entities.

3- The development of Linux closely parallels the rise of open source software

Chapter 5 - Command Line Skills

5.1 Introduction
Most consumer operating systems are designed to shield the user from the ins and outs of the CLI.
The Linux community is different in that it positively celebrates the CLI for its power, speed and
ability to accomplish a vast array of tasks with a single command line instruction.
When a user first encounters the CLI, they can find it challenging because it requires memorizing a
dizzying amount of commands and their options. However, once a user has learned the structure of
how commands are used, where the necessary files and directories are located and how to navigate
the hierarchy of a file system, they can be immensely productive. This capability provides more
precise control, greater speed and the ability to automate tasks more easily through scripting.
Furthermore, by learning the CLI, a user can easily be productive almost instantly on ANY flavor or
distribution of Linux, reducing the amount of time needed to familiarize themselves with a system
because of variations in a GUI.

30
CIS-College

31
CIS-College

5.2 Shell
Once a user has entered a command the terminal then accepts what the user has typed and passes
it to a shell. The shell is the command line interpreter that translates commands entered by a user
into actions to be performed by the operating system. If output is produced by the command, then
text is displayed in the terminal. If problems with the command are encountered, an error message is
displayed.
The Linux environment allows the use of many different shells, some of which have been around for
many years. The most commonly-used shell for Linux distributions is called the Bash shell. Bash
provides many advanced features, such as command history and inline editing, which allows a user
to easily re-execute previously executed commands or a variation of them via simple editing.
The Bash shell also has other popular features, a few of which are listed below:

• Scripting: The ability to place commands in a file and then interpret (effectively use Bash to
execute the contents of) the file, resulting in all of the commands being executed. This
feature also has some programming features, such as conditional statements and the ability
to create functions (AKA subroutines).
• Aliases: The ability to create short nicknames for longer commands.
• Variables: Used to store information for the Bash shell and for the user. These variables can
be used to modify how commands and features work as well as provide vital system
information.

Bash has an extensive feature list; this is only a sampling of its capabilities.
When a terminal application is run, and a shell appears, displaying an important part of the
interface—the prompt. Not only is the prompt there to indicate that commands can be run,
but it also conveys useful information to the user. The prompt is fully configurable and can be
as sparse or as full-featured as is practical and useful.
The structure of the prompt may vary between distributions, but typically contains information
about the user and the system. Below is a common prompt structure:

32
CIS-College

The ~ symbol is used as shorthand for the user's home directory. Typically the home directory for
the user is under the /home directory and named after the user account name; for
example, /home/sysadmin.

5.3 Commands
What is a command? The simplest answer is that a command is a software program that, when
executed on the CLI, performs an action on the computer.
To execute a command, the first step is to type the name of the command. Click in the terminal on
the right. Type ls and hit Enter. The result should resemble the example below:

sysadmin@localhost:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos

Many commands can be used by themselves with no further input. Some commands require
additional input to run correctly. This additional input comes in two forms: options and arguments.
The typical format for a command is as follows:

command [options] [arguments]

Options are used to modify the core behavior of a command while arguments are used to provide
additional information (such as a filename or a username). Each option and argument is normally
separated by a space, although options can often be combined.

33
CIS-College

5.3.1 Arguments
command [options] [arguments]

An argument can be used to specify something for the command to act upon. If the ls command is
given the name of a directory as an argument, it lists the contents of that directory. In the following
example, the /etc/ppp directory is used as an argument; the resulting output is a list of files
contained in that directory:

sysadmin@localhost:~$ ls /etc/ppp
ip-down.d ip-up.d

The ls command also accepts multiple arguments. To list the contents of both
the /etc/ppp and /etc/ssh directories, pass them both as arguments:

sysadmin@localhost:~$ ls /etc/ppp /etc/ssh


/etc/ppp:
ip-down.d ip-up.d
/etc/ssh:
moduli ssh_host_dsa_key.pub ssh_host_rsa_key sshd_conf
igssh_config
ssh_host_ecdsa_key ssh_host_rsa_key.pub
ssh_host_dsa_key ssh_host_ecdsa_key.pub ssh_import_id

5.3.2 Options
command [options] [arguments]

Options can be used with commands to expand or modify the way a command behaves. For
example, using the -l option of the ls command results in a long listing, providing additional
information about the files that are listed, such as the permissions, the size of the file and other
information:

sysadmin@localhost:~$ ls -l
total 0
drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Desktop
drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Documents
drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Downloads
drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Music

34
CIS-College

drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Pictures


drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Public
drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Templates
drwxr-xr-x 1 sysadmin sysadmin 0 Jan 29 20:13 Videos

Note that, in the command above, -l is a lowercase letter "L". An easy way to remember this is -l is
a mnemonic (easy to memorize programming code) for long listing).

Often the character is chosen to be mnemonic for its purpose, like choosing the
letter l for long or r for reverse. By default, the ls command prints the results in alphabetical order,
and so by adding the -r option, it prints the results in reverse alphabetical order.

sysadmin@localhost:~$ ls -r
Videos Templates Public Pictures Music Downloads Documents Desktop

In most cases, options can be used in conjunction with other options. They can be given as separate
options, as in -l -r, or combined, as in -lr. The combination of these two options would result in a
long listing output in reverse alphabetical order:

sysadmin@localhost:~$ ls -lr
total 32
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Videos
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Templates
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Public
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Pictures
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Music
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Downloads
drwxr-xr-x 4 sysadmin sysadmin 4096 Oct 31 20:13 Documents
drwxr-xr-x 2 sysadmin sysadmin 4096 Oct 31 20:13 Desktop

The order of the combined options isn't important. The output of all of these examples would be the
same:

ls -l -r
ls -rl
ls -lr

By default the -l option of the ls command displays files sizes in bytes:

sysadmin@localhost:~$ ls -l /usr/bin/perl
-rwxr-xr-x 2 root root 10376 Feb 4 2018 /usr/bin/perl

35
CIS-College

If the -h option is added the file sizes will be displayed in human-readable format:

sysadmin@localhost:~$ ls -lh /usr/bin/perl


-rwxr-xr-x 2 root root 11K Feb 4 2018 /usr/bin/perl

Options are often single letters; however, sometimes they are words or phrases as well. Typically,
older commands use single letters while newer commands use complete words for options. Single-
letter options are preceded by a single dash - character, like the -h option. Full-word options are
preceded by two dash -- characters. The -h option also has an equivalent full-word form; the --
human-readable option.

sysadmin@localhost:~$ ls -l --human-readable /usr/bin/perl


-rwxr-xr-x 2 root root 11K Feb 4 2018 /usr/bin/perl

5.3.3 History
When a command is executed in the terminal, it is stored in a history list. This is designed to make it
easy to execute the same command, later eliminating the need to retype the entire command.
Pressing the Up Arrow ↑ key displays the previous command on the prompt line. The entire history
of commands run in the current session can be displayed by pressing Up repeatedly to move back
through the history of commands that have been run. Pressing the Enter key runs the displayed
command again.
When the desired command is located, the Left Arrow ← and Right Arrow → keys can position the
cursor for editing. Other useful keys for editing include
the Home, End, Backspace and Delete keys.
To view the history list of a terminal, use the history command:

sysadmin@localhost:~$ date
Wed Dec 12 04:28:12 UTC 2018
sysadmin@localhost:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
sysadmin@localhost:~$ cal 5 2030
May 2030
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

36
CIS-College

sysadmin@localhost:~$ history
1 date
2 ls
3 cal 5 2030
4 history

If the desired command is in the list that the history command generates, it can be executed by
typing an exclamation point ! character and then the number next to the command, for example, to
execute the cal command again:

sysadmin@localhost:~$ history
1 date
2 ls
3 cal 5 2030
4 history
sysadmin@localhost:~$ !3
cal 5 2030
May 2030
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25

If the history command is passed a number as an argument, it outputs that number of previous
commands from the history list. For example, to show the last three commands:

sysadmin@localhost:~$ history 3
6 date
7 ls /home
8 history 3

⁠ To execute the nth command from the bottom of the history list, type !-n and hit Enter. For example,
to execute the third command from the bottom of the history list execute the following:

sysadmin@localhost:~$ !-3
date
Wed Dec 12 04:31:55 UTC 2018

37
CIS-College

To execute the most recent command type !! and hit Enter:

sysadmin@localhost:~$ date
Wed Dec 12 04:32:36 UTC 2018
sysadmin@localhost:~$ !!
date
Wed Dec 12 04:32:38 UTC 2018

To execute the most recent iteration of a specific command, type ! followed by the name of the
command and hit Enter. For example, to execute the most recent ls command:

sysadmin@localhost:~$ !ls
ls /home
sysadmin

5.4 Variables
A variable is a feature that allows the user or the shell to store data. This data can be used to
provide critical system information or to change the behavior of how the Bash shell (or other
commands) work. Variables are given names and stored temporarily in memory. There are two
types of variables used in the Bash shell: local and environment.

38
CIS-College

5.4.1 Local Variables


Local or shell variables exist only in the current shell, and cannot affect other commands or
applications. When the user closes a terminal window or shell, all of the variables are lost. They are
often associated with user-based tasks and are lowercase by convention.
To set the value of a variable, use the following assignment expression. If the variable already
exists, the value of the variable is modified. If the variable name does not already exist, the shell
creates a new local variable and sets the value:

variable=value

The following example creates a local variable named variable1 and assigns it a value
of Something:

sysadmin@localhost:~$ variable1='Something'

The echo command is used to display output in the terminal. To display the value of the variable,
use a dollar sign $ character followed by the variable name as an argument to the echo command:

sysadmin@localhost:~$ echo $variable1


Something

5.4.2 Environment Variables


Environment variables, also called global variables, are available system-wide, in all shells used by
Bash when interpreting commands and performing tasks. The system automatically recreates
environment variables when a new shell is opened. Examples include the PATH, HOME,
and HISTSIZE variables. The HISTSIZE variable defines how many previous commands to store in
the history list. The command in the example below displays the value of the HISTSIZE variable:

sysadmin@localhost:~$ echo $HISTSIZE


1000

To modify the value of an existing variable, use the assignment expression:

sysadmin@localhost:~$ HISTSIZE=500
sysadmin@localhost:~$ echo $HISTSIZE
500

Many variables are available for the Bash shell, as well as variables that affect different Linux
commands. A discussion of all variables is beyond the scope of this chapter; however, more shell
variables will be covered as this course progresses.

39
CIS-College

When run without arguments, the env command outputs a list of the environment variables. Because
the output of the env command can be quite long, the following examples use a text search to filter
that output.
In a previous example variable1 was created as a local variable, so the following search in the
environment variables results in no output:

sysadmin@localhost:~$ env | grep variable1

The pipe | character passes the output of the env command to the grep command, which searches
the output.
This text filtering technique will be covered in detail later in the course.
The export command is used to turn a local variable into an environment variable.

export variable

After exporting variable1, it is now an environment variable. It is now found in the search through
the environment variables:

sysadmin@localhost:~$ export variable1


sysadmin@localhost:~$ env | grep variable1
variable1=Something

The export command can also be used to make a variable an environment variable upon its
creation by using the assignment expression as the argument:

sysadmin@localhost:~$ export variable2='Else'


sysadmin@localhost:~$ env | grep variable2
variable2=Else

To change the value of an environment variable, use the assignment expression:

sysadmin@localhost:~$ variable1=$variable1' '$variable2


sysadmin@localhost:~$ echo $variable1
Something Else

Exported variables can be removed using the unset command:

sysadmin@localhost:~$ unset variable2

40
CIS-College

5.4.3 Path Variable


One of the most important Bash shell variables to understand is the PATH variable. It contains a list
that defines which directories the shell looks in to find commands. If a valid command is entered and
the shell returns a "command not found" error, it is because the Bash shell was unable to locate a
command by that name in any of the directories included in the path. The following command
displays the path of the current shell:

sysadmin@localhost:~$ echo $PATH


/home/sysadmin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/b
in:/usr/games
sysadmin@localhost:~$

Each directory in the list is separated by a colon : character. Based on the preceding output, the
path contains the following directories. The shell will check the directories in the order they are listed:

/home/sysadmin/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games

Each of these directories is represented by a path. A path is a list of directories separated by the /
character. If you think of the filesystem as a map, paths are the directory addresses, which include
step-by-step navigation directions; they can be used to indicate the location of any file within the
filesystem. For example, /home/sysadmin is a path to the home directory:

Directories and paths will be covered in detail later in the course.

41
CIS-College

If the command is not found in any directory listed in the PATH variable, then the shell returns an
error:

sysadmin@localhost:~$ zed
-bash: zed: command not found
sysadmin@localhost:~$

⁠ If custom software is installed on the system it may be necessary to modify the PATH to make it
easier to execute these commands. For example, the following will add and verify
the /usr/bin/custom directory to the PATH variable:

sysadmin@localhost:~$ PATH=/usr/bin/custom:$PATH
sysadmin@localhost:~$ echo $PATH
/usr/bin/custom:/home/sysadmin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/
usr/bin:/sbin:/bin:/usr/games

When updating the PATH variable, always include the current path, so as not to lose access to
commands located in those directories. This can be accomplished by appending $PATH to the value
in the assignment expression. Recall that a variable name preceded by a dollar sign represents the
value of the variable.

5.5 Command Types


One way to learn more about a command is to look at where it comes from. The type command can
be used to determine information about command type.

type command

There are several different sources of commands within the shell of your CLI including internal
commands, external commands, aliases, and functions.

42
CIS-College

5.5.1 Internal Commands


Also called built-in commands, internal commands are built into the shell itself. A good example
is the cd (change directory) command as it is part of the Bash shell. When a user types
the cd command, the Bash shell is already executing and knows how to interpret it, requiring no
additional programs to be started.
The type command identifies the cd command as an internal command:

sysadmin@localhost:~$ type cd
cd is a shell builtin

5.5.2 External Commands


External commands are binary executables stored in directories that are searched by the shell. If
a user types the ls command, then the shell searches through the directories that are listed in
the PATH variable to try to find a file named ls that it can execute.
If a command does not behave as expected or if a command is not accessible that should be, it can
be beneficial to know where the shell is finding the command or which version it is using. It would be
tedious to have to manually look in each directory that is listed in the PATH variable. Instead, use
the which command to display the full path to the command in question:

which command

The which command searches for the location of a command by searching the PATH variable.

sysadmin@localhost:~$ which ls
/bin/ls
sysadmin@localhost:~$ which cal
/usr/bin/cal

External commands can also be executed by typing the complete path to the command. For
example, to execute the ls command:

sysadmin@localhost:~$ /bin/ls
Desktop Documents Downloads Music Pictures Public Templates Videos

For external commands, the type command displays the location of the command:

sysadmin@localhost:~$ type cal


cal is /usr/bin/cal

In some cases the output of the type command may differ significantly from the output of
the which command:

43
CIS-College

sysadmin@localhost:~$ type echo


echo is a shell builtin
sysadmin@localhost:~$ which echo
/bin/echo

Using the -a option of the type command displays all locations that contain the command named:

sysadmin@localhost:~$ type -a echo


echo is a shell builtin
echo is /bin/echo

5.5.3 Aliases
An alias can be used to map longer commands to shorter key sequences. When the shell sees an
alias being executed, it substitutes the longer sequence before proceeding to interpret commands.
For example, the command ls -l is commonly aliased to l or ll. Because these smaller
commands are easier to type, it becomes faster to run the ls -l command line.
To determine what aliases are set on the current shell use the alias command:

sysadmin@localhost:~$ alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

The aliases from the previous examples were created by initialization files. These files are designed
to make the process of creating aliases automatic.
New aliases can be created using the following format, where name is the name to be given the
alias and command is the command to be executed when the alias is run.

44
CIS-College

alias name=command

For example, the cal 2019 command displays the calendar for the year 2019. Suppose you end up
running this command often. Instead of executing the full command each time, you can create an
alias called mycal and run the alias, as demonstrated in the following graphic:

sysadmin@localhost:~$ alias mycal="cal 2019"


sysadmin@localhost:~$ mycal
2019
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 1 2 1 2
6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9
13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16
20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23
27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30
31

Aliases created this way only persist while the shell is open. Once the shell is closed, the new
aliases are lost. Additionally, each shell has its own aliases, so aliases created in one shell won’t be
available in a new shell that’s opened.
The type command can identify aliases to other commands:

sysadmin@localhost:~$ type ll
ll is aliased to `ls -alF'
sysadmin@localhost:~$ type -a ls
ls is aliased to `ls --color=auto'
ls is /bin/ls

The output of these commands indicates that ll is an alias for ls -alF, and even ls is an alias
for ls --color=auto.

45
CIS-College

5.5.4 Functions
Functions can also be built using existing commands to either create new commands, or to override
commands built-in to the shell or commands stored in files. Aliases and functions are normally
loaded from the initialization files when the shell first starts.
Functions are more advanced than aliases and typically are used in Bash shell scripts. Typically,
functions are used to execute multiple commands. To create a function, the following syntax is used:

function_name ()
{
commands
}

In the format above, function_name can be anything that the administrator wants to call the function.
The commands that the administrator wants to execute can replace the commands placeholder.
Note the formatting, in particular, the location of the parenthesis () and braces {}, as well as the
convention of using tabs to make the function more easily readable.
Functions are useful as they allow for a set of commands to be executed one at a time instead of
typing each command repeatedly. In the example below, a function called my_report is created to
execute the ls, date, and echo commands.

sysadmin@localhost:~$ my_report () {
> ls Documents
> date
> echo "Document directory report"
> }

When creating a function, a > character will appear as a prompt to enter the commands for the
function. The curly braces {} are used to let the shell know when a function begins and ends so as
to exit the > prompt.

46
CIS-College

Once a function is created, the function name may be invoked from the BASH prompt to execute the
function:

sysadmin@localhost:~$ my_report
School alpha-third.txt hidden.txt numbers.txt spelling.txt
Work alpha.txt letters.txt os.csv words
adjectives.txt animals.txt linux.txt people.csv
alpha-first.txt food.txt longfile.txt profile.txt
alpha-second.txt hello.sh newhome.txt red.txt
Wed Oct 13 06:54:04 UTC 2021
Document directory report
sysadmin@localhost:~$

47
CIS-College

5.6 Quoting
Quotation marks are used throughout Linux administration and most computer programming
languages to let the system know that the information contained within the quotation marks should
either be ignored or treated in a way that is very different than it would normally be treated. There
are three types of quotes that have special significance to the Bash shell: double quotes ", single
quotes ', and back quotes `. Each set of quotes alerts the shell not to treat the text within the
quotes in the normal way.

5.6.1 Double Quotes


Double quotes stop the shell from interpreting some metacharacters (special characters), including
glob characters.
Glob characters, also called wild cards, are symbols that have special meaning to the shell; they
are interpreted by the shell itself before it attempts to run any command. Glob characters include the
asterisk * character, the question ? mark character, and the brackets [ ], among others.
Globbing will be covered in greater detail later in the course.
Within double quotes an asterisk is just an asterisk, a question mark is just a question mark, and so
on, which is useful when you want to display something on the screen that is normally a special
character to the shell. In the echo command below, the Bash shell doesn't convert the glob pattern
into filenames that match the pattern:

sysadmin@localhost:~$ echo "The glob characters are *, ? and [ ]"


The glob characters are *, ? and [ ]

Double quotes still allow for command substitution, variable substitution, and permit some
other shell metacharacters that haven't been discussed yet. The following demonstration shows that
the value of the PATH variable is still displayed:

sysadmin@localhost:~$ echo "The path is $PATH"


The path is /usr/bin/custom:/home/sysadmin/bin:/usr/local/sbin:/usr/local/bin
:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

48
CIS-College

5.6.2 Single Quotes


Single quotes prevent the shell from doing any interpreting of special characters, including globs,
variables, command substitution and other metacharacters that have not been discussed yet.
For example, to make the $ character simply mean a $, rather than it acting as an indicator to the
shell to look for the value of a variable, execute the second command displayed below:

sysadmin@localhost:~$ echo The car costs $100


The car costs 00
sysadmin@localhost:~$ echo 'The car costs $100'
The car costs $100

5.6.3 Backslash Character


There is also an alternative technique to essentially single quote a single character. Consider the
following message:

The service costs $1 and the path is $PATH

If this sentence is placed in double quotes, $1 and $PATH are considered variables.

sysadmin@localhost:~$ echo "The service costs $1 and the path is $PATH"

⁠The service costs and the path is /usr/bin/custom:/home/sysadmin/bin:/usr/lo


cal/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

If it is placed in single quotes, $1 and $PATH are not considered variables.

sysadmin@localhost:~$ echo 'The service costs $1 and the path is $PATH'


The service costs $1 and the path is $PATH

But what if you want to have $PATH treated as a variable and $1 not?
In this case, use a backslash \ character in front of the dollar sign $ character to prevent the shell
from interpreting it. The command below demonstrates using the \ character:

sysadmin@localhost:~$ echo The service costs \$1 and the path is $PATH
The service costs $1 and the path is /usr/bin/custom:/home/sysadmin/bin:/usr/
local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

49
CIS-College

5.6.4 Backquotes
Backquotes, or backticks, are used to specify a command within a command, a process
called command substitution. This allows for powerful and sophisticated use of commands.
While it may sound confusing, an example should make things more clear. To begin, note the output
of the date command:

sysadmin@localhost:~$ date
Mon Nov 4 03:35:50 UTC 2018

Now, note the output of the echo command:

sysadmin@localhost:~$ echo Today is date


Today is date

In the previous command, the word date is treated as regular text, and the shell passes date to
the echo command. To execute the date command and have the output of that command sent to
the echo command, put the date command in between two backquote characters:

sysadmin@localhost:~$ echo Today is `date`


Today is Mon Nov 4 03:40:04 UTC 2018

5.7 Control Statements


Control statements allow you to use multiple commands at once or run additional commands,
depending on the success of a previous command. Typically these control statements are used
within scripts, but they can also be used on the command line as well.

50
CIS-College

5.7.1 Semicolon
command1; command2; command3

The semicolon ; character can be used to run multiple commands, one after the other. Each
command runs independently and consecutively; regardless of the result of the first command, the
second command runs once the first has completed, then the third and so on.
For example, to print the months of January, February and March of 2030, execute the following
command:

sysadmin@localhost:~$ cal 1 2030; cal 2 2030; cal 3 2030


January 2030
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

February 2030
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28

March 2030
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

51
CIS-College

5.7.2 Double Ampersand


command1 && command2

The double ampersand && acts as a logical "and"; if the first command is successful, then the
second command will also run. If the first command fails, then the second command will not run.
To better understand how this works, consider first the concept of failure and success for
commands. Commands succeed when they work properly and fail when something goes wrong. For
example, consider the ls command. The command succeeds if the given directory is accessible and
fails if it isn't.
In the following example, the first command succeeds because the /etc/ppp directory exists and is
accessible while the second command fails because there is no /junk directory:

sysadmin@localhost:~$ ls /etc/ppp
ip-down.d ip-up.d
sysadmin@localhost:~$ ls /etc/junk
ls: cannot access /etc/junk: No such file or directory

To use the success or failure of the ls command in conjunction with && execute commands like the
following. In the first example, the echo command is executed because the ls command succeeds:

sysadmin@localhost:~$ ls /etc/ppp && echo success


ip-down.d ip-up.d
success

In the second example, the echo command isn't executed because the ls command fails:

sysadmin@localhost:~$ ls /etc/junk && echo success


ls: cannot access /etc/junk: No such file or directory

52
CIS-College

5.7.3 Double Pipe


command1 || command2

The double pipe || is a logical "or". Depending on the result of the first command, the second
command will either run or be skipped.
With the double pipe, if the first command runs successfully, the second command is skipped; if the
first command fails, then the second command is run. In other words, you are essentially telling the
shell, "Either run this first command or the second one”.
In the following example, the echo command only executes if the ls command fails:

sysadmin@localhost:~$ ls /etc/ppp || echo failed


ip-down.d ip-up.d
sysadmin@localhost:~$ ls /etc/junk || echo failed
ls: cannot access /etc/junk: No such file or directory
failed

53
CIS-College

Summary
1- Bash
The most commonly used shell for Linux distributions.
2- PATH environment variable
Variable containing a list that defines which directories the shell looks in for commands.

3- echo
Command that displays output in the terminal.
4- export
Command that turns a local variable into an environment variable.
5- history
Command that outputs a list of previously executed commands.
6- type
Command that determines information about command type

7- Quotes
Quotation marks are used throughout Linux administration and most computer programming
languages to let the system know that the information contained within the quotation marks
should either be ignored or treated in a way that is very different than it would normally be
treated.

There are three types of quotes that have special significance to the Bash shell: double quotes ",
single quotes ', and back quotes `. Each set of quotes alerts the shell not to treat the text within
the quotes in the normal way.

8- Bash provides many advanced features, such as command history and inline editing, which
allows a user to easily re-execute previously executed commands or a variation of them via
simple editing.

• Scripting: The ability to place commands in a file and then interpret (effectively use Bash to
execute the contents of) the file, resulting in all of the commands being executed. This
feature also has some programming features, such as conditional statements and the ability
to create functions (AKA subroutines).
• Aliases: The ability to create short nicknames for longer commands.
• Variables: Used to store information for the Bash shell and for the user. These variables can
be used to modify how commands and features work as well as provide vital system
information.

54
CIS-College

Chapter 6 - Getting Help

6.1 Introduction
There are thousands of commands available with many options, making the command line a
powerful tool. However, with this power comes complexity. Complexity, in turn, can create confusion.
As a result, knowing how to find help while working in Linux is an essential skill for any user.
Referring to help provides a quick reminder of how a command works, as well as being an
information resource when learning new commands.

55
CIS-College

6.2 Man Pages


UNIX is the operating system that Linux was modeled after. The developers of UNIX created help
documents called man pages (short for manual pages).
Man pages are used to describe the features of commands. They provide a basic description of the
purpose of the command, as well as details regarding available options.

56
CIS-College

6.2.1 Viewing Man Pages


To view a man page for a command, use the man command:

man command

For example, the following displays the man page for the ls command:

sysadmin@localhost:~$ man ls

Navigate the document using the arrow keys:

LS(1) User Commands LS(1


)

NAME
ls - list directory contents

SYNOPSIS
ls [OPTION]... [FILE]...

DESCRIPTION
List information about the FILEs (the current directory by default)
.
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci
-
fied.

Mandatory arguments to long options are mandatory for short option


s
too.

-a, --all
do not ignore entries starting with .

To exit viewing a man page, use the Q key.

57
CIS-College

Consider This
The man command uses a pager to display documents. Usually, this pager is the less command, but
on some distributions, it may be the more command. Both are very similar in how they perform.
To view the various movement commands that are available, use the H key while viewing a man
page. This displays a help page.
Pagers will be discussed in more detail later in the course.

58
CIS-College

6.2.2 Sections Within Man Pages


Man pages are broken into sections. Each section is designed to provide specific information about
a command. While there are common sections seen in most man pages, some developers also
create sections only available on specific man pages.
The following describes some of the more common sections found in man pages:
NAME
Provides the name of the command and a very brief description.

NAME
ls - list directory contents

SYNOPSIS
Provides examples of how the command is executed.

SYNOPSIS
ls [OPTION]... [FILE]...

The SYNOPSIS section of a man page can be difficult to understand but is very important because it
provides a concise example of how to use the command. For example, consider the SYNOPSIS of
the man page for the cal command:

SYNOPSIS
cal [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]

The square brackets [ ] are used to indicate that this feature is not required to run the command.
For example, [-31jy] means options -3, -1, -j, or -y are available, but not required for
the cal command to function properly.
The last set of square brackets [[month] year] demonstrates another feature; it means a year
can be specified by itself, but to specify a month the year must also be specified.
Another component of the SYNOPSIS that might cause some confusion can be seen in the man
page of the date command:

SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]


In this SYNOPSIS there are two syntaxes for the date command. The first one is used to display the
date on the system while the second is used to set the date.
The ellipsis ... following [OPTION] indicates that one or more of the items before it may be used.

59
CIS-College

Additionally, the [-u|--utc|--universal] notation means that either the -u option or the --
utc option or the --universal option may be used. Typically this means that all three options really
do the same thing, but sometimes the use of the | character is used to indicate that the options can't
be used in combination, like a logical “or".
DESCRIPTION
Provides a more detailed description of the command.

DESCRIPTION
List information about the FILEs (the current directory by default)
.
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci
-
fied.

OPTIONS
Lists the options for the command as well as a description of how they are used. Often this
information is found in the DESCRIPTION section and not in a separate OPTIONS section.

-a, --all
do not ignore entries starting with .

-A, --almost-all
do not list implied . and ..

--author
with -l, print the author of each file

-b, --escape
print C-style escapes for nongraphic characters

--block-size=SIZE
scale sizes by SIZE before printing them; e.g., '--block-size=M
'
prints sizes in units of 1,048,576 bytes; see SIZE format below

FILES
Lists the files that are associated with the command as well as a description of how they are used.
These files may be used to configure the command's more advanced features. Often this information
is found in the DESCRIPTION section and not in a separate FILES section.

60
CIS-College

AUTHOR
Provides the name of the person who created the man page and (sometimes) how to contact the
person.

AUTHOR
Written by Richard M. Stallman and David MacKenzie.

REPORTING BUGS
Provides details on how to report problems with the command.

REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report ls translation bugs to <http://translationproject.org/team/>

COPYRIGHT
Provides basic copyright information.

COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GN
U
GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it
.
There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
Provides you with an idea of where you can find additional information. This often includes other
commands that are related to this command.

SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/ls>
or available locally via: info '(coreutils) ls invocation'

61
CIS-College

6.2.3 Searching Man Pages


To search a man page for a term, type the / character followed by a search term, then hit
the Enter key. The program searches from the current location down towards the bottom of the page
to try to locate and highlight the term.
If a match is found, it will be highlighted. To move to the next match of the term, press n. To return to
a previous match of the term, press Shift+N. If the term is not found, or upon reaching the end of the
matches, the program will report Pattern not found (press Return).

62
CIS-College

6.2.4 Man Pages Categorized by Sections


Until now, we have been displaying man pages for commands. However, there are several different
types of commands (user commands, system commands, and administration commands),
configuration files and other features, such as libraries and kernel components, that require
documentation.
As a result, there are thousands of man pages on a typical Linux distribution. To organize all of
these man pages, they are categorized by sections.
By default, there are nine sections of man pages:

1. General Commands
2. System Calls
3. Library Calls
4. Special Files
5. File Formats and Conventions
6. Games
7. Miscellaneous
8. System Administration Commands
9. Kernel Routines

The man command searches each of these sections in order until it finds the first match. For
example, if you execute the command man cal, the first section (General Commands) is searched
for a man page called cal. If not found, then the second section is searched. If no man page is
found after searching all sections, an error message is returned:

sysadmin@localhost:~$ man zed


No manual entry for zed

To determine which section a specific man page belongs to, look at the numeric value on the first
line of the output of the man page. For example, the cal command belongs to the first section of
man pages:

CAL(1) BSD General Commands Manual CAL(1)

Sometimes there are man pages with the same name in different sections. In these cases, it may be
necessary to specify the section of the correct man page.
For example, there is a command called passwd that allows you to change your password. There is
also a file called passwd that stores account information. Both the command and the file have a man
page.
The passwd command is a user command, so the associated man page is in the first section.
The man command displays the man page for the passwd command by default:

sysadmin@localhost:~$ man passwd


PASSWD(1) User Commands PASSWD(1)

So how do you display the man page for the passwd file? First, determine in which section the man
page is located. To search for man pages by name, use the -f option to the man command. It

63
CIS-College

displays man pages that match, or partially match, a specific name and provide the section number
and a brief description of each man page:

sysadmin@localhost:~$ man -f passwd


passwd (5) - the password file
passwd (1) - change user password
passwd (1ssl) - compute password hashes

Note: On most Linux distributions, the whatis command does the same thing as man -f. On those
distributions, both will produce the same output.
To specify a different section, provide the number of the section as the first argument of the man
command. The following command displays the passwd man page located in section 5, which is
associated with the passwd file:

sysadmin@localhost:~$ man 5 passwd


PASSWD(5) File Formats and Conversions PASSWD(5)

Unfortunately, you won't always remember the exact name of the man page that you want to view.
Fortunately, each man page has a short description associated with it. The -k option to
the man command searches both the names and descriptions of the man pages for a keyword.
For example, to find a man page that displays how to copy directories, search for the keyword copy:

sysadmin@localhost:~$ man -k copy


cp (1) - copy files and directories
cpgr (8) - copy with locking the given file to the password or gr
...
cpio (1) - copy files to and from archives
cppw (8) - copy with locking the given file to the password or gr
...
dd (1) - convert and copy a file
debconf-copydb (1) - copy a debconf database
install (1) - copy files and set attributes
scp (1) - secure copy (remote file copy program)
ssh-copy-id (1) - use locally available keys to authorize logins on a re
...

Recall that there are thousands of man pages, so when searching for a keyword, be as specific as
possible. Using a generic word, such as "the", could result in hundreds or even thousands of results.
Note: On most Linux distributions, the apropos command does the same thing as man -k. On those
distributions, both produce the same output.

64
CIS-College

6.3 Finding Commands and Documentation


The whatis command (or man -f) returns what section a man page is stored in. This command
occasionally returns unusual output, such as the following:

sysadmin@localhost:~$ whatis ls
ls (1) - list directory contents
ls (lp) - list directory contents

Note
The example above is designed to demonstrate a scenario where two commands list directory
contents. The output in the example terminal above may not match the output in the VM.
Based on this output, there are two ls commands that list directory contents. The simple reason for
this is that UNIX had two main variants, which resulted in some commands being developed "in
parallel" and therefore behaving differently on different variants of UNIX. Many modern distributions
of Linux include commands from both UNIX variants.
This does, however, pose a bit of a problem: when the ls command is typed, which command is
executed?

6.3.1 Where Are These Commands Located?


To search for the location of a command or the man pages for a command, use
the whereis command. This command searches for commands, source files and man pages in
specific locations where these files are typically stored:

sysadmin@localhost:~$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1.gz /usr/share/man/man1/ls.1.gz

Man pages are easily distinguished from commands as they are typically compressed with a
program called gzip, resulting in a filename that ends in .gz. Notice there are two man pages listed
above, but only one command: /bin/ls. This is because the ls command can be used with the
options/features that are described by either man page. So, when learning what can be done with
the ls command, it may be interesting to explore both man pages. Fortunately, this is more of an
exception as most commands only have one man page.

65
CIS-College

6.3.2 Find Any File or Directory


The whereis command is specifically designed to find commands and man pages. While this is
useful, it is often necessary to find a file or directory, not just files that are commands or man pages.
To find any file or directory, use the locate command. This command searches a database of all
files and directories that were on the system when the database was created. Typically, the
command to generate this database is run nightly.

sysadmin@localhost:~$ locate gshadow


/etc/gshadow
/etc/gshadow-
/usr/include/gshadow.h
/usr/share/man/cs/man5/gshadow.5.gz
/usr/share/man/da/man5/gshadow.5.gz
/usr/share/man/de/man5/gshadow.5.gz
/usr/share/man/fr/man5/gshadow.5.gz
/usr/share/man/it/man5/gshadow.5.gz
/usr/share/man/man5/gshadow.5.gz
/usr/share/man/ru/man5/gshadow.5.gz
/usr/share/man/sv/man5/gshadow.5.gz
/usr/share/man/zh_CN/man5/gshadow.5.gz

Any files created today will not be searchable with the locate command. If root access is available,
it’s possible to update the locate database manually by running the updatedb command. Regular
users cannot update the database file.
Also note that when using the locate command as a regular user, the output may be limited due to
file permissions. If the user that is logged in doesn’t have access to a file or directory on the
filesystem due to permissions, the locate command won't return those names. This security feature
is designed to keep users from "exploring" the filesystem by using the locate database.
The root user can search for any file in the locate database.
The output of the locate command can be quite large. When searching for a filename, such
as passwd, the locate command produces every file that contains the string passwd, not just files
named passwd.
In many cases, it is helpful to start by finding out how many files match. Do this by using the -
c option to the locate command:

sysadmin@localhost:~$ locate -c passwd


98

66
CIS-College

To limit the output produced by the locate command use the -b option. This option only includes
listings that have the search term in the basename of the filename. The basename is the portion of
the filename not including the directory names.

sysadmin@localhost:~$ locate -c -b passwd


83

As you can see from the previous output, there will still be many results when the -b option is used.
To limit the output even further, place a \ character in front of the search term. This character limits
the output to filenames that exactly match the term:

sysadmin@localhost:~$ locate -b "\passwd"


/etc/passwd
/etc/pam.d/passwd
/usr/bin/passwd
/usr/share/doc/passwd
/usr/share/lintian/overrides/passwd

6.4 Info Documentation


Man pages are excellent sources of information, but they do tend to have a few disadvantages. One
example is that each man page is a separate document, not related to any other man page. While
some man pages have a SEE ALSO section that may refer to other man pages, they tend to be
independent sources of documentation.
The info command also provides documentation on operating system commands and features. The
goal is slightly different from man pages: to provide a documentation resource that gives a logical
organizational structure, making reading documentation easier.
All of the documentation is merged into a single "book" representing all of the documentation
available. Within info documents, information is broken down into categories that work much like a
table of contents in a book. Hyperlinks are provided to pages with information on individual topics for
a specific command or feature.
Another advantage of info over man pages is that the writing style of info documents is typically
more conducive to learning a topic. Consider man pages to be more of a reference resource and info
documents to be more of a learning guide.

67
CIS-College

6.4.1 Viewing Info Documentation


To display the info documentation for a command, use the info command.

info command

For example, to display the info page of the ls command:

sysadmin@localhost:~$ info ls

Navigate the document using the arrow keys:

Next: dir invocation, Up: Directory listing

10.1 `ls': List directory contents


==================================

The `ls' program lists information about files (of any type, including di
rectories). Options and file arguments can be intermixed arbitrarily, as usu
al.

For non-option command-line arguments that are directories, by


default `ls' lists the contents of directories, not recursively, and
omitting files with names beginning with `.'. For other non-option
arguments, by default `ls' lists just the file name. If no non-option
argument is specified, `ls' operates on the current directory, acting
as if it had been invoked with a single argument of `.'.

By default, the output is sorted alphabetically, according to the


locale settings in effect.(1) If standard output is a terminal, the
output is in columns (sorted vertically) and control characters are
output as question marks; otherwise, the output is listed one per line
and control characters are output as-is.

-----Info: (coreutils)ls invocation, 57 lines --Top--------------------------


---
Welcome to Info version 6.5. Type H for help, h for tutorial.

68
CIS-College

This documentation is broken up into nodes, and in the example above the line highlighted in white
shows it’s currently in the ls invocation node. The first line provides index information about the
current location within the document. The next node, like the next chapter in a book, would be
the dir invocation node. Going up one level is the Directory listing node.
Scrolling through the document, notice the menu for the ls command:

* Menu:

* Which files are listed::


* What information is listed::
* Sorting the output::
* Details about version sort::
* General output formatting::
* Formatting file timestamps::
* Formatting the file names::

---------- Footnotes ----------

(1) If you use a non-POSIX locale (e.g., by setting `LC_ALL' to


`en_US'), then `ls' may produce output that is sorted differently than
you're accustomed to. In that case, set the `LC_ALL' environment
variable to `C'.

-----Info: (coreutils)ls invocation, 57 lines --Bot--------------------------


---

The items under the menu are hyperlinks that link to nodes that describe more about
the ls command. For example, placing the cursor on the line * Sorting the output:: and
pressing the Enter key, leads to a node that describes sorting the output of the ls command:

Next: Details about version sort, Prev: What information is listed, Up: ls
in\
vocation

10.1.3 Sorting the output


-------------------------

These options change the order in which 'ls' sorts the information it

69
CIS-College

outputs. By default, sorting is done by character code (e.g., ASCII


order).

'-c'
'--time=ctime'
'--time=status'
If the long listing format (e.g., '-l', '-o') is being used, print
the status change timestamp (the ctime) instead of the mtime. When
explicitly sorting by time ('--sort=time' or '-t') or when not
using a long listing format, sort according to the ctime. *Note
File timestamps::.

'-f'
Primarily, like '-U'--do not sort; list the files in whatever order
they are stored in the directory. But also enable '-a' (list all
-----Info: (coreutils)Sorting the output, 69 lines --Top---------------------
---

Note that going into the node about sorting leads into a sub-node of the original. To go back to the
previous node, use the U key. While U leads to the start of the node one level up, the L key returns
to the same location as before entering the sorting node.

70
CIS-College

6.4.2 Navigating Info Documents


Like the man command, a listing of movement commands is available by hitting the Shift+H key
while reading the info documentation:

Basic Info command keys

l Close this help window.


q Quit Info altogether.
h Invoke the Info tutorial.

Up Move up one line.


Down Move down one line.
PgUp Scroll backward one screenful.
PgDn Scroll forward one screenful.
Home Go to the beginning of this node.
End Go to the end of this node.

TAB Skip to the next hypertext link.


RET Follow the hypertext link under the cursor.
l Go back to the last node seen in this window.

[ Go to the previous node in the document.


] Go to the next node in the document.
p Go to the previous node on this level.
n Go to the next node on this level.
u Go up one level.
-----Info: *Info Help*, 302 lines -- Top-------------------------------------
-

Note that to close the help screen type the L key, which brings back the current document. To quit
entirely, use the Q key.

71
CIS-College

6.4.3 Exploring Info Documentation


Instead of using info documentation to look up information about a specific command or feature,
consider exploring the capabilities of Linux by reading through the info documentation. Execute
the info command without any arguments to be taken to the top level of the documentation. This is
a good starting point to explore many of the features offered:

File: dir, Node: Top, This is the top of the INFO tree.

This is the Info main menu (aka directory node).


A few useful Info commands:

'q' quits;
'H' lists all Info commands;
'h' starts the Info tutorial;
'mTexinfo RET' visits the Texinfo manual, etc.

* Menu:

Basics
* Common options: (coreutils)Common options.
* Coreutils: (coreutils). Core GNU (file, text, shell) utilities.
* Date input formats: (coreutils)Date input formats.
* File permissions: (coreutils)File permissions.
Access modes.
* Finding files: (find). Operating on files matching certain criteria.

C++ libraries
* autosprintf: (autosprintf). Support for printf format strings in C++.
-----Info: (dir)Top, 211 lines --Top-----------------------------------------
---
Welcome to Info version 6.5. Type H for help, h for tutorial.

72
CIS-College

6.5 Additional Sources of Help


In many cases, the man pages or info documentation provide needed information in an efficient
manner. However, there are other sources for help to be aware of.

73
CIS-College

6.5.1 Using the Help Option


Many commands will provide basic information, very similar to the SYNOPSIS found in man pages,
by simply using the --help option to the command. This option is useful to learn the basic usage of
a command quickly without leaving the command line:

sysadmin@localhost:~$ cat --help


Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

-A, --show-all equivalent to -vET


-b, --number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank suppress repeated empty output lines
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit

Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>


Report cat translation bugs to <http://translationproject.org/team/>
Full documentation at: <http://www.gnu.org/software/coreutils/cat>
or available locally via: info '(coreutils) cat invocation'

74
CIS-College

6.5.2 Additional System Documentation


On most systems, there is a directory where additional documentation (such as documentation files
stored by third-party software vendors) is found.

These documentation files are often called readme files since the files typically have names such
as README or readme.txt. The location of these files can vary depending on the distribution that
you are using. Typical locations include /usr/share/doc and /usr/doc.
Typically, this directory is where system administrators go to learn how to set up more complex
software services. However, sometimes regular users also find this documentation to be useful.

Summary

1- /usr/share/doc/
Directory containing additional documentation files, such as readme files and support for
third-party software.

2- info
Command used to view info documentation for commands.

3- locate
Command used to find any file or directory. Relies on a database typically generated nightly.

4- man
Command used to view manual (man) pages for commands.

75
CIS-College

Exercises:
1- define ip address (192.168.10.0/25) a Var Y

2- print subnet mask of Y

3- print number of hosts of Y

4- show all the hosts ip of Y additional to subnet mask

------------------
python3
import ipaddress

1- y = ipaddress.ip_network('192.168.10.0/25')

2- print(y.netmask)

3- print(y.num_addresses)

4- for i in y:
print(i , y.netmask)

--------------------------------------------------------------------------------------------------\

write python program to check the validation of the IP V4


if it is true >> Right

is it is false >> Wrong


to exit >> quit

76
CIS-College

-----------------------------------------------------------------------------------------------------

write linux program to change ip address automatically by the user

nano

echo "show current ip address"


ifconfig | grep -w inet

echo "Enter updated ip address "

read ip

echo "Enter subnet mask "


read subnet

sudo ifconfig ens33 $ip netmask $subnet

echo "show updated ip address"

ifconfig | grep -w inet


---------------------------------------------------------------------------------------------
Encrypt the follwoing msg ( ) and decrypt it using openssl ( cipher-commands )

openssl version

openssl list -cipher-commands

nano msg

cat msg

77
CIS-College

openssl enc -aes-256-cbc -base64 -in msg

openssl enc -aes-256-cbc -base64 -in msg -out enc

cat msg

cat enc

openssl enc -aes-256-cbc -d -base64 -in enc

openssl enc -aes-256-cbc -d -base64 -in enc -out dec

===================================

nano
cat g
openssl enc -aes-256-cbc -base64 -in g -out g1
cat g1

openssl enc -aes-256-cbc -d -base64 -in g1 -out g2


cta g2

78
CIS-College

79
CIS-College

80
CIS-College

Contents
Chapter1: introduction to Linux. ........................................................................................................... 0
1.1 Linux is Everywhere ........................................................................................................................ 1
1.2 Linux is a Kernel .............................................................................................................................. 2
1.3 Linux is Open Source ...................................................................................................................... 3
1.4 Linux Has Distributions ................................................................................................................... 3
1.5 Linux Embraces the CLI ................................................................................................................. 3
1.1 Linux is Everywhere ................................................................................................................... 4
1.2 Linux is a Kernel ......................................................................................................................... 4
1.3 Linux is Open Source ................................................................................................................ 4
1.4 Linux Has Distributions .............................................................................................................. 4
1.5 Linux Embraces the CLI ............................................................................................................ 4
2.1 Operating Systems .......................................................................................................................... 5
2.2 Linux Distributions ........................................................................................................................... 7
Chapter 3 - Working in Linux .............................................................................................................. 14
3.1 Navigating the Linux Desktop ...................................................................................................... 14
3.1.1 Getting to the Command Line .................................................................................................. 15
3.2 Applications .................................................................................................................................... 16
3.2.1 Major Applications ...................................................................................................................... 16
3.2.2 Server Applications .................................................................................................................... 17
3.2.2.1 Web Servers ............................................................................................................................ 17
3.2.2.2 Private Cloud Servers ............................................................................................................ 17
3.2.2.3 Database Servers ................................................................................................................... 18
3.2.2.4 Email Servers .......................................................................................................................... 18
3.2.2.5 File Sharing .............................................................................................................................. 19
3.2.3 Desktop Applications ................................................................................................................. 20
3.2.3.1 Email ......................................................................................................................................... 20
3.2.3.2 Creative .................................................................................................................................... 20
3.2.3.3 Productivity............................................................................................................................... 20
3.2.3.4 Web Browsers ......................................................................................................................... 21
3.3 Console Tools ................................................................................................................................ 22
3.3.1 Shells............................................................................................................................................ 22
3.3.2 Text Editors ................................................................................................................................. 22

81
CIS-College

3.7.1 Linux in the Cloud....................................................................................................................... 23


Chapter 4 - Open Source Software and Licensing ......................................................................... 27
4.1 Introduction ..................................................................................................................................... 27
4.2 Open Source Licensing ................................................................................................................ 28
4.2.3 Creative Commons .................................................................................................................... 29
Chapter 5 - Command Line Skills ...................................................................................................... 30
5.1 Introduction ..................................................................................................................................... 30
5.2 Shell ................................................................................................................................................. 32
5.3 Commands ..................................................................................................................................... 33
5.3.1 Arguments ................................................................................................................................... 34
5.3.2 Options ......................................................................................................................................... 34
5.3.3 History .......................................................................................................................................... 36
5.4 Variables ......................................................................................................................................... 38
5.4.1 Local Variables ........................................................................................................................... 39
5.4.2 Environment Variables .............................................................................................................. 39
5.4.3 Path Variable............................................................................................................................... 41
5.5 Command Types ........................................................................................................................... 42
5.5.1 Internal Commands .................................................................................................................... 43
5.5.2 External Commands .................................................................................................................. 43
5.5.3 Aliases.......................................................................................................................................... 44
5.5.4 Functions ..................................................................................................................................... 46
5.6 Quoting ............................................................................................................................................ 48
5.6.1 Double Quotes ............................................................................................................................ 48
5.6.2 Single Quotes ............................................................................................................................. 49
5.6.3 Backslash Character .................................................................................................................. 49
5.6.4 Backquotes.................................................................................................................................. 50
5.7 Control Statements........................................................................................................................ 50
5.7.1 Semicolon .................................................................................................................................... 51
5.7.2 Double Ampersand .................................................................................................................... 52
5.7.3 Double Pipe ................................................................................................................................. 53
Chapter 6 - Getting Help ..................................................................................................................... 55
6.1 Introduction ..................................................................................................................................... 55
6.2 Man Pages...................................................................................................................................... 56

82
CIS-College

6.2.1 Viewing Man Pages ................................................................................................................... 57


6.2.2 Sections Within Man Pages ...................................................................................................... 59
6.2.3 Searching Man Pages ............................................................................................................... 62
6.2.4 Man Pages Categorized by Sections ...................................................................................... 63
6.3 Finding Commands and Documentation.................................................................................... 65
6.3.1 Where Are These Commands Located? ................................................................................ 65
6.3.2 Find Any File or Directory ......................................................................................................... 66
6.4 Info Documentation ....................................................................................................................... 67
6.4.1 Viewing Info Documentation ..................................................................................................... 68
6.4.2 Navigating Info Documents....................................................................................................... 71
6.4.3 Exploring Info Documentation .................................................................................................. 72
6.5 Additional Sources of Help ........................................................................................................... 73
6.5.1 Using the Help Option ............................................................................................................... 74
6.5.2 Additional System Documentation........................................................................................... 75

83

You might also like