Nobody memorises every option. Linux gives you quick help right at the prompt, and which kind you use depends on what sort of command you have.
Built-in or program?
Some commands are built into the shell, such as cd. Others are separate programs on disk, such as ls. The type command tells you which:
$ type cd
cd is a shell builtin
$ type ls
ls is /usr/bin/lsYou might instead see that ls is aliased or hashed.
The help built-in
In bash, help describes shell built-ins:
$ help pwd
pwd: pwd [-LP]
Print the name of the current working directory.The real output continues with the options. Run help with no argument to list the built-ins. help -d cd gives a one line description. help is a bash feature, so other shells may not have it.
It does not cover external programs:
$ help ls
bash: help: no help topics match `ls'. Try `help help' or `man -k ls' or `info ls'.The --help option
Most GNU programs accept --help and print a usage summary:
$ mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.This is a convention, not a rule. Some programs use -h, and BSD or macOS tools often only print a short usage line with an error. Do not assume -h means help: for ls and df it means human readable sizes.
If the text is long, pipe it into a pager:
$ ls --help | lessReading a usage line
[ ]marks something optional....means it can be repeated.- Words in capitals are placeholders for your own values.
So mkdir [OPTION]... DIRECTORY... means any number of options, then one or more directories.
When you need more than a summary, read the manual page with man.
Try it
- Run
typeoncd,ls,echoandpwd. - Read
help cd. - Run
cp --help | lessand find the option for recursion. - Write out in words what the first usage line of
cp --helpmeans.
Check your understanding
help
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.