Commands by krunktron (1)

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

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

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

Juste a reminder that this works.
You can do some boolean logic like A or B then C else D using or : || and : && So you can do some : # false || false && echo true || echo false false # true || false && echo true || echo false true # false || true && echo true || echo false true # true || true && echo true || echo false true and so on ... I use it like : $(ssh 'test something') || $(ssh 'test something') && echo ok || echo ko

Rename files in batch

List your installed Firefox extensions

Broadcast your shell thru UDP on port 5000
Better solution in case of many clients, imo.

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

create a colorful 田 image

Converts all pngs in a folder to webp using all available cores
As an alternative to the above command, this one ditches the unnecessary and complicated for loop in favor of a way faster multi-core approach for a task that's more CPU than I/O intensive, making it a perfect suite for GNU parallel

Unix alias for date command that lets you create timestamps in ISO 8601 format
I often need to add a timestamp to a file, but I never seem to remember the exact format string that has to be passed to the date command to get a compact datetime string like 20090220T231410 (i.e yyyymmddThhmmss, the ISO 8601 format popular outside the US)

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: