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

dump database from postgresql to a file

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.

Found how how much memory in kB $PID is occupying in Linux
The "proportional set size" is probably the closest representation of how much active memory a process is using in the Linux virtual memory stack. This number should also closely represent the %mem found in ps(1), htop(1), and other utilities.

Copy without overwriting

put current directory in LAN quickly

bash screensaver off

Performance tip: compress /usr/
Periodically run the one-liner above if/when there are significant changes to the files in /usr/ = Before rebooting, add following to /etc/fstab : = $ /squashed/usr/usr.sfs /squashed/usr/ro squashfs loop,ro 0 0 $ usr /usr aufs udba=reval,br:/squashed/usr/rw:/squashed/usr/ro 0 0 No need to delete original /usr/ ! (unless you don't care about recovery). Also AuFS does not work with XFS

Remount root in read-write mode.
Saved my day, when my harddrive got stuck in read-only mode.


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: