Commands by warkruid (2)

  • The glob pattern * expands to all files, no need for the 'ls' command. The quotes around "$i" make sure filenames with spaces in them are handled correctly. mplayer determines if it is a media file and plays it, or gives errors and the loop asks if this file has to be removed. Show Sample Output


    -1
    for i in *; do mplayer "$i" && rm -i "$i"; done
    warkruid · 2013-12-26 17:13:23 59
  • I sometimes have use an usb stick to distribute files to several standalone "internet" pc's. I don't trust these machines period. The sticks I have do not have a write protection. So as a added security measure I fill the unused space on the (small) usb stick with a file with randomly generated bits. Any malware that tries to write to this stick will find no space on it. Tested on slackware 14 Note: you may need root access to write to the device. This depends on your mount options. Show Sample Output


    0
    set +e +u; dd if=/dev/urandom of="/media/usb1/$$";sync;sync
    warkruid · 2013-12-22 14:35:53 22

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

Synchronize both your system clock and hardware clock and calculate/adjust time drift
Do not run this command if you already have ntpd running! This needs to run as root, for example with sudo: $ sudo ntpdate pool.ntp.org && sudo hwclock --systohc && sudo hwclock --adjust This command will fetch accurate time from NTP servers and synchronize your system clock, then it will use the system clock to synchronize your hardware clock, and will calculate the time drift.

sort lines by length

Exit mc with 2 keystrokes
For those who like to hit instead of typing "exit" to leave the shell and find it annoying that it doesn't work in Midnight Commander, just press to switch to the subshell and now you can leave with

list block devices
Shows all block devices in a tree with descruptions of what they are.

Batch convert PNG to JPEG
Convert all PNG images in directory to JPEG using ImageMagick, and delete the old PNG images.

dd with progress bar and statistics to gzipped image

Install pip with Proxy
Installs pip packages defining a proxy

Use mtr to create a text file report
The report mode of mtr produces a text formated result of the mtr run using the number of ping cycles stated by the command. This text file could then be attached to an email with ease. I use this also without the ">" portion when writing email from within mutt using VI from the command mode with ":r !mtr --report --report-cycles 10 www.google.com" to actually input the same output in the body of an email.

Benchmark SQL Query
Benchmark a SQL query against MySQL Server. The example runs the query 10 times, and you get the average runtime in the output. To ensure that the query does not get cached, use `RESET QUERY CACHE;` on top in the query file.

Decrypt exported android wallet keys for import into desktop client (LTC,FTC,BTC)


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: