Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Ubuntu Server - Fourth Edition

You're reading from  Mastering Ubuntu Server - Fourth Edition

Product type Book
Published in Sep 2022
Publisher Packt
ISBN-13 9781803234243
Pages 584 pages
Edition 4th Edition
Languages
Concepts
Author (1):
Jay LaCroix Jay LaCroix
Profile icon Jay LaCroix

Table of Contents (26) Chapters

Preface 1. Deploying Ubuntu Server 2. Managing Users and Permissions 3. Managing Software Packages 4. Navigating and Essential Commands 5. Managing Files and Directories 6. Boosting Your Command-line Efficiency 7. Controlling and Managing Processes 8. Monitoring System Resources 9. Managing Storage Volumes 10. Connecting to Networks 11. Setting Up Network Services 12. Sharing and Transferring Files 13. Managing Databases 14. Serving Web Content 15. Automating Server Configuration with Ansible 16. Virtualization 17. Running Containers 18. Container Orchestration 19. Deploying Ubuntu in the Cloud 20. Automating Cloud Deployments with Terraform 21. Securing Your Server 22. Troubleshooting Ubuntu Servers 23. Preventing Disasters 24. Other Books You May Enjoy
25. Index

Navigating and Essential Commands

At this point in our journey, we’ve already covered a lot of ground—we’ve learned how to deploy an Ubuntu server, how to manage users, and most recently, how to manage software packages. Before we go too far, we should take a moment to learn some important concepts and commands that will allow us to build more of the foundational knowledge that will serve us well for the remainder of the book and beyond. These foundational concepts include core Linux commands for navigating the shell, the Linux filesystem layout, viewing the contents of files, and even checking on log files. Specifically, this discussion will include:

  • Learning essential Linux commands
  • Understanding the Linux filesystem layout
  • Viewing the contents of files
  • Viewing application log files

Let’s take some time to learn some essential Linux commands that will help strengthen our command-line skills.

Learning essential Linux commands

Building a solid competency on the command line is essential and effectively gives any system administrator or engineer superpowers. Our new abilities won’t allow us to leap tall buildings in a single bound but will definitely enable us to execute terminal commands as if we’re command-line ninjas. While we won’t completely master the art of using the command line in this section (that can only come with years and experience), we will definitely become more confident.

First, let’s talk about moving from one place to another within the Linux filesystem. Specifically, by “Linux filesystem,” I’m referring to the default structure of the various folders (also referred to as “directories”) contained within your Ubuntu installation. The Linux filesystem contains many important directories, each with its own designated purpose, which we’ll talk about in more detail later in this chapter...

Understanding the Linux filesystem layout

As I mentioned earlier, every directory in a Linux installation has a designated purpose. It isn’t a hard rule that you have to follow, more of a strong recommendation for where certain things are supposed to go.

You can certainly go against the recommendations; ultimately, you have full control over your installation. But, if you make it a habit to place files in strange locations, you may annoy your colleagues. In this section, we’ll go over the most common directories and talk about their purpose.

The term filesystem itself can be somewhat confusing in the Linux world because it can refer to two different things—the default directory structure, as well as the actual filesystem we choose when formatting a volume such as a hard drive or flash drive (ext4, XFS, and so on). Specific to this section, we’re going to take a quick look at the Linux filesystem in the context of the default directory structure...

Viewing the contents of files

The Linux filesystem contains many directories and files. In the case of files, we need to learn how to read and manipulate them to round out our knowledge. We’ll cover more topics surrounding file management in the next chapter. For now, we can benefit by taking a look at how to view the content of existing files.

We can print the contents of a file to the screen with the cat command, along with a filename as an argument. The following command, for example, can be used to view the contents of testfile.txt in our current working directory, which we created earlier in the chapter when we discussed the touch command. Sure, this exercise is rather pointless since that file is empty, but it offers a good first example:

cat testfile.txt

There’s no output, since again, the file is empty. So, let’s instead take a look at a more practical example. Here’s a file we can use cat against that actually does have content inside...

Viewing application log files

In the last section of this chapter, let’s explore log files a bit, as they bring several concepts that we’ve discussed full circle. We went through an overview of the default directory layout, practiced viewing files, and we learned how to search files for strings. We’ll discuss log files in greater detail later on in the book, but we can use all of these concepts to take an initial look at viewing log files now.

If you recall, during the discussion of the Linux filesystem layout earlier in this chapter, there was a table showing some of the most common directories that exist. Among the items in that table, I called out the /var/log directory. While logging is transitioning to a different style (more on that in Chapter 22, Troubleshooting Ubuntu Servers), we’ll have a series of logs in the /var/log directory. Go ahead and use the ls command yourself, and you’ll see there are quite a few files there. While I won...

Summary

There are more Linux commands than you’ll ever be able to memorize. Most of us just memorize our favorite commands and variations of commands, and you’ll develop your own menu of these commands as you learn and expand your knowledge. In this chapter, we covered many of the foundational commands that are, for the most part, essential. Commands such as grep, cat, cd, ls, and others were explored this time around. The next chapter is essentially a continuation of this one, but I wanted to split the foundational concepts into two chapters rather than one enormous one.

In the next chapter, we’ll expand our foundational knowledge with a deeper look at file management, including editing files, input/output streams, and symbolic links, and we’ll even reveal the secret to life itself. Well, maybe not the latter, but the next chapter will still be great. See you there!

Relevant video

Further reading

Join our community on Discord

Join our community’s Discord space for discussions with the author and other readers:

https://packt.link/LWaZ0

lock icon The rest of the chapter is locked
You have been reading a chapter from
Mastering Ubuntu Server - Fourth Edition
Published in: Sep 2022 Publisher: Packt ISBN-13: 9781803234243
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}