Commands matching man (529)

  • Booting the VM headless via VBoxHeadless requires knowledge of the VM's network in order to connect. Using VBoxManage in this way and you can SSH to the VM without first looking up the current IP, which changes depending on how you have your VM configured. Show Sample Output


    9
    ssh vm-user@`VBoxManage guestproperty get "vm-name" "/VirtualBox/GuestInfo/Net/0/V4/IP" | awk '{ print $2 }'`
    lucasrangit · 2011-05-04 18:01:36 6
  • Some commands have more information on 'info' than in the man pages


    9
    rtfm() { help $@ || info $@ || man $@ || $BROWSER "http://www.google.com/search?q=$@"; }
    seattlegaucho · 2011-01-05 21:26:51 43
  • This microscript looks up a man page for each word possible, and if the correct page is not found, uses w3m and Google's "I'm feeling lucky" to output a first possible result. This script was made as a result of an idea on a popular Linux forum, where users often send other people to RTFM by saying something like "man backup" or "man ubuntu one". To make this script replace the usual man command, save it as ".man.sh" in your home folder and add the following string to the end of your .bashrc file: alias man='~/.man.sh' Show Sample Output


    9
    /usr/bin/man $* || w3m -dump http://google.com/search?q="$*"\&btnI | less
    d1337r · 2010-10-05 13:51:39 6
  • If shell escaping of the command is problematic, you can write the command to a file first: batch <somefile Or read it: read -re && echo "$REPLY" | batch Or, if your shell supports it, you can eliminate echo: read -re && batch <<<$REPLY ("man batch" lists 1.5 for me, but I don't know how widely it differs.)


    9
    echo 'some command' | batch
    kniht · 2010-07-14 03:08:31 3
  • This little function will smarten 'cd'. If you try to cd into a file (which I guess we all have done), it cd's into the directory of that file instead. I had to use nesten if's, to get cd to still work with 'cd' (to get to $HOME), 'cd -' (to get to last directory), and 'cd foo\ bar'. Show Sample Output


    9
    cd() { if [ -z "$1" ]; then command cd; else if [ -f "$1" ]; then command cd $(dirname "$1"); else command cd "$1"; fi; fi; }
    xeor · 2010-04-23 19:17:43 6

  • 9
    curl http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-2500:25] | grep -v _curl_ > comfu.txt
    Neo23x0 · 2010-04-01 08:46:20 39
  • Sometimes you have a script that needs and inputfile for execution. If you don't want to create one because it may contain only one line you can use the ` mysql -uuser -ppass dbname < <(echo "SELECT * FROM database;") This can be very usefull when working with mysql as I showed in the example code above. This will create a temporary file that is used to execute mysql and for example select all entrys from a specific database.


    9
    any_script.sh < <(some command)
    cb0 · 2010-02-21 18:44:33 27
  • This will calculate the your commandlinefu votes (upvotes - downvotes). Hopefully this will boost my commandlinefu points. Show Sample Output


    9
    username=matthewbauer; curl -s http://www.commandlinefu.com/commands/by/$username/json | tr '{' '\n' | grep -Eo ',"votes":"[0-9\-]+","' | grep -Eo '[0-9\-]+' | tr '\n' '+' | sed 's/+$/\n/' | bc
    matthewbauer · 2010-02-14 04:32:36 11

  • 9
    curl -sd q=Network http://www.commandlinefu.com/search/autocomplete |html2text -width 100
    commandlinefu · 2009-07-09 00:57:28 10
  • Welcome to Jon H. (@fart), the new maintainer of CommandLineFu. . In the absence of a forum, I encourage people welcome him, here, in the comments. . Also... What would you like to improve/change about the site?


    8
    mail tech@commandlinefu.com
    flatcap · 2015-04-06 13:43:04 120

  • 8
    compgen -c | sort -u > commands && less commands
    Habitual · 2012-04-27 14:19:05 6
  • The $(!!) will expand to the previous command output (by re-running the command), which becomes the parameter of the new command newcommand.


    8
    newcommand $(!!)
    lpb612 · 2011-09-01 21:02:17 5
  • ':r!ls -l' results in listing the files in the current directory and paste it into vi


    8
    :r! <bash_command>
    Dimitri · 2011-03-02 16:55:57 5
  • This works in bash. The "!!:0" limits the argument to man to be only the first word of the last command. "!!:1" would be the second, etc.


    8
    man !!:0
    stubby · 2010-08-14 15:38:55 8
  • Each shell function has its own summary line, as a comment. If there are multiple shell functions with the same name, the function with the highest number of votes is put into the file. Note: added 'grep -v' to the end of the pipeline, to eliminate extraneous lines containing only '--'. Thanks to matthewbauer for pointing this out.


    8
    export QQ=$(mktemp -d);(cd $QQ; curl -s -O http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/[0-2400:25];for i in $(perl -ne 'print "$1\n" if( /^(\w+\(\))/ )' *|sort -u);do grep -h -m1 -B1 $i *; done)|grep -v '^--' > clf.sh;rm -r $QQ
    bartonski · 2010-01-30 19:47:42 40

  • 8
    function manpdf() {man -t $1 | ps2pdf - - | epdfview -}
    Aparicio · 2010-01-07 02:05:03 4
  • You can set the previous bash command as the terminal title by this command. Explanation: -trap assigns a command to execute at a given bash signal. -in the $BASH_COMMAND you find the last command -you can set the terminal title with the escape sequence: \e]0;this is the title\007 -to let the echo care about the backslashes give the -e to it Since trap is a built in bash command you find more informatin in 'man bash'for more Source: http://www.davidpashley.com/articles/xterm-titles-with-bash.html


    8
    trap 'echo -e "\e]0;$BASH_COMMAND\007"' DEBUG
    Vereb · 2009-09-29 21:09:21 18
  • I don't truly enjoy many commands more than this one, which I alias to be ps1.. Cool to be able to see the heirarchy and makes it clearer what need to be killed, and whats really going on. Show Sample Output


    8
    command ps -Hacl -F S -A f
    AskApache · 2009-08-19 07:08:19 10

  • 8
    pacman -Q|wc -l
    freenight · 2009-07-31 08:01:13 4
  • -N removes header -s removes separator chars -r raw output After using these options, the MySQL ouptut can be used with pipes very easily Show Sample Output


    8
    mysql DATABASE -N -s -r -e 'SQL COMMAND'
    alperyilmaz · 2009-03-24 19:53:46 5
  • Would be better if gnome-open would accept std in Should be doable in KDE - anyone?


    8
    TF=`mktemp` && man -t YOUR_COMMAND >> $TF && gnome-open $TF
    furicle · 2009-02-18 15:18:35 9
  • Here is the full function (got trunctated), which is much better and works for multiple queries. function cmdfu () { local t=~/cmdfu; until [[ -z $1 ]]; do echo -e "\n# $1 {{{1" >> $t; curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext" | sed '1,2d;s/^#.*/& {{{2/g' | tee -a $t > $t.c; sed -i "s/^# $1 {/# $1 - `grep -c '^#' $t.c` {/" $t; shift; done; vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t; rm $t $t.c } Searches commandlinefu for single/multiple queries and displays syntax-highlighted, folded, and numbered results in vim. Show Sample Output


    7
    cmdfu(){ local t=~/cmdfu;echo -e "\n# $1 {{{1">>$t;curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext"|sed '1,2d;s/^#.*/& {{{2/g'>$t;vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t;rm $t; }
    AskApache · 2012-02-21 05:43:16 11
  • Calls sudo tee like all the other lines, but also automatically reloads the file. Optionally you can add command Wq :execute ':W' | :q and command WQ :Wq to make quitting easier


    7
    command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
    unixmonkey26167 · 2011-10-06 20:37:54 7
  • Seeing that we get back plain text anyway we don't need lynx. Also the sed-part removes the credit line.


    7
    wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed -n '1d; /./p'
    dramaturg · 2010-12-05 15:32:14 11
  • for me the above command didn't work for more than one argument but this one does


    7
    curl "http://www.commandlinefu.com/commands/matching/$(echo "$@" | sed 's/ /-/g')/$(echo -n $@ | base64)/plaintext"
    potatoface · 2010-08-23 20:25:13 6
  •  < 1 2 3 4 5 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Show your current network interface in use

Redirect incoming traffic to SSH, from a port of your choosing
Stuck behind a restrictive firewall at work, but really jonesing to putty home to your linux box for some colossal cave? Goodness knows I was...but the firewall at work blocked all outbound connections except for ports 80 and 443. (Those were wide open for outbound connections.) So now I putty over port 443 and have my linux box redirect it to port 22 (the SSH port) before it routes it internally. So, my specific command would be: $iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 22 Note that I use -A to append this command to the end of the chain. You could replace that with -I to insert it at the beginning (or at a specific rulenum). My linux box is running slackware, with a kernel from circa 2001. Hopefully the mechanics of iptables haven't changed since then. The command is untested under any other distros or less outdated kernels. Of course, the command should be easy enough to adapt to whatever service on your linux box you're trying to reach by changing the numbers (and possibly changing tcp to udp, or whatever). Between putty and psftp, however, I'm good to go for hours of time-killing.

Force unmount occupied partition
Alternative if "Lazy unmount" (umount -l) doesn't obey. Alternative for NFS: $ umount -f /media/sdb1 Use with caution: forcing to unmount a busy partition can cause data loss!

Send pop-up notifications on Gnome
The title is optional. Options: -t: expire time in milliseconds. -u: urgency (low, normal, critical). -i: icon path. On Debian-based systems you may need to install the 'libnotify-bin' package. Useful to advise when a wget download or a simulation ends. Example: $ wget URL ; notify-send "Done"

Block an IP address from connecting to a server
This appends (-A) a new rule to the INPUT chain, which specifies to drop all packets from a source (-s) IP address.

notify brightness level [custom]
Brightness indicator to be used in scripts that adjust brightness [especially sys that doesn't support automatically]

get all Amazon cloud (amazonws etc) ipv6 subnets

Convert epoch date to human readable date format in a log file.

Wait for file to stop changing
This loop will finish if a file hasn't changed in the last 10 seconds. . It checks the file's modification timestamp against the clock. If 10 seconds have elapsed without any change to the file, then the loop ends. . This script will give a false positive if there's a 10 second delay between updates, e.g. due to network congestion . How does it work? 'date +%s' gives the current time in seconds 'stat -c %Y' gives the file's last modification time in seconds '$(( ))' is bash's way of doing maths '[ X -lt 10 ]' tests the result is Less Than 10 otherwise sleep for 1 second and repeat . Note: Clever as this script is, inotify is smarter.

Adhoc tar backup
Creates a quick backup with tar to a remote host over ssh.


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: