All commands (14,030)

  • In this case it's better do to use the dedicated tool

    ssh-keygen -R <the_offending_host>
    bunam · 2010-07-11 19:37:24 0
  • You can get one specific line during any procedure. Very interesting to be used when you know what line you want. Show Sample Output

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

    open .
    vigo · 2009-06-10 10:55:20 14
  • Create a persistent SSH connection to the host in the background. Combine this with settings in your ~/.ssh/config: Host host ControlPath ~/.ssh/master-%[email protected]%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.

    ssh -MNf <user>@<host>
    raphink · 2009-02-26 14:11:19 4
  • Also works with: chgrp --reference file1 file2 chown --reference file1 file2

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

    ps awwfux | less -S
    ToyKeeper · 2009-07-04 09:39:28 4
  • Uses shell expansion to create a back-up called file.txt.bak

    cp file.txt{,.bak}
    root · 2009-01-26 12:11:29 1
  • Change Seville for your prefered city. Show Sample Output

    nordri · 2016-08-28 09:43:38 9

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

    ssh -t remote_host screen -r
    recursiverse · 2009-07-23 06:15:04 7

  • 41
    tar -tf <file.tar.gz> | xargs rm -r
    prayer · 2009-07-06 22:23:11 3
  • 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

    echo "rm -rf /unwanted-but-large/folder" | batch
    root · 2009-02-04 19:07:52 3
  • 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

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

    rtfm() { help [email protected] || man [email protected] || $BROWSER "[email protected]"; }
    hunterm · 2011-01-05 02:53:38 2
  • 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.

    script -qf | tee >(nc -kl 5000) >(nc -kl 5001) >(nc -kl 5002)
    clvv · 2010-10-11 07:55:30 12
  • 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.

    diff <(lsof -p 1234) <(sleep 10; lsof -p 1234)
    zlemini · 2010-03-15 22:55:32 1
  • Of course you need to be able to access host A for this ;-)

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

  • 38
    until !!; do :; done
    unixmonkey21806 · 2013-05-14 18:08:54 3
  • Short command, easy to remember

    CodSpirit · 2010-08-01 13:56:01 0
  • 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: Manual: This specific command courtesy of lifehacker: Though all can be found in manual page linked above. Show Sample Output

    google docs edit --title "To-Do List" --editor vim
    spiffwalker · 2010-06-21 16:15:42 3
  • 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

    sudo touch /forcefsck
    johnraff · 2009-10-29 17:04:47 6
  • -d: list directory entries instead of contents, and do not dereference symbolic links

    ls -d */
    brianmuckian · 2009-10-08 22:07:22 2
  • 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

    lsof -i tcp:80
    ar_levi · 2009-04-16 14:51:53 7
  • 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* [email protected]:[email protected]: autodetach on zombie kr verbose on multiuser on

    % screen -r someuser/
    totoro · 2009-03-25 23:59:38 1
  • 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

    date --set="$(ssh [email protected] date)"
    splante · 2011-08-30 20:03:06 3
  • ‹ First  < 3 4 5 6 7 >  Last ›

What's this? 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

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" }

A function to find the newest file in a directory

Cleanup a (source) text file, removing trailing spaces/tabs and multiple consecutive blank lines
I used this command (in addition to a code formatting tool) to "cleanup" a bunch of PHP files

Calculate days on which Friday the 13th occurs (inspired from the work of the user justsomeguy)
Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale.

Show directories in the PATH, one per line
The output of "echo $PATH" is hard to read, this is much easier. The parentheses ensure that the change to the input field separator (IFS) only happens the the sub shell and not affecting the current shell.

Check a server is up. If it isn't mail me.
Alternative to the ping check if your firewall blocks ping. Uses curl to get the landing page silently, or fail with an error code. You can probably do this with wget as well.

Get a list of ssh servers on the local subnet
--open -sV is not needed if you are only looking for hosts with 22 open

locating packages held back, such as with "aptitude hold "
locating packages held back, such as with "aptitude hold "

Analyse writing style of writing style of a document
Style analyses the surface characteristics of the writing style of a document. It prints various readability grades, length of words, sentences and paragraphs. It can further locate sentences with certain characteristics. If no files are given, the document is read from standard input. style is part of "diction" package

Get each users commit amount

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.


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: