Stuck in the Linux Terminal? Do This Before You Google It

Ever typed a command and then realized you have no idea how to use it? Before opening your browser and searching for answers, you can try out the built-in help in the Linux terminal that the command came with. Believe me, you don’t even need to search the internet most of the time.

First, Try Built-in Help

For many reasons, you may just use the built-in -h or –help flags with the command you want to learn about to understand its usage. There are instances when you may have a slow internet connection or not have an internet connection at all. In such cases, you won’t be able to correctly display the web pages.

In most cases, the online manual pages contain the exact same information as the built-in help function. If that is the case, there’s no need to refer to the online pages to get the same information. Using the built-in system is much faster. It saves you time and a few clicks when you only want to check some simple syntax or available options.

Related

Linux Commands Are Easy When You Know How to Read Usage

Get to know command usage and unlock the power of Linux.

Another thing to consider is that some online tutorials have outdated information or mistakes. This happens when something about the Linux command changes but the authors don’t update their tutorial accordingly. Even here at How-To Geek, we can’t keep every guide up to date at all times. The official documentation or manual page, on the other hand, is always the latest or, more importantly, accurate to the version you have. That way, you don’t need to worry about something not working.

Using –help for Quick Guidance

Most Linux commands support -h or –help to display available options. So, if you’re not sure how to use a certain command, add -h or –help after the command and hit Enter. It will display what that command is used for, all the available options you have for that command, and which option does what. You can get a quick overview of the command’s usage.

For example, let’s say you’re trying to list files with ls, but you’re not sure which flags to use. So, you can run this command:

ls --help

You’ll get a brief summary of all available options, like -l (lowercase L) for long format or -a to show hidden files. The output might look overwhelming at first, but it’s often the fastest way to find the option you need.

Most commands support either -h or –help or sometimes both. Some commands may have -h as a flag for another purpose. For example, the ls command I showed earlier uses -h to display the directory content in human-readable format. So, if -h doesn’t work, try –help.

Some commands may not have any –help at all. Those are the exceptions. In such cases, you’ll want to check out the man command, which I’ll cover next.

Understanding Linux Man Pages

If –help gives you a quick overview, man pages (short for manual pages) are the full-blown instruction manuals for Linux commands. They provide detailed documentation, including what a command does, its options, and even some examples. However, in some cases, you’ll find that both show almost the same thing.

Related

How to Use Linux’s man Command: Hidden Secrets and Basics

Need to search for a Linux command, but don’t know what it’s called? That’s what the man pages are for!

To access a command’s man page, simply type:

man command_name

For example, to learn everything about the ls command, type

man ls

This opens a structured manual, usually divided into sections such as:

  • NAME: A short description of the command
  • SYNOPSIS: How to use the command, including the required syntax
  • DESCRIPTION: A detailed explanation of what the command does
  • OPTIONS: A list of all available flags and what they do

You can scroll through a man page using the arrow keys, exit with q, and search for keywords by typing forward slash followed by the keyword, like /keyword. If you need further help navigating the man page, you can type h and hit Enter. For the manual page of the man command itself, you can always run:

man man

In the beginning, man pages can be overwhelming. You might feel lost and can’t make anything out of them. But they’re an essential resource for you as a Linux user. If a man page feels too dense, don’t worry; there are simpler alternatives.

Alternative Terminal Assistance

If you don’t want to use the man command, then there’s an alternative command called tldr. The tldr command summarizes a command’s available options and displays example commands that are mostly used. You’ll first need to install it on your Linux machine. After that, run:

tldr command_name

Going back to the previous example, let’s check out what the ls command does.

tldr ls

As you can see, this is much easier to read and understand. The tldr command is like a cheat sheet you can use when you forget the exact syntax you require to perform a task using a command.

Related

Man Pages Too Complex? Try tldr to Learn Linux Commands

If you’re finding man pages too sharp at the edges, try polishing them with tldr.


The –help option and the man command are both useful to learn about a Linux command without consulting the internet. The tldr command is helpful as a reference guide when you need a full-blown command you can copy and run. Besides, there are many more tricks to make learning the command line easier.


Source link
Exit mobile version