All commands (12,655)

  • If you want to be notified when a long-running command is finished, but you have already started it: CTRL+Z fg; echo "finished" | sendmail me@example.com I use a script to post a tweet, which sends me a txt: fg; echo "finished" | tweet


    28
    <ctrl+z> fg; notify_me
    recursiverse · 2010-05-20 16:16:43 4
  • While editing a source file in vim, or using vimdiff to compare two or more files, the ':TOhtml' command can be used to export each buffer as an html file, including syntax highlighting and vimdiff colorization. If you are in insert mode in vim, you will have to type :TOhtml This will open a new buffer filled with html, which you can then save.


    28
    :TOhtml
    bartonski · 2010-03-26 15:01:34 2

  • 28
    arecord -f dat | ssh -C user@host aplay -f dat
    drinkcat · 2010-02-18 06:00:33 2
  • After the command is done, open the html file in a browser


    28
    lshw -html > hardware.html
    flart · 2009-06-04 07:14:03 6
  • Creates a full snapshot of your current vim session, including tabs, open buffers, cursor positions, everything. Can be resumed with vim -S . Useful for those times when you HAVE to close vim, but you don't want to lose all your hard-opened buffers and windows. The ! will cause vim to overwrite the file if it already exists. It is not necessary, but useful if you frequently save to the same file (like session.vim or something).


    28
    :mksession! <filename>
    neutral · 2009-02-26 05:03:07 3
  • (relies on 'imagemagick') This command will convert all .pdf files in a directory into a 800px (wide or height, whichever is smaller) image (with the aspect ratio kept) .jpg. If the file is named 'example1.pdf' it will be named 'example1.jpg' when it is complete. This is a VERY worthwhile command! People pay hundreds of dollars for this in the Windows world. My .jpg files average between 150kB to 300kB, but your's may differ. Show Sample Output


    28
    for file in `ls *.pdf`; do convert -verbose -colorspace RGB -resize 800 -interlace none -density 300 -quality 80 $file `echo $file | sed 's/\.pdf$/\.jpg/'`; done
    brettalton · 2009-02-15 23:27:43 4
  • the -x option is for binding to a shell command


    27
    bind -x '"\C-l":ls -l'
    roalddevries · 2010-12-25 22:55:33 1

  • 27
    find / -type f -size +500M
    flxndn · 2010-11-09 10:09:33 0
  • This command is more portable than it's cousin netstat. It works well on all the BSDs, GNU/Linux, AIX and Mac OS X. You won't find lsof by default on Solaris or HPUX by default, but packages exist around the web for installation, if needed, and the command works as shown. This is the most portable command I can find that lists listening ports and their associated pid. Show Sample Output


    27
    lsof -Pan -i tcp -i udp
    atoponce · 2010-06-07 15:22:44 0
  • PDF files are simultaneously wonderful and heinous. They are wonderful in being ubiquitous and mostly being cross platform. They are heinous in being very difficult to work with from the command line, search, grep, use only the text inside the PDF, or use outside of proprietary products. xpdf is a wonderful set of PDF tools. It is on many linux distros and can be installed on OS X. While primarily an open PDF viewer for X, xpdf has the tool "pdftotext" that can extract formated or unformatted text from inside a PDF that has text. This text stream can then be further processed by grep or other tool. The '-' after the file name directs output to stdout rather than to a text file the same name as the PDF. Make sure you use version 3.02 of pdftotext or later; earlier versions clipped lines. The lines extracted from a PDF without the "-layout" option are very long. More paragraphs. Use just to test that a pattern exists in the file. With "-layout" the output resembles the lines, but it is not perfect. xpdf is available open source at http://www.foolabs.com/xpdf/


    27
    pdftotext [file] - | grep 'YourPattern'
    drewk · 2010-02-14 21:42:35 0
  • connects to host via ssh and displays the live transfer speed, directing all transferred data to /dev/null needs pv installed Debian: 'apt-get install pv' Fedora: 'yum install pv' (may need the 'extras' repository enabled) Show Sample Output


    27
    yes | pv | ssh $host "cat > /dev/null"
    opertinicy · 2009-12-27 21:34:23 10

  • 27
    date -d @1234567890
    elzapp · 2009-08-25 11:18:04 2

  • 27
    sudo strings /dev/mem
    point_to_null · 2009-08-09 02:07:26 1
  • Generated XML files often are poorly formatted. Use this command to properly indent and normalize the file in-place.


    27
    tidy -xml -i -m [file]
    scw · 2009-02-05 21:22:33 2
  • (also works on Ubuntu) Copies the 'install,' 'hold,' 'deinstall' and 'purge' states of packages on the remote machine to be matched on the local machine. Note: if packages were installed on the local machine that were never installed on the remote machine, they will not be deinstalled by this operation.


    26
    ssh remotehost 'dpkg --get-selections' | dpkg --set-selections && dselect install
    Mozai · 2011-05-12 17:26:43 0

  • 26
    grep -Fx -f file1 file2
    zarathud · 2010-05-28 14:50:14 2
  • Run the alias command, then issue ps aux | head 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 deafault of 12 (-2 = 10). The default for HEAD is to output the first 10 lines, this alias changes the default to output the first x lines instead, where x is the number of lines currently displayed on your terminal - 2. The -2 is there so that the top line displayed is the command you ran that used HEAD, 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-unix/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. Show Sample Output


    26
    alias head='head -n $((${LINES:-`tput lines 2>/dev/null||echo -n 12`} - 2))'
    AskApache · 2010-04-08 22:37:06 7
  • That command installs "most" and make this command as the default man reader. The "most" works like "less" (the current man reader), but it render colors for manpages and may do more things. Read "man most". You can see a preview here: http://www.dicas-l.com.br/dicas-l/20090718.php


    26
    apt-get install most && update-alternatives --set pager /usr/bin/most
    aurium · 2010-01-04 14:13:55 4

  • 26
    nl
    solarislackware · 2009-12-08 19:30:32 3
  • You got some results in two variables within your shell script and would like to find the differences? Changes in process lists, reworked file contents, ... . No need to write to temporary files. You can use all the diff parameters you'll need. Maybe anything like $ grep "^>" is helpful afterwards.


    26
    diff <(echo "$a") <(echo "$b")
    olorin · 2009-07-15 07:26:23 2
  • Continue with: killall -CONT -m firefox Suspends all Firefox Threads. Results in Zero CPU load. Useful when having 100+ Tabs open and you temporarily need the power elsewhere. Be careful - might produce RACE CONDITIONS or LOCKUPS in other processes or FF itself. matching is case sensitive.


    26
    killall -STOP -m firefox
    Schneckentreiber · 2009-05-18 20:02:44 6
  • This command will tell lynx to read keystrokes from the specified file - which can be used in a cronjob to auto-login on websites that give you points for logging in once a day *cough cough* (which is why I used -accept_all_cookies). For creating your keystroke file, use: lynx -cmd_log yourfile


    26
    lynx -accept_all_cookies -cmd_script=/your/keystroke-file
    Alanceil · 2009-03-17 00:38:36 0
  • Use this command to find out a list of committers sorted by the frequency of commits. Show Sample Output


    26
    svn log -q|grep "|"|awk "{print \$3}"|sort|uniq -c|sort -nr
    psytek · 2009-02-17 21:37:03 1
  • Sends SIGINFO to the process. This is a BSD feature OS X inherited. You must have the terminal window executing dd selected when entering CTRL + T for this to work. Show Sample Output


    25
    CTRL + T
    unixmonkey44467 · 2012-12-19 02:21:41 1
  • This is a very simple way to input a large number of seconds and get a more useful value in minutes and seconds. Avoids useless use of echo. Show Sample Output


    25
    bc <<< 'obase=60;299'
    mathias · 2011-10-21 13:15:17 1
  • ‹ First  < 6 7 8 9 10 >  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



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: