All commands (14,187)


  • -4
    wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
    sanjaygoel · 2009-11-06 10:18:26 3
  • That makes a function you can put in your ~/.bashrc to run it when you need in any term with an IP as argument Show Sample Output


    3
    GeoipLookUp(){ curl -A "Mozilla/5.0" -s "http://www.geody.com/geoip.php?ip=$1" | grep "^IP.*$1" | html2text; }
    sputnick · 2009-11-06 00:32:27 4
  • Halt script progress until a key has been pressed. Source: http://bash-hackers.org/wiki/doku.php/mirroring/bashfaq/065


    25
    read -sn 1 -p "Press any key to continue..."
    kalaxy · 2009-11-05 21:53:23 11

  • 8
    umount -a -t nfs
    sdadh01 · 2009-11-05 20:57:32 5
  • Simple MAC adrress, thanks to ifconfig.


    0
    ifconfig | awk '/HW/ {print $5}'
    Cont3mpo · 2009-11-05 18:00:50 4

  • -2
    mount | awk '/:/ { print $3 } ' | xargs sudo umount
    uid0 · 2009-11-05 17:19:11 3
  • ...or for a particular interface...


    0
    ip link show eth0 | grep "link/ether" | awk '{print $2}'
    maxmanders · 2009-11-05 17:06:15 3
  • Of course, you can adjust "Maildir" to your config... Show Sample Output


    1
    find ~/Maildir/ -mindepth 1 -type d | egrep -v '/cur$|/tmp$|/new$' | xargs
    ook · 2009-11-05 14:11:29 3
  • Alternative command to retrieve the CPU model name and strip off the "model name : " labels. Show Sample Output


    0
    sed -n 's/^model name[ \t]*: *//p' /proc/cpuinfo
    jgc · 2009-11-05 10:59:31 4
  • require the tex4ht package . You can open the file with openoffice , I use it much for correct my spelling and grammar . Show Sample Output


    2
    htlatex MyFile.tex "xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"
    eastwind · 2009-11-05 10:12:28 5
  • Extracts the model name of the CPU and displays it on screen. Show Sample Output


    3
    grep "model name" /proc/cpuinfo
    getkaizer · 2009-11-05 05:23:30 4
  • Useful tool to test if all speaker channels are working properly. speaker-test is part of alsa-utils package Show Sample Output


    5
    speaker-test -D plug:surround51 -c 6 -l 1 -t wav
    alperyilmaz · 2009-11-05 02:57:46 3
  • For those of us that still uses lynx :)


    -5
    lynx --dump http://ip.boa.nu|sed -e 's/^[[:space:]]*//' -e 's/*[[:space:]]$//'|grep -v ^$
    xeor · 2009-11-04 22:23:45 3
  • Using our beloved wget


    -6
    wget -O - -q ip.boa.nu
    xeor · 2009-11-04 22:22:04 3

  • -3
    curl whatismyip.org
    m8t · 2009-11-04 21:40:31 3
  • I much prefer using /sbin/ip over /sbin/ifconfig for most everything. I find the interface and output to be much more consistent and it has many abilities that ifconfig, route, etc. do not. To get the mac address for only one interface, add 'show dev [interface]' to the 'ip link' part of the command: ip link show dev eth0 | grep 'link/ether' | awk '{print $2}' . Also, both this command and the ifconfig one do not require root access to run, so the sudo is not necessary. Show Sample Output


    1
    ip link | grep 'link/ether' | awk '{print $2}'
    markdrago · 2009-11-04 19:41:26 19

  • -2
    sudo ifconfig -a | grep eth | grep HW | cut -d' ' -f11
    rubenmoran · 2009-11-04 19:24:35 3
  • Adds up the total memory used by all Stainless processes: 1 Stainless, 1 StainlessManager and 1 StainlessClient per tab open. Show Sample Output


    0
    ps -ec -o command,rss | grep Stainless | awk -F ' ' '{ x = x + $2 } END { print x/(1024) " MB."}'
    unixmonkey6893 · 2009-11-04 19:01:22 6
  • This command uses the top voted "Get your external IP" command from commandlinefu.com to get your external IP address. Use this and you will always be using the communities favourite command. This is a tongue-in-cheek entry and not recommended for actual usage.


    -1
    eval $(curl -s http://www.commandlinefu.com/commands/matching/external/ZXh0ZXJuYWw=/sort-by-votes/plaintext|sed -n '/^# Get your external IP address$/{n;p;q}')
    jgc · 2009-11-04 16:58:31 6
  • There's been so many ways submitted to get your external IP address that I decided we all need a command that will just go pick a random one from the list and run it. This gets a list of "Get your external IP" commands from commanlinefu.com and selects a random one to run. It will run the command and print out which command it used. This is not a serious entry, but it was a learning exercise for me writing it. My personal favourite is "curl icanhazip.com". I really don't think we need any other ways to do this, but if more come you can make use of them with this command ;o). Here's a more useful command that always gets the top voted "External IP" command, but it's not so much fun: eval $(curl -s http://www.commandlinefu.com/commands/matching/external/ZXh0ZXJuYWw=/sort-by-votes/plaintext|sed -n '/^# Get your external IP address$/{n;p;q}') Show Sample Output


    3
    IFS=$'\n';cl=($(curl -s http://www.commandlinefu.com/commands/matching/external/ZXh0ZXJuYWw=/sort-by-votes/plaintext|sed -n '/^# Get your external IP address$/{n;p}'));c=${cl[$(( $RANDOM % ${#cl[@]} ))]};eval $c;echo "Command used: $c"
    jgc · 2009-11-04 16:55:44 9
  • If your script needs to be run in a terminal, this line at the top will stop it running if you absent-mindedly double-click the icon, perhaps intending to edit it. (Of course this won't help with scripts that run in the background.)


    0
    tty > /dev/null 2>&1 || { aplay error.wav ; exit 1 ;}
    johnraff · 2009-11-04 16:18:00 6
  • Not my script. Belongs to mathewbauer. Used without his permission. This script gives a single line as shown in the sample output. NOTE: I have blanked out the IP address for obvious security reasons. But you will get whatever is your IP if you run the script. Tested working in bash. Show Sample Output


    10
    curl -s "http://www.geody.com/geoip.php?ip=$(curl -s icanhazip.com)" | sed '/^IP:/!d;s/<[^>][^>]*>//g'
    getkaizer · 2009-11-04 07:15:02 11

  • 4
    svn ci `svn stat |awk '/^A/{printf $2" "}'`
    realist · 2009-11-04 03:30:07 3
  • Create a binary clock. Show Sample Output


    36
    watch -n 1 'echo "obase=2;`date +%s`" | bc'
    matthewbauer · 2009-11-04 02:04:00 13
  • Figures out what has changed in the last 12 hours. Change the author to yourself, change the time since to whatever you want. Show Sample Output


    3
    git diff --stat `git log --author="XXXXX" --since="12 hours ago" --pretty=oneline | tail -n1 | cut -c1-40` HEAD
    askedrelic · 2009-11-04 01:41:33 3
  • ‹ First  < 430 431 432 433 434 >  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

Alias TAIL for automatic smart output
Run the alias command, then issue $ps aux | tail and resize your terminal window (putty/console/hyperterm/xterm/etc) then issue the same command and you'll understand. $ ${LINES:-`tput lines 2>/dev/null||echo -n 12`} Insructs the shell that if LINES is not set or null to use the output from `tput lines` ( ncurses based terminal access ) to get the number of lines in your terminal. But furthermore, in case that doesn't work either, it will default to using the default of 80. The default for TAIL is to output the last 10 lines, this alias changes the default to output the last x lines instead, where x is the number of lines currently displayed on your terminal - 7. The -7 is there so that the top line displayed is the command you ran that used TAIL, ie the prompt. Depending on whether your PS1 and/or PROMPT_COMMAND output more than 1 line (mine is 3) you will want to increase from -2. So with my prompt being the following, I need -7, or - 5 if I only want to display the commandline at the top. ( http://www.askapache.com/linux/bash-power-prompt.html ) 275MB/748MB [7995:7993 - 0:186] 06:26:49 Thu Apr 08 [askapache@n1-backbone5:/dev/pts/0 +1] ~ $ In most shells the LINES variable is created automatically at login and updated when the terminal is resized (28 linux, 23/20 others for SIGWINCH) to contain the number of vertical lines that can fit in your terminal window. Because the alias doesn't hard-code the current LINES but relys on the $LINES variable, this is a dynamic alias that will always work on a tty device.

generate a unique and secure password for every website that you login to
usage: sitepass MaStErPaSsWoRd example.com description: An admittedly excessive amount of hashing, but this will give you a pretty secure password, It also eliminates repeated characters and deletes itself from your command history. tr '!-~' 'P-~!-O' # this bit is rot47, kinda like rot13 but more nerdy rev # this avoids the first few bytes of gzip payload, and the magic bytes.

Route outbound SMTP connections through a addtional IP address rather than your primary

View all images
So you are in directory with loads of pictures laying around and you need to quickly scan through them all

Renaming a file without overwiting an existing file name
Sometimes in a hurry you may move or copy a file using an already existent file name. If you aliased the cp and mv command with the -i option you are prompted for a confirmation before overwriting but if your aliases aren't there you will loose the target file! The -b option will force the mv command to check if the destination file already exists and if it is already there a backup copy with an ending ~ is created.

Extract the MBR ID of a device
Useful when you want to know the mbrid of a device - for the purpose of making it bootable. Certain hybridiso distros, for eg the OpenSUSE live ISO uses the mbrid to find the live media. Use this command to find out the mbrid of your USB drive and then edit the /grub/mbrid file to match it.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Find files that were modified by a given command
Traces the system calls of a program. See http://linuxhelp.blogspot.com/2006/05/strace-very-powerful-troubleshooting.html for more information.

Check wireless link quality with dialog box
The variable WIRELESSINTERFACE indicates your wireless interface

Quick screenshot
Requires ImageMagick. Takes a screenshot 5 seconds after it's run and saves it as desktop_screenshot.jpg Particularly handy when made into a menu option or button.


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: