Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using man from sorted by
Terminal - Commands using man - 61 results
man -Pcat urxvt | \ # see description for full command
2014-07-16 23:14:14
User: malathion
Functions: man
0

man -Pcat urxvt | sed -n '/th: b/,/^B/p'|sed '$d'|sed '/^ \{7\}[a-z]/s/^ */^/g' | sed -e :a -e 'N;s/\n/@@/g;ta;P;D' | sed 's,\^\([^@]\+\)@*[\t ]*\([^\^]\+\),! \2\n! URxvt*\1\n\n,g' | sed 's,@@\( \+\),\n\1,g' | sed 's,@*$,,g' | sed '/^[^!]/d' | tr -d "'\`"

Prints a precompiled list of options to add to your Xresources.

Provided by Charles Torvalds here: http://www.askapache.com/linux/rxvt-xresources.html#Output_RXVT_Resources

man inet
rtfm() { help $@ || man $@ || xdg-open "http://www.google.com/search?q=$@"; }
2014-04-25 04:17:03
User: KlfJoat
Functions: man
1

Same as the other rtfm's, but using the more correct xdg-open instead of $BROWSER.

I can't find a way to open info only if the term exists, so it stays out of my version.

man foobar | less +/searched_string
2013-11-06 18:50:11
User: mcescalante
Functions: less man
1

This will open the manpage for "foobar", and display all instances of "searched_string". You can traverse through them by pressing "n"

man <COMMAND>
2013-04-05 16:08:01
Functions: man
-4

Just type man and the name of the command you want information on followed by enter.. POW!!! there you have all you need to know on the subject.

man ls | egrep "^([A-Z]| [A-Z])"
2013-01-09 17:12:03
User: bartonski
Functions: egrep ls man
2

Uses the formatting of a man page to show an outline of its headers and sub-headers.

man -HBrowser manpage
2012-06-04 19:14:34
User: cassvin
Functions: man
0

Specify the Browser where you want to open the manpage.

man -t ls > ls.ps && pdf2ps ls.ps && rm ls.ps
man ascii
2012-01-26 20:39:13
User: titan2x
Functions: man
0

It shows the complete ascii table, and it works in BSD too, not only in Linux.

MANWIDTH=70 man 7 man
2012-01-13 19:42:30
User: escondida
Functions: man
Tags: man bashrc
0

Typographically speaking, it's generally the [accepted wisdom][1] that about 60 characters per line makes for optimal reading (would that more Web pages followed this convention!). I know I got tired of reading manpages with text as wide as my screen! However, the command above sets manwidth to 70 rather than 60 because paragraphs in manpages are generally indented.

I recommend the following snippet for your .${SHELL}rc, which sets manwidth to 70 unless your terminal is smaller than 70 characters:

function man () {

if [[ $COLUMNS -gt 70 ]]; then

MANWIDTH=70 command man $*

else

command man $*

fi

}

[1]: https://en.wikipedia.org/wiki/Column_(typography)

man -t man | ps2pdf - temp.pdf; evince temp.pdf &> /dev/null &; sleep 3; rm temp.pdf
2011-12-08 17:40:47
User: threv
Functions: man rm sleep
0

Yeah yeah, another "render man page in pdf", but this time it creates a temporary PDF that stays resident in memory for viewing, but is eliminated on the filesystem.

Replace evince with your PDF viewer of choice.

man -t awk | ps2pdf - awk.pdf
man <command> then type h
2011-10-16 09:49:56
User: stanix
Functions: man type
-5

Read all chapters up to 'Jumping', improve your effectiveness of wirking in terminal.

Most useful are the Moving and Searching commands

man () { if [[ $(type ${1}) =~ "is a shell builtin" ]]; then; /usr/bin/man -P "/usr/bin/less -iRs --pattern=\"^ *${1}\"" bash; else; /usr/bin/man ${1}; return; fi; }
2011-08-25 20:27:16
Functions: man type
0

ulimit [-SHacdflmnpstuv [limit]]

Provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The -H

and -S options specify that the hard or soft limit is set for the given resource. A hard limit cannot be increased once it is set; a

soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are set.

# jumps straight to the definition of ulimit in the bash man page.

manswitch () { man $1 | less -p "^ +$2"; }
2011-08-19 16:44:48
User: dbh
Functions: less man
Tags: grep switch
14

e.g.

manswitch grep -o

This will take you to the relevant part of the man page, so you can see the description of the switch underneath.

manswitch() { man $1 | grep -A5 "^ *\-$2"; }
2011-08-19 08:36:54
User: totti
Functions: grep man
Tags: man grep switch
1

Find the usage of a switch with out searching through the entire man page.

Usage: manswitch [cmd] [switch]

Eg:

manswitch grep silent

____________________________

In simple words

man <cmd> | grep "\-<switch>"

Eg:

man grep | grep "\-o"

This is not a standard method but works.

man emacs
2011-08-17 00:37:00
User: cwimmer
Functions: man
-2

Emacs backs up previous versions by default.

rtfm() { help $@ || man $@ || open "http://www.google.com/search?q=$@"; }
2011-01-26 06:23:42
User: vaporub
Functions: man
Tags: man google
0

Simple edit to work for OSX.

Now just add this to your ~/.profile and `source ~/.profile`

rtfm() { help $@ || info $@ || man $@ || $BROWSER "http://www.google.com/search?q=$@"; }
2011-01-05 21:26:51
Functions: info man
Tags: man info google
9

Some commands have more information on 'info' than in the man pages

rtfm() { help $@ || $@ -h || $@ --help || man $@ || $BROWSER "http://www.google.com/search?q=$@"; }
2011-01-05 17:36:26
User: karol
Functions: man
Tags: man google
3

Sometimes you don't have man pages only '-h' or '--help'.

rtfm() { help $@ || man $@ || $BROWSER "http://www.google.com/search?q=$@"; }
man -t manpage | ps2pdf - filename.pdf
2010-12-19 22:40:18
User: TetsuyO
Functions: man
47

Quick and dirty version. I made a version that checks if a manpage exists (but it's not a oneliner). You must have ps2pdf and of course Ghostscript installed in your box.

Enhancements appreciated :-)

man !!
2010-09-24 13:38:17
User: pahnin
Functions: man
-4

when we work with terminal often we open man pages for help if we did some mistakes

and when we want to open the man page for command we are working with this one helps

as many people may be knowing that '!!' performs the last command action

we use it in sudo !! to perform the last action with root previleages

man !! will also be helpful and handy

thanx

man $(ls -1 /usr/share/man/man?/ | shuf -n1 | cut -d. -f1)
2010-08-20 23:36:10
User: dooblem
Functions: cut ls man
Tags: man sort shuf
-3

Another one.

Maybe not the quicker because of the sort command, but it will also look in other man sections.

updated with goodevilgenius 'shuf' idea

man $(ls /bin | shuf | head -1)
2010-08-20 23:12:51
Functions: head ls man
Tags: man
1

I'm not sure why you would want to do this, but this seems a lot simpler (easier to understand) than the version someone submitted using awk.