All commands sorted by votes

8 min read Original article ↗

All commands (14,233)

  • Useful when you forget to use sudo for a command. "!!" grabs the last run command.

    This is sample output - yours may be different.

    · 2009-01-26 10:26:48 32

  • This is sample output - yours may be different.

    python -m SimpleHTTPServer

  • Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run: echo "no typozs" you can correct it with ^z

    This is sample output - yours may be different.

    root · 2009-01-26 13:25:37 9

  • Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever. Show Sample Output

    This is sample output - yours may be different.

    GNU nano 2.0.7         File: /tmp/bash-fc-30782221326                         
    
    # begin writing some exceedingly long and complex command in the editor...

    fool · 2009-03-11 09:26:05 15

  • When typing out long arguments, such as: cp file.txt /var/www/wp-content/uploads/2009/03/ You can put that argument on your command line by holding down the ALT key and pressing the period '.' or by pressing <ESC> then the period '.'. For example: cd 'ALT+.' would put '/var/www/wp-content/uploads/2009/03/ as my argument. Keeping pressing 'ALT+.' to cycle through arguments of your commands starting from most recent to oldest. This can save a ton of typing.

    This is sample output - yours may be different.

  • Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting. Show Sample Output

    This is sample output - yours may be different.

    /dev/sda1   on  /                         type  ext3        (rw,relatime,errors=remount-ro)
    tmpfs       on  /lib/init/rw              type  tmpfs       (rw,nosuid,mode=0755)
    /proc       on  /proc                     type  proc        (rw,noexec,nosuid,nodev)
    sysfs       on  /sys                      type  sysfs       (rw,noexec,nosuid,nodev)
    varrun      on  /var/run                  type  tmpfs       (rw,nosuid,mode=0755)
    varlock     on  /var/lock                 type  tmpfs       (rw,noexec,nosuid,nodev,mode=1777)
    udev        on  /dev                      type  tmpfs       (rw,mode=0755)
    tmpfs       on  /dev/shm                  type  tmpfs       (rw,nosuid,nodev)
    devpts      on  /dev/pts                  type  devpts      (rw,noexec,nosuid,gid=5,mode=620)
    fusectl     on  /sys/fs/fuse/connections  type  fusectl     (rw)
    securityfs  on  /sys/kernel/security      type  securityfs  (rw)
  • curl ifconfig.me/ip -> IP Adress curl ifconfig.me/host -> Remote Host curl ifconfig.me/ua ->User Agent curl ifconfig.me/port -> Port thonks to http://ifconfig.me/

    This is sample output - yours may be different.

    aajjk · 2010-04-21 13:10:33 6

  • This is an alternative to cron which allows a one-off task to be scheduled for a certain time.

    This is sample output - yours may be different.

    echo "ls -l" | at midnight

    root · 2009-01-25 21:07:42 13

  • This is sample output - yours may be different.

  • This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.

    This is sample output - yours may be different.

    dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

  • Example : vim /etc/fstab ## damn <ctrl+u> sudo <ctrl+y> ## like a boss. Example 2 : sudo vim /root/bin/ ##uh... autocomplete doesn't work... <ctrl+u> sudo ls /root/bin ##ah! that's the name of the file! <ctrl+y> sudo vim /root/bin/ ##resume here! Thanks readline!

    This is sample output - yours may be different.

  • This is sample output - yours may be different.

    sshfs name@server:/path/to/folder /path/to/mount/point

    ihasn · 2009-02-05 20:17:41 6

  • Query Wikipedia by issuing a DNS query for a TXT record. The TXT record will also include a short URL to the complete corresponding Wikipedia entry.You can also write a little shell script like: $ cat wikisole.sh #!/bin/sh dig +short txt ${1}.wp.dg.cx and run it like ./wikisole.sh unix were your first option ($1) will be used as search term. Show Sample Output

    This is sample output - yours may be different.

    $ dig +short txt unix.wp.dg.cx
    "Unix (officially trademarked as UNIX, sometimes also written as Unix with small caps) is a computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe O" "ssanna. Today's Unix systems are split into various branches, developed over time by AT&T as well as various commercial... http://a.vu/w:Unix"

    dig +short txt <keyword>.wp.dg.cx

  • Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast. Be aware that anything saved in this partition will be gone after your computer is turned off.

    This is sample output - yours may be different.

    mount -t tmpfs tmpfs /mnt -o size=1024m

  • -p parameter tells wget to include all files, including images. -e robots=off you don't want wget to obey by the robots.txt file -U mozilla as your browsers identity. --random-wait to let wget chose a random number of seconds to wait, avoid get into black list. Other Useful wget Parameters: --limit-rate=20k limits the rate at which it downloads files. -b continues wget after logging out. -o $HOME/wget_log.txt logs the output

    This is sample output - yours may be different.

    wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com

  • This is sample output - yours may be different.

  • Useful for checking if there are differences between local and remote files.

    This is sample output - yours may be different.

    ssh user@host cat /path/to/remotefile | diff /path/to/localfile -

    root · 2009-02-04 11:33:19 1

  • time read -sn1 (s:silent, n:number of characters. Press any character to stop)

    This is sample output - yours may be different.

    time read (ctrl-d to stop)

  • Unreachable_host is unavailable from local network, but it's available from reachable_host's network. This command creates a connection to unreachable_host through "hidden" connection to reachable_host.

    This is sample output - yours may be different.

    ssh -t reachable_host ssh unreachable_host

    patko · 2009-03-03 23:21:36 2

  • This is sample output - yours may be different.

    curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml

  • A nice way to use the console in full screen without forget the current time. you can too add other infos like cpu and mem use. Show Sample Output

    This is sample output - yours may be different.

                                                             Qui Fev 17 08:27:29 BRST 2011
     #
    

    while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &

  • This is sample output - yours may be different.

    prayer · 2009-04-10 12:22:34 7

  • Using +F will put less in follow mode. This works similar to 'tail -f'. To stop scrolling, use the interrupt. Then you'll get the normal benefits of less (scroll, etc.). Pressing SHIFT-F will resume the 'tailling'.

    This is sample output - yours may be different.

    adamm9 · 2009-02-19 14:33:46 5

  • This will output the characters at 10 per second.

    This is sample output - yours may be different.

    echo "You can simulate on-screen typing just like in the movies" | pv -qL 10

  • This is sample output - yours may be different.

  •  1 2 3 >  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

You can compare directories on two different remote hosts as well: $ diff -y

Compress information DBs of firefox to speed up the launch of browser.

This was gotten from http://www.veen.com/jeff/archives/000573.html. The line will grab all the mp3 files on the urls listed in text file sourceurls.txt (one url per line) . A much more complete breakdown of the line can be found at the web site mentioned above.

Sets the @ A record for your domain hosted by namecheap to your current internet-facing IP address, logs success or failure with syslog, and logs the data returned to /root/dnsupdate. Change the XXX's as appropriate. More info at: http://www.namecheap.com/support/knowledgebase/article.aspx/29/

Copy this function to command line, press 'Enter' 'f'' 'Enter' to execute (sentence on the left written only for newbies). Hint 'e|x|v|1..9' in front of displayed last modified file name means: "Press 'e' for edit,'x' for execute,'v' for view or a digit-key '1..9' to touch one file from the recent files list to be last modified" and suggested (hidden files are listed too, else remove 'a' from 'ls -tarp' statement if not intended). If you find this function useful you can then rename it if needed and append or include into your ~/.bashrc config script. With the command $ . ~/.bashrc the function then can be made immediately available. In the body of the function modifications can be made, i.e. replaced joe editor command or added new option into case statement, for example 'o) exo-open $h;;' command for opening file with default application - or something else (here could not be added since the function would exceed 255 chars). To cancel execution of function started is no need to press Ctrl-C - if the mind changed and want to leave simple Enter-press is enough. Once defined, this function can with $ typeset -f f command be displayed in easy readable form


Stay in the loop…