All commands (14,187)

  • I must monitorize a couple of ftp servers every morning WITHOUT a port-scanner Instead of ftp'ing on 100 ftp servers manually to test their status I use this loop. It might be adaptable to other services, however it may require a 'logout' string instead of 'quit'. The file ftps.txt contains the full list of ftp servers to monitorize.


    1
    for host in $(cat ftps.txt) ; do if echo -en "o $host 21\nquit\n" |telnet 2>/dev/null |grep -v 'Connected to' >/dev/null; then echo -en "FTP $host KO\n"; fi done
    vlan7 · 2010-01-26 15:34:18 3
  • Recursive grep through directory for file.


    -5
    find directory/ |xargs grep -i "phrase"
    tuxtutorials · 2010-01-26 14:56:56 3
  • no loop, only one call of grep, scrollable ("less is more", more or less...)


    12
    ls /usr/bin | xargs whatis | grep -v nothing | less
    michelsberg · 2010-01-26 12:59:47 31
  • Useful for Maven multimodule projects, where you want to extract all packaged jar files.


    -3
    find . -iname "*.jar" -exec cp '{}' /tmp/ \;
    unixmonkey6754 · 2010-01-26 12:19:15 3
  • This command has been used to overwrite corrupted "entries" files of a corrupted subversion working copy. Note the --files-from input format.


    3
    rsync -vd --files-from=<(find . -name entries -print ) . ../target_directory
    samyboy · 2010-01-26 09:41:12 6
  • This command toggles the touchpad on and off, when it's on, the right side scroll strip (annoying) and the tap-clicking are disabled, you can change this by changing occurances of 2 in the command to 0. this whole command can then be given a keyboard shortcut so that the touchpad is disableable without using a special fn key (which linux doesn't recognize on some computers) or a seperate button.


    -3
    if [ $(synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then synclient TouchpadOff=1; elif [ $(synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then synclient TouchpadOff=2; else synclient TouchpadOff=2; fi
    GinoMan2440 · 2010-01-26 07:52:55 5

  • 1
    find . -maxdepth 1 -type d -exec 'mv "{}" "{}-old" && svnadmin create "{}" && svnadmin recover "{}-old" && svnadmin dump "{}-old" | svnadmin load "{}" && rm -rf "{}-old"' \;
    raspi · 2010-01-26 07:06:43 3

  • 7
    for i in $(ls /usr/bin); do whatis $i | grep -v nothing; done | more
    Abiden · 2010-01-26 06:15:54 6

  • -2
    7za x \*.zip
    andrew112358 · 2010-01-25 21:50:15 2
  • Traditionally we rewind a tape using this syntaxis: mt -f /dev/rmt/0cbn rewind Redirecting the dispositive to nothing as shown above is faster. Less typing is always better.


    2
    < /dev/rmt/0cbn
    vlan7 · 2010-01-25 20:32:38 3

  • -1
    find . -maxdepth 1 -type f| xargs sha1sum | sed 's/^\(\w*\)\s*\(.*\)/\2 \1/' | while read LINE; do mv $LINE; done
    foremire · 2010-01-25 20:21:01 11
  • for example if you did a: ls -la /bin/ls then ls !$ is equivalent to doing a ls /bin/ls


    9
    !$
    ringlerun · 2010-01-24 17:59:52 22
  • running top command in batch mode. it is usefull if you want to redirect the output in a file. Show Sample Output


    2
    top -b -n 1
    r00t4u · 2010-01-24 16:17:30 5

  • 0
    dpkg -l | grep ^rc | awk '{print $2}' | sudo xargs dpkg -P
    kayowas · 2010-01-24 14:23:37 4
  • Use find's built-in ability to call programs. Alternatively, find -maxdepth 1 -type f -name "*.7z" -print0 | xargx -0 -n 1 7zr e would work, too.


    -1
    find -maxdepth 1 -type f -name "*.7z" -exec 7zr e '{}' ';'
    minnmass · 2010-01-23 19:50:10 4

  • 0
    find . -type f -exec stat \{\} \; | grep Modify: | awk '{a[$2]++}END{for(i in a){print i " : " a[i] }}' | sort
    pepin · 2010-01-23 07:55:16 6
  • Restores the keyboard so your partner who expects the keys to correspond to what they're labelled can type (in qwerty).


    -2
    setxkbmap us
    keturn · 2010-01-23 04:08:46 4
  • What to type to fix the keyboard when it's all qwerty and/or the modifier key to the left of the 'a' is doing something unexpected. In addition, I've also been known to use the altwin:meta_win and compose:ralt flags.


    0
    setxkbmap dvorak '' ctrl:nocaps
    keturn · 2010-01-23 04:04:59 3
  • A command to post a message to Twitter that includes your geo-location and a short URL. The link shortening service is provide by TinyURL, the geo-location service is provided by HostIP and the IP address lookup service is provided by AppSpot. This is an upgrade of an of one of my previous contributions: http://tinyurl.com/yd2xtzv.


    4
    curl --user "USERNAME:PASSWORD" -d status="MESSAGE_GOES_HERE $(curl -s tinyurl.com/api-create.php?url=URL_GOES_HERE) $(curl -s api.hostip.info/get_html.php?ip=$(curl ip.appspot.com))" -d source="cURL" twitter.com/statuses/update.json -o /dev/null
    o0110o · 2010-01-23 02:21:57 10

  • -7
    scp /home/svnlabs.txt root@92.178.0.56:/home/
    bakhru · 2010-01-22 21:19:37 5

  • 10
    nmap -T4 -sP 192.168.2.0/24 && egrep "00:00:00:00:00:00" /proc/net/arp
    wincus · 2010-01-22 20:36:43 7

  • 3
    for file in *.7z; do 7zr e "$file"; done
    jmcantrell · 2010-01-22 18:42:20 11
  • Connect EC2 server with public keys "/root/.ec2/id_rsa-gsg-keypair" or "/root/.ec2/keypair.pem"


    -2
    rsync -avvvz -e "ssh -i /root/.ec2/id_rsa-gsg-keypair" --archive --progress /root/.ec2/id_rsa-gsg-keypair root@ec2-75-101-212-113.compute-1.amazonaws.com:/root
    lalit241 · 2010-01-22 17:21:58 3
  • Upload file to remote server using SCP


    -9
    scp -P 22 /home/svnlabs.txt root@92.178.0.56:/home/svnlabs.txt
    lalit241 · 2010-01-22 17:21:07 3
  • Upload file to remote server using SCP


    -6
    scp -P 22 /home/svnlabs.txt root@92.178.0.56:/home/svnlabs.txt
    svnlabs · 2010-01-22 16:55:25 4
  • ‹ First  < 406 407 408 409 410 >  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

Install pip with Proxy
Installs pip packages defining a proxy

Kill any lingering ssh processes

See system users

Takes all file except file between !()
Go to tmp : cd /tmp; mkdir retmp; cd retmp Create 10 files : for i in {1..10}; do touch test$i; done Remove all files except test10 : rm !(test10)

Ultimate current directory usage command
Based on the MrMerry one, just add some visuals to differentiate files and directories

Rot13 using the tr command
rot13 maps a..mn..z (A..MN..Z) to n..za..m (n..za..m) and so does this alias.

List recorded formular fields of Firefox
When you fill a formular with Firefox, you see things you entered in previous formulars with same field names. This command list everything Firefox has registered. Using a "delete from", you can remove anoying Google queries, for example ;-)

tail: watch a filelog
-f file(s) to be monitorized -n number of last line to be printed on the screen in this example, the content of two files are displayed

ssh autocomplete based on ~/.ssh/config
I use this in my bashrc to expand hosts defined in ~/.ssh/config: function _ssh_completion() { perl -ne 'print "$1 " if /^Host (.+)$/' ~/.ssh/config } complete -W "$(_ssh_completion)" ssh Here's a great article on how to setup your own ~/.ssh/config: http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html

Make vim open in tabs by default (save to .profile)
I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.


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: