### Commands by mkc (9) the last day the last week the last month all time sorted by date votes

• This command is somewhat similar to 'nice', but constrains I/O usage rather than CPU usage. In particular, the '-c3' flag tells the OS to only allow the process to do I/O when nothing else is pending. This dramatically increases the responsiveness of the rest of the system if the process is doing heavy I/O. There's also a '-p' flag, to set the priority of an already-running process.

6
ionice -c3 find /
· 2009-02-19 17:23:12
• The Linux /dev/full file simulates a "disk full" condition, and can be used to verify how a program handles this situation. In particular, several programming language implementations do not print error diagnostics (nor exit with error status) when I/O errors like this occur, unless the programmer has taken additional steps. That is, simple code in these languages does not fail safely. In addition to Perl, C, C++, Tcl, and Lua (for some functions) also appear not to fail safely. Show Sample Output

8
perl -e 'print 1, 2, 3' > /dev/full
· 2009-02-19 17:08:13
• The backslash avoids any 'rm' alias that might be present and runs the 'rm' command in $PATH instead. In a misguided attempt to be more "friendly", some Linux distributions (or sites/etc.) alias 'rm' to 'rm -i'. Unfortunately, this trains users to expect that files won't actually be deleted until they okay it. This expectation will fail with catastrophic results when they use other distributions, move to other sites, etc., and doesn't really even work 100% even with the alias. It's too late to fix 'rm', but '\rm' should work everywhere (under bash). 3 \rm somefile · 2009-02-19 16:55:54 • This is the setup I'm using for my largest project. It gives 357 lines per page (per side), which makes it fairly easy to carry around a significant amount of code on a few sheets of paper. Try it. (I stick to the 80 column convention in my coding. For wider code, you'll have to adjust this.) 1 enscript -E -B -3 -r -s 0 --borders -fCourier4.8 --mark-wrapped-lines=arrow · 2009-02-09 06:23:38 • The date command does offset calculations nicely, handles concepts like "a month" as you'd expect, and is good for offsets of at least 100M years in either direction. Show Sample Output 3 date --date="1 fortnight ago" · 2009-02-06 20:57:59 • strace can be invaluable in trying to figure out what the heck some misbehaving program is doing. There are number of useful flags to limit and control its output, and to attach to already running programs. (See also 'ltrace'.) Show Sample Output 5 strace -f -s 512 -v ls -l · 2009-02-06 02:45:33 • This is priceless for discovering otherwise invisible characters in files. Like, for example, that stray Control-M at the end of the initial hash bang line in your script, which causes it to generate a mysterious error even though it looks fine. ('od' is the last word, of course, but for many purposes it's much harder to read.) 0 cat -A · 2009-02-06 02:37:51 • This is a quick and dirty way to generate a (non-floating-point) CPU-bound task to benchmark. Adjust "20" to higher or lower values, as needed. As a benchmark this is probably a little less bogus than bogomips, and it will run anywhere 'bc' does. Show Sample Output 2 echo '2^2^20' | time bc > /dev/null · 2009-02-06 02:31:55 • This command repeatedly gets the specified process' stack using pstack (which is an insanely clever and tiny wrapper for gdb) and displays it fullscreen. Since it updates every second, you rapidly get an idea of where your program is stuck or spending time. The 'tac' is used to make the output grow down, which makes it less jumpy. If the output is too big for your screen, you can always leave the 'tac' off to see the inner calls. (Or, better yet--get a bigger screen.) Caveats: Won't work with stripped binaries and probably not well with threads, but you don't want to strip your binaries or use threads anyway. Show Sample Output 8 watch -n 1 'pstack 12345 | tac' · 2009-02-05 18:17:00 ### 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. ### Check These Out Numeric zero padding file rename rename file name with fixed length nomeric format pattern Get AWS temporary credentials ready to export based on a MFA virtual appliance You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: awk '{ print "export AWS_ACCESS_KEY_ID=\""$1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\""$3 "\"" }' You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials grep (or anything else) many files with multiprocessor power xargs -P N spawns up to N worker processes. -n 40 means each grep command gets up to 40 file names each on the command line. Use Linux coding style in C program put "-linux" option into$HOME/.indent.pro to make it default

Working random fact generator
extension to tali713's random fact generator. It takes the output & sends it to notify-osd. Display time is proportional to the lengh of the fact.

Open a manpage in the default (graphical) web browser
An easy alias for opening a manpage, nicely HTML formatted, in your set internet browser. If you get a "command exited with status 3" error you need to install groff.

Easy way to see your real external IP

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\""$2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }' You must adapt the command line to include: *$MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

list files recursively by size

Fastest segmented parallel sync of a remote directory over ssh
Mirror a remote directory using some tricks to maximize network speed. lftp:: coolest file transfer tool ever -u: username and password (pwd is merely a placeholder if you have ~/.ssh/id_rsa) -e: execute internal lftp commands set sftp:connect-program: use some specific command instead of plain ssh ssh:: -a -x -T: disable useless things -c arcfour: use the most efficient cipher specification -o Compression=no: disable compression to save CPU mirror: copy remote dir subtree to local dir -v: be verbose (cool progress bar and speed meter, one for each file in parallel) -c: continue interrupted file transfers if possible --loop: repeat mirror until no differences found --use-pget-n=3: transfer each file with 3 independent parallel TCP connections -P 2: transfer 2 files in parallel (totalling 6 TCP connections) sftp://remotehost:22: use sftp protocol on port 22 (you can give any other port if appropriate) You can play with values for --use-pget-n and/or -P to achieve maximum speed depending on the particular network. If the files are compressible removing "-o Compression=n" can be beneficial. Better create an alias for the command.