All commands (14,187)


  • 55
    vim scp://username@host//path/to/somefile
    adminzim · 2009-02-18 15:09:53 16
  • It deletes all removed files, updates what was modified, and adds new files.


    54
    git add -u
    donnoman · 2009-09-16 00:13:14 21
  • Find random strings within /dev/urandom. Using grep filter to just Alphanumeric characters, and then print the first 30 and remove all the line feeds. Show Sample Output


    54
    strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo
    jbcurtis · 2009-02-16 00:39:28 26
  • Written for linux, the real example is how to produce ascii text graphs based on a numeric value (anything where uniq -c is useful is a good candidate). Show Sample Output


    53
    netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }'
    knassery · 2009-04-27 22:02:19 24
  • You're running a script, command, whatever.. You don't expect it to take long, now 5pm has rolled around and you're ready to go home... Wait, it's still running... You forgot to nohup it before running it... Suspend it, send it to the background, then disown it... The ouput wont go anywhere, but at least the command will still run... Show Sample Output


    53
    ^Z $bg $disown
    fall0ut · 2009-03-17 21:52:52 26
  • for one line per process: ss -p | cat for established sockets only: ss -p | grep STA for just process names: ss -p | cut -f2 -sd\" or ss -p | grep STA | cut -f2 -d\"


    52
    ss -p
    Escher · 2009-09-19 21:55:01 13
  • Grab X11 input and create an MPEG at 25 fps with the resolution 800x600


    51
    ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
    dcabanis · 2009-06-05 21:11:17 15
  • Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. Source: http://www.catonmat.net/blog/unix-utilities-pipe-viewer/ Show Sample Output


    51
    pv access.log | gzip > access.log.gz
    p3k · 2009-02-06 08:50:40 167

  • 51
    du -s * | sort -n | tail
    bambambazooka · 2009-02-05 11:18:43 33
  • Same as http://www.commandlinefu.com/commands/view/5876, but for bash. This will show a numerical value for each of the 256 colors in bash. Everything in the command is a bash builtin, so it should run on any platform where bash is installed. Prints one color per line. If someone is interested in formatting the output, paste the alternative.


    49
    for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done
    scribe · 2010-06-19 02:14:42 13

  • 49
    find . -type d -empty -delete
    jmcantrell · 2010-03-23 15:21:33 18
  • This is how I typically grep. -R recurse into subdirectories, -n show line numbers of matches, -i ignore case, -s suppress "doesn't exist" and "can't read" messages, -I ignore binary files (technically, process them as having no matches, important for showing inverted results with -v) I have grep aliased to "grep --color=auto" as well, but that's a matter of formatting not function.


    49
    grep -RnisI <pattern> *
    birnam · 2009-09-22 15:09:43 29
  • This example, for example, produces the output, "Fri Feb 13 15:26:30 EST 2009"


    49
    date -d@1234567890
    kFiddle · 2009-04-11 22:26:41 20
  • Watch is a very useful command for periodically running another command - in this using mysqladmin to display the processlist. This is useful for monitoring which queries are causing your server to clog up. More info here: http://codeinthehole.com/archives/2-Monitoring-MySQL-processes.html


    49
    watch -n 1 mysqladmin --user=<user> --password=<password> processlist
    root · 2009-02-16 11:21:16 132
  • Change Seville for your prefered city. Show Sample Output


    48
    curl wttr.in/seville
    nordri · 2016-08-28 09:43:38 32
  • Usage: cmdfu hello world Show Sample Output


    48
    cmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext"; }
    knoopx · 2009-08-19 02:18:24 72
  • This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit. A couple of variants: A little bit bigger text: watch -t -n1 "date +%T|figlet -f big" You can try other figlet fonts, too. Big sideways characters: watch -n 1 -t '/usr/games/banner -w 30 $(date +%M:%S)' This requires a particular version of banner and a 40-line terminal or you can adjust the width ("30" here). Show Sample Output


    48
    watch -t -n1 "date +%T|figlet"
    dennisw · 2009-06-21 01:02:37 35
  • Read 32GB zero's and throw them away. How fast is your system? Show Sample Output


    48
    dd if=/dev/zero of=/dev/null bs=1M count=32768
    jacquesloonen · 2009-02-16 12:22:18 178
  • Uses shell expansion to create a back-up called file.txt.bak


    48
    cp file.txt{,.bak}
    root · 2009-01-26 12:11:29 90
  • just make some data scrolling off the terminal. wow.


    47
    cat /dev/urandom | hexdump -C | grep "ca fe"
    BOYPT · 2010-09-27 08:20:44 20
  • Remove security from PDF document using this very simple command on Linux and OSX. You need ghostscript for this baby to work.


    47
    gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c .setpdfwrite -f INPUT.pdf
    deijmaster · 2009-12-14 21:30:22 26
  • Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages. For some reason sed gets stuck on OS X, so here's a Perl version for the Mac: curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/' If you want to see the name of the last person, who added a message to the conversation, change the greediness of the operators like this: curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/$2 - $1/' Show Sample Output


    47
    curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
    postrational · 2009-09-07 21:56:40 43
  • Also works with: chgrp --reference file1 file2 chown --reference file1 file2


    46
    chmod --reference file1 file2
    rpavlick · 2010-03-31 12:05:48 12
  • 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"


    46
    notify-send ["<title>"] "<body>"
    o6291408 · 2009-04-29 10:05:20 20
  • Create a persistent SSH connection to the host in the background. Combine this with settings in your ~/.ssh/config: Host host ControlPath ~/.ssh/master-%r@%h:%p ControlMaster no All the SSH connections to the machine will then go through the persisten SSH socket. This is very useful if you are using SSH to synchronize files (using rsync/sftp/cvs/svn) on a regular basis because it won't create a new socket each time to open an ssh connection.


    46
    ssh -MNf <user>@<host>
    raphink · 2009-02-26 14:11:19 18
  • ‹ First  < 2 3 4 5 6 >  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

tail -f a log file over ssh into growl

dump database from postgresql to a file

Lists all usernames in alphabetical order

Keep a copy of the raw Youtube FLV,MP4,etc stored in /tmp/
Certain Flash video players (e.g. Youtube) write their video streams to disk in /tmp/ , but the files are unlinked. i.e. the player creates the file and then immediately deletes the filename (unlinking files in this way makes it hard to find them, and/or ensures their cleanup if the browser or plugin should crash etc.) But as long as the flash plugin's process runs, a file descriptor remains in its /proc/ hierarchy, from which we (and the player) still have access to the file. The method above worked nicely for me when I had 50 tabs open with Youtube videos and didn't want to have to re-download them all with some tool.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Change the homepage of Firefox
Pros: Works in all Windows computers, most updated and compatible command. Cons: 3 liner Replace fcisolutions.com with your site name.

Copy without overwriting

Fast, built-in pipe-based data sink
This is shorter and actually much faster than >/dev/null (see sample output for timings) Plus, it looks like a disappointed face emoticon.

bash screensaver off

return the latest kernel version from a Satellite / Spacewalk server software channel


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: