Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am curious to know what trick you use to remember options for various commands? Looking up man pages all the time is time consuming and not so cool!

share|improve this question

closed as primarily opinion-based by Braiam, slm Aug 5 '14 at 2:44

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

Among other things: unix.stackexchange.com/questions/138720/… is handy for creating a customized summary of things I habitually screw up or forget. BTW, the more you read man pages, the more you come to appreciate them. – goldilocks Aug 3 '14 at 20:14
I some time feel i am forgetting everything. I was wondering if i am the only one who has hard time remembering all useful options on top of the head..Your suggestion seems like a good solution..Thank you! – Atul Aug 3 '14 at 20:17
Reading man pages is very cool... :) – jasonwryan Aug 3 '14 at 21:32
Q: How do you get to Carnegie Hall? A: Practice! – evilsoup Aug 3 '14 at 22:15
I think this deserves some XKCD: xkcd.com/1168 – Darkhogg Aug 4 '14 at 1:29
up vote 35 down vote accepted

The trick is simple: You just don't. It's a waste of time and just not necessary. Memorizing command options isn't a particularly useful skill. It's much more important to understand how stuff works in general and to have a vague idea which tools exist in the first place and what you use them for. A very important skill here is to know how to find out about stuff you don't know yet.

Man pages are time consuming? Not so. It's not like you have to read them - at least, not every time - there is a search function. So if I don't remember which cryptic option was the one for hdparm to disable idle timer on some WD disks, I do man hdparm and /idle3 and hey, it was -J. Looking stuff like that up is so quick I don't even remember doing it afterwards.

Imagine someone actually memorizing all of the hdparm options. What a waste of time.

It's fine if you just happen to remember options because you use them frequently. That happens automatically without even thinking about it. But actually consciously spending time on memorizing them... what's that supposed to be good for? A paper test?

share|improve this answer
Upvoted: the skill is finding what you need, not rote memory. man hdparm | less -p idle3 is also a handy way to jump to the desired term... – jasonwryan Aug 3 '14 at 23:31
I fully agree with this answer, though I think it's worth emphasizing that it is normal to have the few most common options to common programs memorized, just because you use them so often. Like rm -i -f -r, ln -s, df -s -h, cp -r -i, ls -l -h -a, etc. (the list varies from person to person). – David Z Aug 4 '14 at 2:41

Zsh has the run-help function, by default bound to Alth. With this function you can begin typing a command with many or complex options that are difficult to remember, like rsync for example, and then have that command's man page opened. So:

 rsync Alth

read the man page and work out which switches you require, hit q and then you are returned to your command prompt, exactly where you left off, ready to complete the command with the requisite options:

rysnc -azP file dir/

As the wiki notes:

The function can be further customized by defining helper functions of the form run-help-command. There are three such functions available in the standard distribution: run-help-git, run-help-svk, and run-help-svn.
share|improve this answer
Similarly bash has bash-complete which will supply a lot of parameter options for a lot of commands. – ericx Aug 3 '14 at 21:48
@ericx "Similarly" might be overstating it a little... Zsh also has completion, this is a step up from that. – jasonwryan Aug 3 '14 at 22:01
hey... I've heard folks brag, but I've never tried zsh – ericx Aug 3 '14 at 22:07
@ericx, also, bash's completion doesn't support adding descriptions to the completion list, or grouping entries (--classify -F -- append file type indicators for example in zsh's GNU ls completion) so is not nearly as useful as zsh's. – Stéphane Chazelas Aug 5 '14 at 11:10
** root@milicent ** ~/tmp ** Tue Aug 05 09:24:55 # pkg info (-e -d -f -l -o -p -D)-r[Displays the reverse dependencies] (-e -d -r -f -o -p -D)-l[Displays all files] (-e -d -r -l -f -p -D)-o[Displays origin] (-e -d -r -l -o -f -D)-p[Displays prefix] (-e -d -r -l -o -p -D)-f[Displays full information] (-e -d -r -l -o -p -f)-D[Displays message] (-e -f -r -l -o -p -D)-d[Displays the dependencies] (-f -d -r -l -o -p -D)-e[Returns 0 if <pkg-name> is installed] (-g -X -a -F)-x[Process packages that match the regex pattern] (-g -x -X -F)-a[Process all package – ericx Aug 5 '14 at 13:26

Most commands have --help for quick reference, and it is usually enough to remind what was something that I used to know.

That said have a habit of writing --help instead of -h or even -?. You never know what -h is before looking usage output or manual page. In worst case the -h might be short hand for --hazardous-automatic-destruction.

share|improve this answer
...Most commands on GNU systems. commands on Unix systems typically don't have --help. -? needs quoting with zsh, csh, tcsh or fish or if there are files whose name are - followed by a single character in the current directory. -: may be preferable there. – Stéphane Chazelas Aug 3 '14 at 21:25
Well.. many non GNU systems has so appalling usage outputs they are pointless to even look. In such case see man pages & best of luck memorizing by hard coz nothing else will work. – kerolasa Aug 3 '14 at 22:29
"That said have a habit of writing". Missing word? – Faheem Mitha Aug 3 '14 at 22:30
Missing comma. Unfortunately, since it's only one character, the website won't let me add it. – Mark Aug 4 '14 at 23:46

Using a very long command history, and seaching through it, is very useful.

I basically collect all shell history files, and grep through them.

The results found are in many cases very useful, as it's easy to seach for good keywords.
Searching for a speciffic argument you used, like an URL, you find the related commands and options too. And searching for speciffic options, you may find relevant arguments too.

share|improve this answer

One option I like is to create aliases that have the same or similar options, e.g.

alias rmi='rm -i'
alias rmiv='rm -iv'
alias rmv='rm -v'
alias cpr='cp -r'
alias cprv='cp -rv'

This way you have a nice shortcut that you'll soon remember easily but that will also retain information about the actual option(s) it reflects.

Another approach with aliases is to pick the most common options and make a super short alias that uses them. For instance for ls I nearly always do l and that is because I have:

alias l='ls -alFtrG'

Another option is to just bring in the the options you like to the base command, e.g.

alias ls='ls -F --color=always'

Finally practice, practice, practice and patience. Keep typing common options and you will eventually learn them. The common ones in days, others in weeks and yes some take years to become known to you. Think of that as a treat in that unix programming will continue to entertain you for a long time.

Another option that I like is an alias to make searching my history easier and for that I have two similar aliases:

alias hg='history | tail -200 | grep -i'
alias hga='history | grep -i'

These let me search for uses of a command for instance:

hg ls will show any recent uses of ls from history
hga ls will show all uses of ls from my entire history.

I developed hg after finding that hga tended to show too much.

share|improve this answer
If OP can't remember what rm -iv does, OP probably also won't remember what rmiv does. I don't think it's the hyphen that's the problem. – tobyink Aug 4 '14 at 0:15
I'd personally alias rm -iv to safe_delete or rm_prompt – slebetman Aug 5 '14 at 1:31
Thank you guys! I guess i was worrying to much for remembering more than learning more..I shall learn when to use the weapon instead of learning what is the bullet dimensions and velocity! Lucky to have so many good linux folks here.. Cheers to unix/linux!! – Atul Aug 5 '14 at 21:57

I typically do:

man ${CMD} | grep 'what was I thinking about?'

Or some variation thereof. With some greps you can specify -C/A/B for context, after, and before respectively. If not, nl and sed can be pretty well matched:

man hdparm |                      #hard to forget
nl -bp'idle3' -nln -w1 |          #I had to grep man to put this together
sed -n '/^[0-9]/{N;N;N;s///p}'    #no print until line begins w/ number, next,next,next

           Drive's "idle3" timeout value.  This timeout
            controls how often the drive parks its heads
            and  enters  a  low power consumption state.
            The factory default is  eight  (8)  seconds,
           zero (0) to disable the WD idle3 timer  com‐
            pletely (NOT RECOMMENDED!).

     -k     Get/set  the "keep_settings_over_reset" flag

The same techniques work with --help menus if you have them, but you might need to do a ${CMD} --help 2>&1 | ..filter.. because is a fairly standard practice to print such things to stderr.

Anyway, I guess the moral of the story is, remember at least man and grep. Maybe don't sweat the rest.

share|improve this answer
+1. I often grep man pages when looking for a particular feature, that's pretty handy. – John WH Smith Aug 4 '14 at 21:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.