Home Security Fedora Linux System Administration

Fedora Linux System Administration

By Alex Callejas
books-svg-icon Book
eBook $51.99 $35.99
Print $64.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $51.99 $35.99
Print $64.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
  1. Free Chapter
    Chapter 1: Linux and Open Source Projects
About this book
Fedora Linux is a free and open-source platform designed for hardware, clouds, and containers that enables software developers and community members to create custom solutions for their customers. This book is a comprehensive guide focusing on workstation configuration for the modern system administrator. The book begins by introducing you to the philosophy underlying the open-source movement, along with the unique attributes of the Fedora Project that set it apart from other Linux distributions. The chapters outline best practices and strategies for essential system administration tasks, including operating system installation, first-boot configuration, storage, and network setup. As you make progress, you’ll get to grips with the selection and usage of top applications and tools in the tech environment. The concluding chapters help you get a clear understanding of the basics of version control systems, enhanced Linux security, automation, virtualization, and containers, which are integral to modern system administration. By the end of this book, you’ll have gained the knowledge needed to optimize day-to-day tasks related to Linux-based system administration.
Publication date:
November 2023
Publisher
Packt
Pages
560
ISBN
9781804618400

 

Linux and Open Source Projects

System administration is a job that requires the right tools to achieve the required process optimization. To administrate GNU/Linux-based systems, you must have a workstation that facilitates this aforementioned optimization. A Linux workstation provides many advantages in this regard. In my experience, Fedora Linux, a community-developed distribution sponsored by Red Hat, has a recommended set of tools for Linux-based system administration.

Before learning how to configure a workstation for system administration, we’ll review the history of this operating system so that we have a better context and, above all, know how we can help develop the distribution so that we can improve it.

In this chapter, we will learn a little more about the following:

  • A brief history of Linux
  • Understanding Linux distributions
  • The Fedora Project
  • The command-line interface
  • Desktop environments

Let’s get started!

 

A brief history of Linux

Before getting into the subject, I would like to provide a little background on the history of the operating system. As we know, the history of personal computing is somewhat short – only about 50 years, and, speaking of GNU/Linux in particular, a little less than that.

It was dark times at the end of the 1960s when Ken Thompson wrote the first version of Unix on a PDP-7 minicomputer based on Multics, composed of a kernel, a shell, an editor, and an assembler.

In 1970, the development of the operating system continued at AT&T Bell Labs. Now on a PDP-11 machine, Brian Kernighan suggested the name Uniplexed Information & Computing Service (UNICS). However, the BCPL and B languages that were used presented several implementation problems on the new platform. In 1972, Denis Ritchie, using both languages, developed a new high-level language, now known as the C language, adding data typing and other powerful functions. With that, the Unix system was born.

Software development for this platform continues, with important additions to the operating system. In 1976, Richard Stallman, a student at MIT, while working in a group that used free software exclusively, wrote the first version of Emacs in Text Editor & Corrector (TECO).

In the early 1980s, almost all software was proprietary because technology companies focused their efforts individually, without thinking about collaborative development. This led Stallman to create the GNU Project (meaning GNU is not Unix) in 1983, which pursued the creation of a free operating system that was based on Unix. This was because the general design was already proven and portable, bringing back the spirit of cooperativity that had prevailed in the computer community in earlier days.

Stallman started GNU Emacs by distributing the code for 150 USD. He then used this money to fund the creation of the Free Software Foundation in 1985. Emacs was distributed under the Emacs General Public License, which allowed it to be distributed and used freely while preserving its copyright and restricting him to preserve it even through modifications or additions to the code that could be made later.

Under this same concept, in 1989, the first version of the GNU General Public License (GPL) was released, extending the use and distribution of free software to all programming developments that adopted it as part of the GNU Project.

The second version of the license was published in 1991, with the main difference being that the license’s obligations couldn’t be separated due to conflicting obligations. This provision was intended to discourage any party from using a claim of patent infringement or other litigation to prejudice the freedom of users to use the earlier version.

In the same year, Linus Torvalds, a Finnish student, used Tanenbaum’s 1987 book [Operating Systems: Design and Implementation], Bach’s 1986 book [Design of the UNIX Operating System. Bach, Maurice J. Pearson Education. 1986], and the Jolitz articles [Porting UNIX to the 386: A Practical Approach. William Jolitz. Dr. Dobb’s Journal, Volume 16, Issue 1, Jan. 1991. pp 16–46.], to port some basic tools to create a (free) operating system … for 386(486) AT clones as a hobby and asked for help on the Usenet group comp.os.minix (https://groups.google.com/g/comp.os.minix/c/dlNtH7RRrGA/m/SwRavCzVE7gJ), which became what we know today as Linux:

Figure 1.1 – Original post by Linus Torvalds in the Usenet group comp.os.minix

Figure 1.1 – Original post by Linus Torvalds in the Usenet group comp.os.minix

Linux was not always open source. The first Linux licenses prohibited commercial redistribution. It was with version 0.12, released in early 1992, that the Linux kernel was released under the GPL. According to Linus Torvalds, open sourcing Linux was the best thing he ever did.

Inspired by the success of this effort, various new software development projects emerged to boost the newly created operating system. These developments provided new functionalities and tools that complemented and facilitated the use of Linux, besides expanding the use of the platform to different areas such as business and personal use.

The use of the GPL was the driving force behind the development based on the cooperative nature of the computing community.

This spirit of collaboration founded the basis of what we know today as Linux, but it took a push to make the fruits of these efforts reach everyone. This came with Linux distributions, known as distros.

 

Understanding Linux distributions

The GNU Project experienced some problems implementing the kernel it had officially developed. Known as Hurd, this kernel is a collection of protocols that formalizes how different components should interact with each other (https://www.gnu.org/software/hurd/index.html). The tools worked well but did not have the right cohesion to integrate with the operating system. When Linus Torvalds released the Linux kernel, many enthusiastic developers ported the GNU code, including the compiler to run on it. These efforts filled in the remaining gaps to get a completely free operating system.

In 1992, Linux and the GNU Project joined forces (http://laurel.datsi.fi.upm.es/~ssoo/IG/download/timeline.html), and Richard Stallman urged to call it GNU/Linux since many of its tools were integrated from the GNU project. This led to the creation of new projects that integrated these GNU tools and the Linux kernel into what we know today as Linux distributions.

Distributions consist of the Linux kernel, the GNU tools, and a lot of other packages; many distributions also provide an installation system like that of other modern operating systems. Distributions are usually segmented into packages, some of which provide only the kernel binary, compilation tools, and an installer. Packages come as compiled code, with the installation and removal of packages handled by a package management system (PMS) rather than a simple file archiver.

Some distributions are even delivered as embedded operating systems on some devices, except for mobile distributions, which are based on Android. These distributions are created separately for mobile phones.

Throughout the years, there have been different GNU/Linux distribution projects, with the ones that have lasted over time being the most important. Besides that, they have led to the birth of new distributions, including the following:

  • Slackware: Released in 1993, it was originally named Softlanding Linux System (SLS) and included the X Window System. It was the most complete distribution for a short period (1992). With the newest tools of the time, Slackware Linux offered both new and experienced users a full-featured system, suited for use for any need, as a desktop workstation or as a server. Web, FTP, and email services were ready to go out of the box, as was a wide selection of popular desktop environments. A full range of development tools, editors, and libraries was included for users wishing to develop or compile additional software. It was the first distribution to benefit from the work of millions of developers around the world.
  • Debian: In 1993, Ian Murdock, disappointed with the poor maintenance and the prevalence of bugs in SLS (later known as Slackware), released what he initially called the Debian Linux Release. Debian is a portmanteau (a blend of words in which parts of several words are combined into a new word) of his then-girlfriend Debra Lynn’s first name and his name. The stable branch of Debian is the most used in personal computers and servers. The release included the Debian Linux Manifesto, with Murdock’s vision for his operating system, in which he called to keep it “open in the spirit of Linux and GNU.” Debian releases are codenamed based on characters from the Toy Story movies. Debian is also the basis for many other distributions, with Ubuntu being the most notable of them. Debian uses dpkg (Debian Package) as a package management system, as well as its numerous derivations.
  • Red Hat: Also in 1993, Marc Ewing was creating, debugging, and circulating his own Linux distribution on CD from his home in Raleigh, North Carolina. The name Red Hat came from his computer lab days in college; he always wore a red hat and users would say. “If you need help, look for the guy in the red hat.” Bob Young met him at a tech conference and started buying his CDs for resale due to the growing interest in Linux. In 1995, they joined forces to create Red Hat Software. Red Hat uses rpm (named Red Hat Package Manager initially; as it became popular among various Linux distributions, it changed to RPM Package Manager) as a package management system, as well as its numerous derivations.

Now, it is time to learn about the distribution we use, which has several interesting precepts.

 

The Fedora Project

Red Hat Linux was released every 6 months and was even available at Best Buy. After several releases, it began to have large enterprise customers, partly thanks to the monopoly lawsuit suffered by Microsoft around 2000, but it did not have a defined support cycle to meet these customers’ needs. The company realized that they were trying to develop their product on two different fronts – on the one hand, looking for the stability required by the industry, while on the other hand, looking for innovation using the latest open source developments.

Thus, they opted to split their efforts into two fundamentally separate entities – Red Hat Enterprise Linux (RHEL) and the Fedora Project – each of which addressed its own problems as best it could.

For RHEL, the job was to make it a solid, stable platform that its customers and partners could count on for 5 to 7-year support cycles. Red Hat first offered an enterprise Linux support subscription for Red Hat Linux 6.1. This was not a standalone product; rather, the subscription offering was called Red Hat 6.2E. Subsequently, Red Hat began building a standalone product with commercial service-level agreements and a longer life cycle based on Red Hat Linux.

Fedora Linux is developed by the Fedora Project (originally named Fedora.us) and sponsored by Red Hat. It follows its own release schedule, with a new version every 6 months (in April and October). Fedora provides a modern Linux operating system that uses many of the latest technologies.

To create a new version of RHEL, most development happens in upstream projects. This new version is then integrated into Fedora Linux, with additional “productization” happening in CentOS Stream, which becomes RHEL.

This process, known as Red Hat’s contribution path, is important to delve into to understand the distribution’s development flow. It will also help us understand the importance of the distribution in that flow.

The Red Hat contribution path

In December 2020, Red Hat announced the discontinuation of the development of the CentOS Project, a project it had sponsored since 2014 and which, in its version 2 of 2004, was forked from RHEL 2.1AS, which from that moment on was integrated as CentOS Stream, to the RHEL development contribution path.

The development of RHEL starts in community projects, where the latest and most innovative technologies in the industry are developed. Fedora’s role is to take these technologies and adapt them in each new release of the distribution.

Every 3 years, a new major version of RHEL is released. When the next major release of RHEL is about 1 year away, these innovations reach an optimal level of development, fueled by feedback between Fedora Project developers and integrators and independent software and hardware vendors, providing the stability required by the industry. CentOS Stream then branches from Fedora Linux. The CentOS Stream code becomes the next release of RHEL, meaning that users can contribute to the product and test their workloads before it is released. This becomes a continuous integration of RHEL development, thus shortening the feedback loop that should be considered in future RHEL releases.

The following figure shows this flow:

Figure 1.2 – The Red Hat contribution path

Figure 1.2 – The Red Hat contribution path

The role of Fedora Linux is essential in the development of RHEL, as described previously, but Fedora Linux is a usable operating system in its own right, with the most modern and innovative tools in the industry. As a side result, it is also widely used in enterprise environments to manage RHEL-based systems. This is due to the facilities provided by the Red Hat contribution path, described above.

Fedora’s mission and foundations

The Fedora Project works to build a free and open source software platform that collaborates and shares end user-focused solutions.

Since the Fedora community includes thousands of individuals with different views and approaches, they base their cooperativeness on what they call the four foundations:

Figure 1.3 – The four foundations of Fedora

Figure 1.3 – The four foundations of Fedora

Let’s look at them in detail:

  • Freedom

We are dedicated to free software and content.

(https://docs.fedoraproject.org/en-US/project/)

The goal is to produce a usable operating system that includes only free software. Avoid proprietary or patented content and use free alternatives that allow you to provide a distribution that can bring the most innovative software to everyone so that anyone can use it, legally.

  • Friends

We are a strong, caring community.

(https://docs.fedoraproject.org/en-US/project/)

The Fedora community is multidisciplinary and diverse with a common goal: pushing free software forward. Anyone who wants to help, regardless of their skills, can have a place in the community, a friendly and collaborative environment, so long as they believe in its core values.

  • Features

We care about excellent software.

(https://docs.fedoraproject.org/en-US/project/)

Many of the features that have empowered Linux come from the Fedora community, making it flexible and useful for many people around the world. The Fedora community is a fervent believer in free software development, whether it’s used or not in the distribution. It allows features to be developed clearly and transparently, making them available to anyone who wants to take part in the distribution.

  • First

We are committed to innovation.

(https://docs.fedoraproject.org/en-US/project/)

The Fedora Project offers the latest in stable and robust free software and is a platform that showcases the future of operating system usage. It advances such software to demonstrate collaborative technical progress. Fedora always thinks about providing for the future before anything else.

Besides these four foundations, the Fedora Project has a very clear vision and mission.

Vision

“The Fedora Project envisions a world where everyone benefits from free and open source software built by inclusive, welcoming, and open-minded communities.”

(https://docs.fedoraproject.org/en-US/project/#_our_vision)

Fedora’s vision follows the precepts of the GNU Project, where the benefit of using free and open source software extends to all those who need to use it, in a way that is inclusive of all communities and open to all possibilities.

Mission

“Fedora creates an innovative platform for hardware, clouds, and containers that enables software developers and community members to build tailored solutions for their users.”

(https://docs.fedoraproject.org/en-US/project/#_our_mission)

Fedora’s mission focuses on innovating and adapting technology on existing and future platforms for solutions that enhance the end user experience.

Contributing to the project

The Fedora community contributes to building and developing free and open source software and making advances of importance to the community in general. It quickly and regularly incorporates these advances into the distribution or even into other GNU/Linux distributions. Fedora integrates the free and open source approach and ease of use in the short term.

Software development not only involves programmers – it also requires designers, artists, writers, speakers, translators, system administrators, and others. Coordinating all this effort requires leadership throughout the community, which allows for decision-making without excessive dragging.

Important

You don’t have to be a contributor to use Fedora Linux. In the following chapters, you will learn how to use Fedora Linux for system administration. But, if you want to contribute to the project, here’s how!

The leadership of the project is provided by the Fedora Council, which is made up of eight positions, two of which are held by elected community contributors. Besides the council, there are several leadership groups:

  • Fedora Engineering Steering Committee (FESCo): Manages the technical features of the Fedora distribution and specific implementations of the policy in the Fedora Project.
  • Fedora Mindshare Committee: Represents leadership for user and contributor community growth and support.

Besides working groups, where various editions of the distribution are developed, such as Workstation, Server, IoT, Cloud, and CoreOS, some subprojects develop opportunity areas under the Fedora model. There are also other interest groups (SIGs) that are more informal, where they adopt a framework or lightweight desktop for the distribution.

Code of Conduct

Fedora aims for the best interaction between its collaborators and members of its community through a set of guidelines contained in a document known as the Code of Conduct, whose decisions are applied using all the information and context available in pursuit of having the best environment for its members. It does not intend to restrict expressions or penalize any member of the community; it only details the type of behavior that is considered acceptable or unacceptable.

Note

For the full Code of Conduct, refer to the Fedora Docs at https://docs.fedoraproject.org/en-US/project/code-of-conduct/.

Getting started with Fedora

To contribute to the Fedora Project, follow these steps:

  1. The first step is to create a user account at https://accounts.fedoraproject.org/:
Figure 1.4 – Fedora Accounts

Figure 1.4 – Fedora Accounts

  1. After filling out the registration form, the system will ask you to verify the registered email address:
Figure 1.5 – Fedora Accounts – Account creation

Figure 1.5 – Fedora Accounts – Account creation

  1. Upon clicking on the link you received via mail, the system will ask you to create a password:
Figure 1.6 – Fedora Accounts – set password

Figure 1.6 – Fedora Accounts – set password

  1. Once you’ve accessed your profile, click on the Agreements tab to sign the Fedora Project Contributor Agreement document:
Figure 1.7 – Fedora Accounts – profile settings

Figure 1.7 – Fedora Accounts – profile settings

  1. Click on the Sign button to sign the agreement:
Figure 1.8 – Fedora Accounts – Fedora Project Contributor Agreement

Figure 1.8 – Fedora Accounts – Fedora Project Contributor Agreement

After signing the agreement, continue to the profile configuration area and join a development or collaboration group of interest.

If needed, Fedora provides an online tool at https://whatcanidoforfedora.org/ that guides you to the appropriate group(s) that match your interests, based on the questions you ask:

Figure 1.9 – What can I do for Fedora?

Figure 1.9 – What can I do for Fedora?

Note

This page, although very useful for a first approach, is already deprecated by the documentation of the project. For further reference, please refer to a group of interest (SIG) at https://docs.fedoraproject.org/en-US/project/join/.

Now that we know how to contribute to the Fedora project, let’s learn how to use the distribution to administrate Linux-based systems.

Fedora as a system administration tool

Using Fedora Linux as the main distribution, in work or study, also supports the development of the Fedora Project, as an end user. You can contribute with feedback on the use of the tools and services included in the distribution, and also take advantage of these innovations to become more productive and efficient in day-to-day activities.

One of the most important activities in the IT industry is system administration, where the main responsibility is to maintain, configure, and ensure the reliable operation of computer systems, especially multi-user computers such as servers. The system administrator tries to ensure that the uptime, performance, resources, and security of the computers that are managed meet the needs of the users, without exceeding a set target budget during this process.

Managing Linux systems using a Linux workstation provides many advantages that lead to a high level of efficiency and productivity since, from the host operating system, you can automate tasks or perform functional tests based on an operating system, such as the one being managed.

Fedora, given its privileged position within the contributory development of RHEL, becomes a highly profitable tool in the administration of similar platforms, such as its variants (CentOS Stream, Rocky, and AlmaLinux), as well as any distribution that uses rpm packages.

At the same time, when using this approach for Linux system administration, it is possible to contribute to the development of the distribution since continuously testing the platform and its various packages and projects within it takes place here.

So, if you wish to use Fedora Linux to manage Linux-based systems, you could support the Fedora Project by reporting unexpected behaviors or contributing to the improvement of system performance. This includes making suggestions for new features. Before reporting a bug, it is recommended to consult the Ask Fedora website at https://ask.fedoraproject.org/, the community support forum, in case this unexpected behavior has occurred before:

Figure 1.10 – Ask Fedora

Figure 1.10 – Ask Fedora

Note

For more information on how to file a bug, refer to the Fedora Docs at https://docs.fedoraproject.org/en-US/quick-docs/howto-file-a-bug/.

Before we customize the distribution as our system administration workstation, let’s review how to use our main tool.

 

The command-line interface

As the development of graphical user interfaces progressed, the use of the command line was often discarded. However, it is the main tool for operating system administration in general, whether it’s for system administrators or Advanced and Power users. Apart from Linux-based systems, the CLI is also used on Windows or Mac systems. The use of the command line extends system management and administration capabilities.

Achieving the fluency necessary for maximum efficiency requires practice at every opportunity. Using Linux as a workstation allows us to practice this skill so that we can improve our productivity and efficiency when performing daily tasks.

The default command-line interpreter (shell) in Fedora Linux is Bourne Again Shell (Bash) and can be accessed through different Terminal emulators available with the distribution:

  • xterm: This is the original terminal emulator program for the X Window System.
  • Konsole: The terminal emulator program for the Konsole Desktop Environment (KDE).
  • gnome-terminal: The terminal emulator program for the GNOME desktop environment.
  • Alacritty: This is a lightweight, OpenGL-based terminal emulator program that focuses on performance.
  • yakuake (guake): This is a drop-down terminal emulator program that can easily be accessed via a keyboard shortcut. guake is the version that’s used for the GNOME desktop environment.
  • Terminator: This is based on gnome-terminal. It provides multiple instances of the terminal emulator in a single window, generating a terminal console that fills the size of the screen area and divides it into a resizable grid.

Now that we know about the different terminal emulator options, let’s dive into the topics that will help us get into system administration.

The basics

Practice is the only way to develop our console skills, but there is a path that can help with such improvement. This path consists of four sections with three levels each; following it as a guide while practicing should help you develop fluency in the console.

1. Ask the one who knows

Upon encountering an unexpected behavior or requiring a tool to make a task more efficient, it is a very common mistake to first look it up on the internet; it has even become a common term: Google it. But open source projects offer us reference material (that is, man and info pages) explaining the options, and, in most cases, the use of the packages, commands, processes, and services that follow it. The flow of information search is the first paradigm we have to break to develop efficiency as a system administrator.

Basic level

Use the built-in help command. If you do not know or remember how to use a command, use the built-in help module. To do so, add the --help or -h parameter or even run the command without parameters. The command may have one of these basic help options.

Note

Not all commands have a built-in help option. In some cases, they may offer one or two. Just test which one comes with the command. If not, use the next level.

Let’s look at an example of each of them:

  • A command run with the built-in help module:
Figure 1.11 – Built-in help module

Figure 1.11 – Built-in help module

  • A command run with the -h parameter:
Figure 1.12 – Command run with the -h parameter

Figure 1.12 – Command run with the -h parameter

  • A command run without parameters:
Figure 1.13 – Command run without parameters

Figure 1.13 – Command run without parameters

These are the basic recommended options included in most of the commands. Now let’s look at a more elaborate type of help. Unfortunately, sometimes it is not included as part of the package or requires a separate package to be installed to get this help. In each case, there is mention of it.

Intermediate level

man is your friend. Most of the commands, besides the built-in help command, come with a user manual, which details the use of each of the options and parameters that are available with it. To consult the manual, run the man <command> command:

Figure 1.14 – Command user manual

Figure 1.14 – Command user manual

In some cases, the commands may include info pages. These may reference the same man pages or, in some cases, have more detailed information on the usage and options of the command. To consult the info pages, run the info <command> command.

Advanced level

The operating system provides a directory where the documentation for packages and services resides – for example, in /usr/share/doc. You should consider installing the kernel documentation, which includes documentation for the drivers shipped with the kernel, and references to various configuration options. The kernel-doc package contains the kernel documentation for installing and running several tasks as a root user:

[root@workstation ~]# dnf -y install kernel-doc
...output omitted…
[root@workstation ~]# ls /usr/share/doc/kernel-doc-6.0.9-300/Documentation/
ABI atomic_t.txt crypto  features  ia64  kernel-hacking memory-barriers.txt
...output omitted...
[root@workstation ~]# cat \
> /usr/share/doc/kernel-doc-6.0.9-300/Documentation/networking/bonding.rst
...output omitted...
Introduction
============
The Linux bonding driver provides a method for aggregating
multiple network interfaces into a single logical "bonded" interface.
The behavior of the bonded interfaces depends upon the mode; generally
speaking, modes provide either hot standby or load balancing services.
Additionally, link integrity monitoring may be performed.
...output omitted...

After exhausting the options that the operating system contains, you can access the different online options. The community is very helpful if you haven’t found a suitable solution. To do so, you can access mailing lists, telegram channels, and IRC sites such as Reddit, Stack Overflow, or the ones provided by the Fedora Project itself, such as Ask Fedora. Using these options, you can get in touch with the community, which will always offer a helping hand.

2. Use the console

Having a Linux-based workstation brings with it the ability to use the console in all circumstances, even in your free time. The idea is to take advantage of any opportunity to use it to launch applications or tasks and reduce the use of the mouse and graphic solutions as much as possible.

The use of the console depends on the privileges of the users who use it. A privileged account is a user account that has more privileges than regular users. Privileged accounts can, for example, install or remove software, update the operating system, or change system or application settings. They might also have access to files that non-privileged users can’t access.

The command prompt provides information on the privileges of the user using it.

If, upon opening the console, the prompt shows $, this means that the user is logged on to this system as a non-privileged user. The $ prompt is the default for normal users:

[user@workstation ~]$

The root user’s prompt is #. Logging in as a root user can be done in two ways:

  • By logging in with the root user’s username and password
  • By switching to the root user

This last point could involve the same username and password of the privileged user. Use the su – command to become the root user:

[user@workstation ~]$ su -
Password: [root password]
[root@workstation ~]#

Alternatively, we can use the sudo (Super User DO) command, which is a program that helps us provide privileges to normal users.

Most Linux distributions have sudo installed by default. In some cases, even root access is turned off. When this happens, we can only access it through the sudo command.

While installing the operating system, when creating the user, we can choose to add them as part of the system administration group. This will allow them to switch to the root user by using the sudo command and their own password.

To find out if your user has access to different privileges with sudo, run the following code:

[user@workstation ~]$ sudo -l
Password: [user password]
Matching Defaults entries for user on workstation:
...output omitted...
User user may run the following commands on workstation:
    (ALL) PASSWD: ALL
...output omitted...

(ALL) PASSWD: ALL indicates that the user can gain access to any command of the operating system by using the sudo command and their password. To switch to the root user, run the following code:

[user@workstation ~]$ sudo -i
Password: [user password]
[root@workstation ~]#

So, now that we know how to use the console, depending on our activities and privileges, let’s learn how to improve our console skills.

Basic level

Just use it. Type as much as you can to list, search for, and open applications.

Intermediate level

Chain, redirect, and concatenate. After typing commands and understanding the result of their output, we can start playing with them and put them together in such a way that they simplify tasks. By using pipes (|) and redirecting the output and input with > and <, we can generate a string of commands that we know as one-liners. Bash-one-liners are famous in the computer world, and it is even considered an art to be able to chain commands for certain tasks. There are many internet sites and even social networks where we can find them. Some of them use such redirection to interpret pattern processing written in the AWK programming language as output.

Example: Send the output of the following command to a new file:

[user@workstation ~]$ ip link show > link.txt
[user@workstation ~]$ cat link.txt
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:f9:69:14 brd ff:ff:ff:ff:ff:ff

Example: Get the open and listening TCP ports and the processes related to them, separated by commas:

[root@workstation ~]# ss -tulpn | grep tcp | awk '{ print $1","$2","$5","$7 }'
tcp,LISTEN,0.0.0.0:22,users:(("sshd",pid=844,fd=3))
tcp,LISTEN,127.0.0.54:53,users:(("systemd-resolve",pid=707,fd=19))
tcp,LISTEN,0.0.0.0:5355,users:(("systemd-resolve",pid=707,fd=11))
tcp,LISTEN,127.0.0.1:6010,users:(("sshd",pid=1514,fd=9))
tcp,LISTEN,127.0.0.53%lo:53,users:(("systemd-resolve",pid=707,fd=17))
tcp,LISTEN,127.0.0.1:631,users:(("cupsd",pid=842,fd=7))
tcp,LISTEN,[::]:22,users:(("sshd",pid=844,fd=4))
tcp,LISTEN,[::]:5355,users:(("systemd-resolve",pid=707,fd=13))
tcp,LISTEN,[::1]:6010,users:(("sshd",pid=1514,fd=8))
tcp,LISTEN,[::1]:631,users:(("cupsd",pid=842,fd=6))

Advanced level

If you typed it twice, you should have scripted it once.

In system administration, it is very common for tasks to become repetitive. The first step in automating them, and with this, reducing the time taken to perform them, is to put them together and turn them into a series of instructions, known as a shell script. This script or series of instructions can contain the commands to run complex tasks, such as using outputs as variable settings and reusing them in the same execution.

There is a lot of documentation on how to create shell scripts. They should have a structure similar to the following:

#!/bin/bash ← [1]
#
# IDENTITY ← [2]
#
# VARIABLES ← [3]
# COMMANDS ← [4]

Let’s look at what the highlighted text indicates in each section:

  • [1]: Shebang. This indicates the command-line interpreter that uses the instructions; the functional tests of the script must confirm its use.
  • [2]: The script must contain identification information – what it works for, who the author is, what version is being used, and even the date of creation and the changes it has undergone. This documentation will help you use it and identify its scope.
  • [3]: In this section, the variables used to execute the instructions are set.
  • [4]: In this section, you will find the instructions that will be executed.

3. Edit text files

On Linux, everything is a file. Thus, we must use a text editor to help us perform configuration or administration tasks. Knowing about the editor of choice in more depth helps make this activity more efficient, especially if some of them have specialized add-ons or plugins for cases such as identifying or validating syntax in files written in diverse programming languages or formats.

Basic level

GNU Nano is a simple, lightweight, open source command-line text editor written in C. Developed as part of the GNU Project, it emulates the Pico text editor, part of the Pine mail client:

Figure 1.15 – The Nano editor

Figure 1.15 – The Nano editor

GNU Nano does not have many add-ons, but it does have built-in features, such as one to highlight different programming languages.

Intermediate level

Vim is an open source command-line text editor (licensed under its charityware license), written in C and with a scripting language called Vim (or VimL). It was developed in the 1970s as the visual mode (vi, its base) of the ex line editor. The original vi was a modal text editor that had no syntax highlighting, was written in C, and had only a command-line interface. Later, in the 1980s, vim was released as a clone of the vi text editor for personal computers, ported as Vi IMproved (Vim). Eventually, Vim got a graphical user interface (along with a CLI) called gVim, syntax highlighting, a scripting language (to customize and extend it), and support for many more computer platforms:

Figure 1.16 – The Vim editor

Figure 1.16 – The Vim editor

vim has many add-ons and plugins to enhance its use. It is even possible to create special add-ons for specific or special needs.

Advanced level

GNU Emacs is a free, open source, extensible, self-documenting text editor written in C and its own Lisp programming language (Emacs Lisp). It was developed by Richard Stallman and Guy L. Steele Jr.. Its initial release was in 1985 and it has been ported to all major operating systems. Developed as part of the GNU Project, its use is extended through plugins written in Emacs Lisp, which are available in the official Fedora repositories. It also runs on Fedora via an AppImage package (sandboxed application):

Figure 1.17 – The GNU Emacs editor

Figure 1.17 – The GNU Emacs editor

4. Handle regular expressions

The bash command interpreter has many ways to handle regular expressions, which it does by expanding the power of the command line.

Basic level

At a basic level, it is important to use pattern matching (wildcards), loops, and exit codes. With wildcards, it is easier to handle many files. By using metacharacters as wildcards that expand to match the filenames and paths searched for, commands act on one set of files at a time.

The following table shows the characters that are used as wildcards in terms of basic usage:

Character

Description

*

Matches any number of characters – for example, list all .txt files in a directory:

$ ls *.txt

?

Matches any single character – for example, list the .sh files that start with the compar string:

$ ls compar*.sh

compare.sh

[ ]

Matches one of the characters between the brackets – for example, list files in a directory and filter out files starting with letters:

$ ls | grep ^[a-z]

compare.sh

conkyrc

labkey

labkey.pub

{ }

Contains a comma-separated list of strings or a sequence. If so, use double-dot syntax. An example is to create five empty files and list them:

$ touch file{1..5}
$ ls file?
file1  file2  file3  file4  file5

~

Match the current user’s home directory – for example, list the Downloads directory in the user’s home directory:

$ ls ~/Downloads/

$

Denotes a string as a variable – for example, print the user’s PATH variable on the screen:

$ echo $PATH
/home/user/.local/bin:/home/user/bin::/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

Loops help us perform repetitive tasks simply. In Bash, a for loop is built from the following syntax:

for <variable> in <list>
do
command <variable>
done

You could add a condition to these loops so that they run different actions, depending on the situation:

if <condition>;
   then
       <statement 1>
       ...
       <statement n>
   else
       <statement alternative>
fi

Running a script provides an output and passes control to the calling process. The script may exit before finishing if it encounters an error condition, for example. The exit command shown in the following code, with an optional argument between 0 and 255, represents an exit code:

[user@workstation ~]$ cat test.sh
#!/bin/bash
echo "Hello, I'm a test"
exit 0
[user@workstation ~]$ ./test.sh
Hello, I'm a test
[user@workstation ~]$ echo $?
0

In the output, the exit code’s value of 0 indicates that the script ran successfully with no errors; any other value indicates an error output.

Intermediate level

Regular expressions provide a pattern-matching mechanism that helps you search for specific content. The grep, less, and vim commands support regular expressions in their use. Most programming languages also support them, although the syntax in each may differ. As mentioned previously, these commands can be chained and converted into a search for more complex structures.

At the end of this section, you will find a guided example that better illustrates this level.

Advanced level

Write scripts with regular expressions and patterns in an optimized way.

Be careful when handling regular expressions within scripts since chained commands use a certain amount of memory and CPU processing that should not be underestimated. The battery and functional testing phase should be planned carefully and never on a productive server; at this point, it is highly profitable to have a Linux workstation to manage our servers. We can recreate the production environment in an instance based on a local virtual machine and perform the first functional tests of our super-script.

This is the way.

Patience, young Padawan.

It may seem a very laborious journey, but it is not. A lot of it depends on practice, incorporating the characteristics mentioned, and thus, developing the necessary skills. It is not a matter of 1 day of practice – it requires effort and dedication, so you must go one step at a time.

Next, we will perform a guided exercise where I will show, step by step, how to go from a simple command to a chained command with a defined purpose. This will show you how the tools shown below can be incorporated as the need arises.

Guided example – releasing space in the filesystem

Description: A ticket gets assigned to us because a managed server shows the root filesystem at 92% disk use. It is necessary to determine various responsibilities and provide evidence so that we can document the issue and resolve it so that we can close it.

Analysis: Since the server has no separate directories in the filesystems, it is necessary to determine which directory or directories have used the most disk space and identify which application or service it is relative to.

Solution:

  1. As root, switch to the root directory (/) and list the available directories:
    [root@workstation ~]# cd /
    [root@workstation /]# ls
    afs  bin  boot  dev  etc  home  lib  lib64  lost+found  media  
    mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
  2. Run the following command to list the directories. Use the -l parameter to run a long list and identify the directories only:
    [root@workstation /]# ls -l | grep ^d
    dr-xr-xr-x.   1 root root    0 Aug  9 08:27 afs
    dr-xr-xr-x.   6 root root 4096 Nov 22 13:12 boot
    drwxr-xr-x.  21 root root 4000 Nov 22 13:12 dev
    drwxr-xr-x.   1 root root 5186 Nov 22 13:12 etc
    drwxr-xr-x.   1 root root   18 Nov 21 21:41 home
    drwx------.   1 root root    0 Nov  5 02:18 lost+found
    drwxr-xr-x.   1 root root    0 Aug  9 08:27 media
    drwxr-xr-x.   1 root root    0 Aug  9 08:27 mnt
    drwxr-xr-x.   1 root root    0 Aug  9 08:27 opt
    dr-xr-xr-x. 329 root root    0 Nov 22 13:12 proc
    dr-xr-x---.   1 root root  188 Nov 22 01:45 root
    drwxr-xr-x.  58 root root 1580 Nov 22 13:14 run
    drwxr-xr-x.   1 root root    0 Aug  9 08:27 srv
    dr-xr-xr-x.  13 root root    0 Nov 22 13:12 sys
    drwxrwxrwt.  20 root root  460 Nov 23 00:06 tmp
    drwxr-xr-x.   1 root root  168 Nov  5 02:4.0 usr
    drwxr-xr-x.   1 root root  200 Nov  5 03:15 var
  3. Use awk to select only the names of the directories (column 9):
    [root@workstation /]# ls -l | grep ^d | awk '{ print $9 }'
    afs
    boot
    dev
    etc
    home
    lost+found
    media
    mnt
    opt
    proc
    root
    run
    srv
    sys
    tmp
    usr
    var
  4. Determine the disk space used by each directory with the xargs and du commands:
    [root@workstation /]# ls -l | grep ^d | awk '{ print $9 }' | xargs du -sk
    0    afs
    293680    boot
    0    dev
    33212    etc
    176728    home
    0    lost+found
    0    media
    0    mnt
    0    opt
    du: cannot read directory 'proc/3945/task/3945/net': Invalid argument
    du: cannot read directory 'proc/3945/net': Invalid argument
    du: cannot read directory 'proc/3946/task/3946/net': Invalid argument
    du: cannot read directory 'proc/3946/net': Invalid argument
    du: cannot access 'proc/7762/task/7762/fd/3': No such file or directory
    du: cannot access 'proc/7762/task/7762/fdinfo/3': No such file or directory
    du: cannot access 'proc/7762/fd/3': No such file or directory
    du: cannot access 'proc/7762/fdinfo/3': No such file or directory
    0    proc
    32    root
    du: cannot access 'run/user/1000/doc': Permission denied
    1632  run
    0    srv
    0    sys
    8    tmp
    8371056    usr
    6576996    var
  5. To avoid confusion, send the standard error output (stderr) to /dev/null:
    [root@workstation /]# ls -l | grep ^d | awk '{ print $9 }' | \
    > xargs du -sk 2> /dev/null
    0    afs
    293680    boot
    0    dev
    33212    etc
    176728    home
    0    lost+found
    0    media
    0    mnt
    0    opt
    0    proc
    32    root
    1632    run
    0    srv
    0    sys
    8    tmp
    8371056    usr
    6576996    var
  6. Sort the results:
    [root@workstation /]# ls -l | grep ^d | awk '{ print $9 }' | \
    > xargs du -sk 2> /dev/null  | sort -n
    0    afs
    0    dev
    0    lost+found
    0    media
    0    mnt
    0    opt
    0    proc
    0    srv
    0    sys
    8    tmp
    32    root
    1632    run
    33212    etc
    176728    home
    293680    boot
    6576996    var
    8371056    usr
  7. Discard the directories with the lowest disk space usage and keep only the Top 5:
    [root@workstation /]# ls -l | grep ^d | awk '{ print $9 }' | \
    > xargs du -sk 2> /dev/null  | sort -n | tail -5
    33212    etc
    176728    home
    293680    boot
    6576996    var
    8371056    usr
  8. Now that we have found the Top 5 directories with the highest disk usage, we will only deal with this order so that we can use it as evidence:
    [root@workstation /]# ls -l | grep ^d | awk '{ print $9 }' | \
    > xargs du -sk 2> /dev/null  | sort -n | tail -5 \
    > awk '{ print $2 }' | xargs du -sh
    33M        etc
    173M    home
    287M    boot
    6.3G    var
    8.0G    usr

The same steps should be executed for each of the Top 5 directories so that we can find the subdirectory that occupies the most disk space and is the one causing the issue. Finding out which service determines who handles releasing the issue depends on the directory.

Now that these concepts are clear, we can start thinking about how to install our workstation for system administration purposes. However, before that, we should take a moment to select the desktop environment we want to use.

 

Desktop environments

Fedora’s default desktop environment is GNOME, but it provides us with the alternative of using other desktop environments, either lightweight ones or those with special features, such as those that use different graphic engines and specialized libraries or are focused on performance. These alternatives are offered by the Fedora Project as Spin distributions. You can download a Spin with a preconfigured desktop environment based on Fedora:

Note

For more information about alternative desktops for Fedora, refer to Fedora Spins at https://spins.fedoraproject.org/.

With this, we have come to the end of Chapter 1. Let’s quickly recap what we learned.

 

Summary

In this chapter, we briefly walked through the history of the Unix operating system, which taught us about the beginning and development of Linux and its distributions. Apart from teaching us how the project that develops the distribution that we will use as a workstation for system administration operates, it helped us learn how we can be part of it and improve the distribution while we perform our day-to-day tasks.

In the next chapter, we will learn about some best practices and tips that will help ensure we have a good installation that will help us develop our work.

 

Further reading

To learn more about the topics that were covered in the chapter, please visit the following links:

About the Author
  • Alex Callejas

    Alex Callejas is a services content architect at Red Hat, the world's leading provider of enterprise open source solutions, including Linux, the cloud, containers, and Kubernetes. He is based in Mexico City and is a free and open source software contributor. With more than 20 years of experience as a system administrator, he has strong expertise in infrastructure hardening and automation. An enthusiast of open source solutions, he supports the community by sharing his knowledge at different public-access and university events.

    Browse publications by this author
Fedora Linux System Administration
Unlock this book and the full library FREE for 7 days
Start now