All commands (14,187)

  • "-o loop" lets you use a file as a block device


    46
    mount /path/to/file.iso /mnt/cdrom -oloop
    nerd65536 · 2009-02-05 17:28:06 33
  • In this case it's better do to use the dedicated tool


    45
    ssh-keygen -R <the_offending_host>
    bunam · 2010-07-11 19:37:24 16
  • 'dpkg -S' just matches the string you supply it, so just using 'ls' as an argument matches any file from any package that has 'ls' anywhere in the filename. So usually it's a good idea to use an absolute path. You can see in the second example that 12 thousand files that are known to dpkg match the bare string 'ls'. Show Sample Output


    45
    dpkg -S /usr/bin/ls
    bwoodacre · 2009-04-18 18:18:23 25
  • Good for one off jobs that you want to run at a quiet time. The default threshold is a load average of 0.8 but this can be set using atrun. Show Sample Output


    45
    echo "rm -rf /unwanted-but-large/folder" | batch
    root · 2009-02-04 19:07:52 45
  • You can get one specific line during any procedure. Very interesting to be used when you know what line you want. Show Sample Output


    44
    sed -n 5p <file>
    Waldirio · 2009-10-15 11:00:48 140
  • I did not know this, i'd like to share...


    44
    open .
    vigo · 2009-06-10 10:55:20 25
  • This command shows the various shortcuts that can be use in bash, including Ctrl+L, Ctrl+R, etc... You can translate "\C-y" to Ctrl+y, for example. Show Sample Output


    43
    bind -P
    ricardofunke · 2012-05-28 18:51:59 16

  • 43
    timeout 5s COMMAND
    kev · 2011-11-19 06:14:33 12
  • Directly attach a remote screen session (saves a useless parent bash process)


    43
    ssh -t remote_host screen -r
    recursiverse · 2009-07-23 06:15:04 45
  • If you want a visual representation of the parent/child relationships between processes, this is one easy way to do it. It's useful in debugging collections of shell scripts, because it provides something like a call traceback. When a shell script breaks, just remember "awwfux".


    43
    ps awwfux | less -S
    ToyKeeper · 2009-07-04 09:39:28 15
  • RTFMFTW.


    42
    rtfm() { help $@ || man $@ || $BROWSER "http://www.google.com/search?q=$@"; }
    hunterm · 2011-01-05 02:53:38 323
  • This command takes a snapshot of the open files for a PID 1234 then waits 10 seconds and takes another snapshot of the same PID, it then displays the difference between each snapshot to give you an insight into what the application is doing.


    42
    diff <(lsof -p 1234) <(sleep 10; lsof -p 1234)
    zlemini · 2010-03-15 22:55:32 13
  • run 'nc yourip 5000', 'nc yourip 5001' or 'nc yourip 5002' elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.


    41
    script -qf | tee >(nc -kl 5000) >(nc -kl 5001) >(nc -kl 5002)
    clvv · 2010-10-11 07:55:30 20
  • Short command, easy to remember


    41
    curl ifconfig.me
    CodSpirit · 2010-08-01 13:56:01 12

  • 41
    tar -tf <file.tar.gz> | xargs rm -r
    prayer · 2009-07-06 22:23:11 20
  • Sometimes you need to use a port that is already opened by some program , and you don't know who to "kill" for it to release - so, now you do ! Show Sample Output


    41
    lsof -i tcp:80
    ar_levi · 2009-04-16 14:51:53 25
  • Of course you need to be able to access host A for this ;-)


    40
    ssh -t hostA ssh hostB
    0x89 · 2009-08-27 21:35:19 19

  • 39
    until !!; do :; done
    unixmonkey21806 · 2013-05-14 18:08:54 69
  • Shorter, easier to remember version of cmd#7636 NTP is better, but there are situations where it can't be used. In those cases, you can do this to sync the local time to a server. Show Sample Output


    39
    date --set="$(ssh user@server date)"
    splante · 2011-08-30 20:03:06 62
  • In Python version 3, the module was merged into http.server. Gentlemen, change your aliases. Show Sample Output


    39
    python -m http.server
    Alanceil · 2010-12-17 12:52:45 44
  • -d: list directory entries instead of contents, and do not dereference symbolic links


    39
    ls -d */
    brianmuckian · 2009-10-08 22:07:22 28
  • Google just released a new commend line tool offering all sorts of new services from the commend line. One of them is uploading a youtube video but there are plenty more google services to interact with. Download it here: http://code.google.com/p/googlecl/ Manual: http://code.google.com/p/googlecl/wiki/Manual This specific command courtesy of lifehacker:http://lifehacker.com/5568817/ Though all can be found in manual page linked above. Show Sample Output


    38
    google docs edit --title "To-Do List" --editor vim
    spiffwalker · 2010-06-21 16:15:42 17
  • The empty file /forcefsck causes the file system check fsck to be run next time you boot up, after which it will be removed. This works too: sudo >/forcefsck


    38
    sudo touch /forcefsck
    johnraff · 2009-10-29 17:04:47 17
  • If you enable multiuser, then you can permit others to share your screen session. The following conditions apply: 1. screen must be suid root; 2. "multiuser on" must be configured in ~/.screenrc; 3. control the others user(s) access with "aclchg": # ----- from ~/.screenrc-users ----- aclchg someuser +rx "#?" #enable r/o access to "someuser" aclchg someuser -x "#,at,aclchg,acladd,acldel,quit" # don't allow these aclchg otheruser +rwx "#?" # enable r/w access to "otheruser" aclchg otheruser -x "#,at,aclchg,acladd,acldel,quit" # don't allow them to use these commands # ----- After doing this (once), you start your session with: $ screen Then, the other user can join your terminal session(s) with youruserid: $ screen -r youruserid/ Note: the trailing "/" is required. Multiple users can share the same screen simultaneously, each with independent access controlled precisely with "aclchg" in the ~/.screenrc file. I use the following setup: # ~/.screenrc-base # default screenrc on any host source $HOME/.screenrc-base source $HOME/.screenrc-$HOST source $HOME/.screenrc-users # ----- Then, the base configurations are in ~/.screenrc-base; the host-specific configurations are in ~/.screenrc-$HOST, and the user configurations are in ~/.screenrc-users. The host-specific .screenrc file might contain some host-specific screen commands; e.g.: # ~/.screen-myhost # ----- screen -t 'anywhere' /bin/tcsh screen -t 'anywhere1' /bin/tcsh # ---- The .screenrc-base contains: # ~/.screenrc-base ## I find typing ^a (Control-a) awkward. So I set the escape key to CTRL-j instead of a. escape ^Jj termcapinfo xterm* ti@:te@: autodetach on zombie kr verbose on multiuser on


    38
    % screen -r someuser/
    totoro · 2009-03-25 23:59:38 12
  • EDIT: command updated to support accented characters! Works in any of 58 google supported languages (some sound like crap, english is the best IMO). You get a mp3 file containing your query in spoken language. There is a limit of 100 characters for the "q" parameter, so be careful. The "tl" parameter contains target language.


    37
    wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world
    sairon · 2011-03-08 14:05:36 23
  • ‹ First  < 3 4 5 6 7 >  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

Top ten (or whatever) memory utilizing processes (with children aggregate) - Can be done without the multi-dimensional array

Show apps that use internet connection at the moment.
show only the name of the apps that are using internet

Find out how much ram memory has your video (graphic) card

External IP (raw data)

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Does a traceroute. Lookup and display the network or AS names and AS numbers.
From the man page. lft ? display the route packets take to a network host/socket using one of several layer-4 protocols and methods; optionally show heuristic network information in transitu -A Enable lookup and display of of AS (autonomous system) numbers (e.g., [1]). This option queries one of several whois servers (see options 'C' and 'r') in order to ascertain the origin ASN of the IP address in question. By default, LFT uses the pWhoIs service whose ASN data tends to be more accurate and more timely than using the RADB as it is derived from the Internet's global routing table. -N Enable lookup and display of network or AS names (e.g., [GNTY-NETBLK-4]). This option queries Prefix WhoIs, RIPE NCC, or the RADB (as requested). In the case of Prefix WhoIs or RADB, the network name is displayed. In the case of RIPE NCC, the AS name is displayed.

HTTP GET request on wireshark remotly

True Random Dice Roll

cycle through everything sox knows how to read, playing only the first three seconds
I wasted two hours reading the sox documentation and searching on the web for the format of some obscure fscking sound sample, and then finally came up with this. This plays only the first three seconds of your unknown formatted sound file using every one of sox's built-in filetypes. If you don't get an exact match, you may get close. . I could not fit every single type in and keep it under 127 characters, so you will have to replace "..." with the full list obtainable by `$ sox --help` (or try `Show sample output`) . note: /usr/bin/play should be linked to sox on most systems.

kill all foo process
Kill all processes with foo in them. Similar to pkill but more complete and also works when there is no pkill command. Works on almost every Linux/Unix platform I have tried.


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: