Get Help in Red Hat Enterprise Linux

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

In this lab, you will master the essential skill of navigating and searching man pages in Red Hat Enterprise Linux. You will learn how to effectively browse through man pages using various navigation keys, search for specific strings within a man page, and discover relevant man pages by keyword. Furthermore, you will explore techniques for performing full-text searches across all available man pages to find comprehensive information.

Note: LabEx provides a streamlined UBI9 (Universal Base Image 9) environment for this lab. This lightweight container image includes essential tools but has a limited set of man pages compared to a full RHEL installation. We'll use available commands like curl, free, and groff to demonstrate man page navigation techniques.

In this step, you will learn how to navigate through man pages, which are essential for understanding commands and their functionalities in Red Hat Enterprise Linux. The man command (short for manual) provides detailed documentation for most commands, utilities, and functions available on the system.

Note: In this LabEx environment (UBI9), we'll use commands that have available man pages. While a full RHEL system would include man pages for basic commands like ls and passwd, our streamlined environment focuses on available tools like curl, free, and groff.

To begin, let's view the man page for the curl command, which is used to transfer data from or to a server.

man curl

After executing the command, you will see the man page for curl. This page might be longer than your terminal screen, so you'll need to know how to navigate it.

Here are the common navigation keys you can use within a man page:

  • Spacebar or PageDown: Scroll forward (down) one full screen.
  • PageUp: Scroll backward (up) one full screen.
  • DownArrow: Scroll forward (down) one line.
  • UpArrow: Scroll backward (up) one line.
  • D: Scroll forward (down) one half-screen.
  • U: Scroll backward (up) one half-screen.
  • Q: Exit the man page and return to the command shell prompt.

Practice navigating the curl man page using these keys. Try scrolling down a few screens, then back up.

For example, press the Spacebar a few times to scroll down.

Then, press PageUp to scroll back up.

Finally, press Q to exit the man page.

## Press Spacebar multiple times to scroll down
## Press PageUp to scroll up
## Press Q to exit

You can also go directly to the beginning or end of a man page:

  • G: Go to the start of the man page.
  • Shift+G: Go to the end of the man page.

Let's try this with the free command's man page. The free command is used to display memory usage information.

man free

Once inside the free man page, press Shift+G to jump to the end of the page.

Then, press G to jump back to the beginning.

Finally, press Q to exit the man page.

## Press Shift+G to go to the end
## Press G to go to the start
## Press Q to exit

In this step, you will learn how to search for specific strings or keywords within an open man page. This is extremely useful when you are looking for information about a particular option or concept within a long manual page.

To search forward (down) for a string in the man page, type / followed by the string you want to search for, and then press Enter. The man page viewer will highlight the first occurrence of the string and jump to it.

To repeat the previous search forward (down), press N. To repeat the previous search backward (up), press Shift+N.

Let's open the man page for the curl command again.

man curl

Now, imagine you want to find information about HTTP options. You might search for the string "HTTP".

Inside the man page, type /HTTP and press Enter.

/HTTP

You should see the cursor jump to the first occurrence of "HTTP", and it might be highlighted.

Now, press N to find the next occurrence of "HTTP". Press N a few more times to see all occurrences.

N

To search backward, press Shift+N. This will take you to the previous occurrence of "HTTP".

Shift+N

When you are done searching, press Q to exit the man page.

Q

Let's try another example with the groff command. This command is used for document formatting. We will search for information related to "format".

man groff

Inside the man page, type /format and press Enter.

/format

Press N to find subsequent occurrences and Shift+N to go back.

N
Shift+N

When you are finished, press Q to exit the man page.

Q

In this step, you will learn how to search for man pages by keyword. This is incredibly useful when you know what you want to do (e.g., "change password") but don't know the exact command name.

The man -k option (which is equivalent to the apropos command) allows you to search for a keyword in the man pages' titles and short descriptions. This will list all man pages that contain the specified keyword in their one-line description.

Note: In LabEx's streamlined UBI9 environment, you'll see fewer results compared to a full RHEL installation. This demonstrates the concept while working within the available man pages.

Let's say you want to find commands related to "curl". You can use man -k curl.

man -k curl

You will see a list of commands and their section numbers, along with a brief description. For example:

curl (1)             - transfer a URL

From this output, you can see that curl (1) is the command to "transfer a URL", which is the main curl command for data transfer. The number in parentheses, like (1), indicates the section of the man page.

Let's try another example. Suppose you want to find commands related to "memory". You might search for "memory".

man -k memory

You will get a list of man pages related to memory functionalities. This output can be quite short in UBI9, but it helps you discover relevant commands.

free (1)             - Display amount of free and used memory in the system
pmap (1)             - report memory map of a process
vmstat (8)           - Report virtual memory statistics

This method is a great way to explore the system's capabilities when you're not sure about the exact command name.

In this final step, you will learn about a more powerful search option for man pages: searching for a keyword in the full text of all available man pages. This can be very time-consuming and resource-intensive, so it's typically used as a last resort when man -k (or apropos) doesn't yield the desired results.

The man -K (uppercase K) option searches for the keyword in the full-text content of all man pages. When a match is found, man will display that page and prompt you to either view it, skip to the next match, or quit the search.

Let's try searching for the keyword "option" across all man pages. This might take a moment as the system scans through many files.

man -K option

As the search progresses, man will stop at each page where "authentication" is found. You will see a prompt similar to this:

--Man-- next: some_command(section) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]
  • Press Enter (or return) to view the current man page.
  • Press Ctrl-D to skip the current man page and move to the next one that contains the keyword.
  • Press Ctrl-C to quit the search entirely and return to the command prompt.

For this exercise, press Ctrl-D a few times to skip through some pages, and then press Ctrl-C to quit the search. This demonstrates how to navigate the results of a full-text search without having to read every single man page.

## Press Ctrl-D multiple times to skip
## Press Ctrl-C to quit

This man -K command is a very broad search and can be slow, especially on systems with many installed man pages. It's best used when you have a very specific term and man -k hasn't helped you find what you need.

You have now learned various ways to get help using the man command, from navigating pages to searching for specific information and discovering commands by keyword. This knowledge is fundamental for effective system administration and troubleshooting in Red Hat Enterprise Linux.

Note: Make sure you have returned to the command prompt before clicking the Continue button. Otherwise, the lab will not be able to verify your operation.

Summary

In this lab, you learned how to effectively navigate and search man pages in RHEL, which are crucial for understanding commands and their functionalities. You practiced navigating within a man page using keys like Spacebar, PageUp, DownArrow, UpArrow, D, U, G, and Shift+G, and exiting with Q.

Furthermore, you gained skills in searching for specific strings within an open man page using / for forward searches and ? for backward searches, and repeating searches with n and N. You also learned how to find relevant man pages by keyword using man -k or apropos, and how to perform full-text searches across all man pages for keywords using man -K.