Help on linux command line

How can I get help on terminal commands?

I’d also like to mention tldr.sh, which is an effort to simplify and present man pages in a better way.

@Nodon’tshownmyrealname Would you write an answer about tldr ? You could also mention cheat and maybe cheat.sh.

9 Answers 9

What is a man page?

A man page (short for manual page) is the traditional form of software documentation on a Unix-like OS like Ubuntu. For the vast majority of commands and programs there’s a man page which lists its options and explains its usage.

How can I find and view man pages?

Offline in a terminal

Man pages are automatically installed on your system together with the commands they describe. To view and search man pages there’s the command man :

displays the man page of mv while

searches names and short descriptions of all installed man pages for the string mv . POSIX Extended Regular Expressions are allowed and it’s a search, so this will also find e.g. git-mv and semver , if you want to search exactly mv use ^mv$ instead.

See What is the difference between `man` and `man (#)`? to read about man page sections. For more information read man ‘s man page. 😉

How can I influence how a man page is displayed?

The default program to display man pages is less . This so-called pager provides a helpful search function, just enter / followed by the search term, e.g.

and press Enter . This will mark every finding and scroll to the first one. Press N to go to the next finding and ⇧ Shift + N to go to the previous one (see How can I search within a manpage?). For a list of commands press H , to exit less press Q .

Beside less there are other pagers available: pg , most and w3m just to list three. I recommend most : It comes with a very useful coloring of key words making a man page much easier to read and navigate, see for yourself:

most screenshot displaying mv's manpage

To view a man page in a different than your default pager use the -P option, e.g.:

If you want to change the default pager manpages are displayed with you have two options:

    change the default pager solely of man

sudo update-alternatives --config pager 

Fans can even (ab)use vim as the MANPAGER , see this article written by muru.

Читайте также:  Linux gtk warning cannot open display

Man pages are displayed in the font specified in your terminal emulator settings. If you work with the terminal regularly you might want to change this font; I can only recommend Hack – a typeface designed for source code, see the screenshot above for its beauty.

Offline via GUI

A nice and easy way to display man pages with a simple GUI is the preinstalled yelp program. To start a man page with yelp execute yelp man:PROGRAM or gnome-help man:PROGRAM , e.g.:

You can also view man pages with your preferred browser, see How do I make man pages open in a web browser?, e.g. for man mv in firefox :

Last but not least you can convert man pages to PDF and view them with your preferred PDF viewer, see: Is there a way to print info/man pages to PDF?

Online

http://manpages.ubuntu.com

You can view the man pages of programs available via the repositories of every currently supported Ubuntu version with the shorthand URL manpg.es/PROGRAM , e.g. http://manpg.es/mv. This opens mv ‘s man page for the latest Ubuntu release, you can choose a different release in the top bar. To search for man pages you can use e.g. http://manpages.ubuntu.com/cgi-bin/search.py?q=mv.

As explained above man can only display man pages of software installed on the system. To view man pages from http://manpages.ubuntu.com using a terminal pager there’s dman available in the bikeshed package.

Other sources

When you read documentation from other online sources it’s a good idea to keep an eye on the program version. Most programs have a —version option that displays the version of the program in question, e.g.

$ mv --version mv (GNU coreutils) 8.25 

There are a lot of websites which dedicated themselves to make man pages easily available, I’m just going to present the two I like the most:

  • man7.org comes with useful syntax highlighting, but it features only the last released version of the program
  • manpag.es hosts man pages of Ubuntu releases long gone EOL

Источник

Terminal Basics #10: Getting Help in Linux Terminal

Learn how you can get help about using Linux commands in the final chapter of the Terminal Basics series.

These days, you can search the internet for the usage and examples of any command. But it was not like this when the internet didn’t exist, or it was not as widely available to everyone. For this reason, commands in Linux (and the operating systems before it) come with a help or manual page (man pages). This worked as a reference and users could access it anytime to see what options were available for a command and how it worked. The man pages are still relevant in this age of information abundance. First, they are the original command documentation and hence the most trusted source on command usage. Second, if you are taking some Linux exam, you will not be allowed to search on the internet but the man pages are always at your disposal. Now that you understand the importance of getting help directly in the terminal, let’s see more about them.

Читайте также:  Arch linux intellij idea

Get help with Linux commands in the terminal

Wait! What are shell built-in commands?

You may feel that commands like ls, rm, mv are part of the bash shell. But that’s not true. Shell only has a few commands that are built into it as a part of the shell itself. This is why they are called built-in commands. Some examples of built-in commands are echo, cd, and alias.

Other popular Linux commands like ls, mv, rm, cat, less, etc are part of a software package called GNU coreutils. They come preinstalled on almost all Linux distributions.

You won’t find man pages for the shell built-ins.

[email protected]:~$ man cd No manual entry for cd 

The man pages are for these ‘external’ Linux commands. The shell built-ins have help sections.

Use man to see command documentation

Using the man command is simple. Just give it command’s name like this:

And it will open the manual page of the command. You’ll find the syntax of the command, its options, and a brief explanation of the options.

An example manpage of the ip command in Linux

The pages are (usually) opened with the less command so you can use all the keyboard shortcuts of the less command to move around and search for text.

Don’t remember it? This will help you recall

Keys Action
Up arrow Move one line up
Down arrow Move one line down
Space or PgDn Move one page down
b or PgUp Move one page up
g Move to the beginning of the file
G Move to the end of the file
ng Move to the nth line
/pattern Search for pattern and use n to move to next match
q Exit

There is more to man pages than. I cannot cover it all here, but we do have a detailed guide. Feel free to refer to it.

Use help command for shell built-ins

As mentioned earlier, no man pages exist for the built-in shell commands. Instead, you use the help command like this:

It will show a summary of the command options. The entire content is displayed on the screen, unlike the man command.

Using help for built-in shell commands

Help option for all commands

Do you feel the man page has too much information and you just want to see the options of a command? The help option ‘helps’ you.

Almost all Linux commands provide a —help option that should summarize the available options.

Using help option of Linux commands

However, it’s not a hard and fast rule. The help sections of some commands are pretty bland. Try it for the ip command.

There are more ways to get help in Linux terminal

There is the info command that works similar to the man command.

If you find man pages complicated to understand, there are third-party tools that simplify the content of man pages and make it more beginner friendly. TLDR is one such package you can use.

Читайте также:  Linux command line openvpn

In other words, the help is just a few key presses away.

It’s not that only new Linux users need help. Experienced Linux users specially rely on the manpages. So don’t shy away from using the help in the terminal.

I also advise using the history command. This way, you can search for the commands you typed earlier.

This is the end. or the beginning

And with this, I conclude the Linux Terminal Basics series.

In the ten chapters of the series, you got familiar with the terminal, learned to move around in the terminal, and create, move and delete files and folders. You also learned to read and edit files.

This gives you a basic but solid foundation of Linux commands. It may be the end of this series, but it helps begin your Linux command line journey.

You’ll find more in-depth guides on ‘doing things in Linux command line’ on It’s FOSS in the future. It may not be in a series (or maybe it will) but you’ll have plenty of opportunity for learning.

💬 I hope you liked this beginner series. I welcome your feedback on the usability of this series and suggestions to improve it. If you have any suggestions for a related new series, please don’t hesitate. The comment section is waiting for you.

Источник

О команде help в Linux

Все подробности о команде help в Linux

Конечно же, невозможно запомнить все имеющиеся флаги для различных команд. Для этого существует встроенное руководство по каждой команде, которое можно вызвать специальным флагом -h или —help. Например, я попробовал ввести команду «ls -help»:

ls -help ls: неверный ключ — «e» По команде «ls --help» можно получить дополнительную информацию.

Как видите, командная строка вежливо меня поправила, так как я допустил ошибку, и предложила правильный вариант флага для этой команды.

Введя команду «ls —help» вы увидите длинный список флагов и того, что они делают, кстати, на моем дистрибутиве вывод из терминала был на русском языке.

help — Показывает информацию о встроенных командах в Linux

Синтаксис:

help [-dms] [команда, для которой нужно узнать информацию]

Описание:

Данная команда отображает краткое описание встроенных команд оболочки. Если указан шаблон команды, то «help» отображает подробную справку по всем опциям по запрашиваемой команде. В противном случае, «help» выдает весь список поддерживаемых команд, по которым выдает информацию.

Параметры:

  • d выводит краткое предназначение по запрашиваемой команде.
  • м выводит информации в формате псевдо-Man-страницы.
  • s выводит информацию только для использования синтаксиса по запрашиваемой команде.

Примеры:

Данная команда отобразить краткое описание встроенной команды оболочки echo.

Не все команды поддерживают параметр -h или —help. Это значит, что для таких команд существует manual (руководство). Для этого перед командой нужно написать man. Например: «man ls», что является вторым способом для подсказки параметров по команде «ls».

Источник

Оцените статью
Adblock
detector