Command Line Options Resource?

Is there a manual or list of options available to use in the command line?
Throughout many of the lessons on Codecademy we’re asked to make commands in the terminal and often they have ‘options’ attached that are not explained.

For example, in the git/GitHub lessons when setting up a repository, you’re asked to use these commands:

git branch -M main
git push -u origin main

While branch, push, origin and main are explained, the options -M and -u aren’t.

Is there any resource where you can look up all the different options that are used in the command line terminal?

Google has provided some help, but options like -b are still a mystery.

Any help would be much appreciated.

The answer is a bit of a yes and no, many tools have gone through numerous iterations and have branched off in several different ways such that the flags/options available to them may be a little different on a given system. I think there’s a few posts on the forums about the sed command in particular being different on OSX compared to GNU (but there’s more differences for this one in modern BSD, the older POSIX and likely other systems too).

Possibly the simplest route would be using the commands built-in help and the second being manuals provided with the command (they aren’t always provided and sometimes the wrong one can be included but most of the time a manual is a very good choice).

Depending on the command you might need to use one of the following-

command --help  # might be in-built help, may redirect to manual
command -h  # this one might be a bit less common as -h can be a real flag
man command  # open the manual page if one exists
info command
help command  # this one might be restricted to bash/zsh (aliased in zsh)

It sounds a bit hectic but you’ll get the hang of it in due course. With some tools like git you can take this a little bit further such that git branch --help will provide the manual documentation for branching in particular, roughly equivalent to man git-branch. Combining some of these with search tools like grep can be helpful.

For git in particular it should be standardised across all systems (new versions add bits but it should be backwards compatible). It also has excellent online documentation if you’d prefer reading it that way. Many older commands do have their manuals online but make sure you get the right one (GNU vs. BSD etc.).

The man command itself has a few additional options that help if you have name re-use (to find out more use man man). You may also be able to set it up such that man -Hbrowser command would open the manuals in the given browser, e.g. man -Hchromium ls if you don’t like reading from the command line itself.

In short there’s no need to memorise shortcuts though there’s nothing wrong with remembering those you use often. Normally the safest and easiest option is just viewing the help or manuals for a command on your own system.


Thanks for the lengthy response!
Very helpful - thanks!