11 Not Sick Linux Commands

1) Create a pdf version of a manpage

man -t manpage | ps2pdf – filename.pdf

Quick and dirty version. I made a version that checks if a manpage exists (but it’s not a oneliner). You must have ps2pdf and of course Ghostscript installed in your box.

Enhancements appreciated :-)

2) Bind a key with a command

bind -x '"\C-l":ls -l'

the -x option is for binding to a shell command

3) Use file(1) to view device information

file -s /dev/sd*

file(1) can print details about certain devices in the /dev/ directory (block devices in this example). This helped me to know at a glance the location and revision of my bootloader, UUIDs, filesystem status, which partitions were primaries / logicals, etc.. without running several commands.

See also:

file -s /dev/dm-* file -s /dev/cciss/*etc..

4) Single use vnc-over-ssh connection

ssh -f -L 5900:localhost:5900 your.ssh.server "x11vnc -safer -localhost -nopw -once -display :0";
vinagre localhost:5900

This command

1. SSH into a machine
2. Tunnels VNC port to your local computer (“-L 5900:localhost:5900”)
3. Runs a single use vnc server (“x11vnc -safer -localhost -nopw -once -display :0”)
4. Goes into the background (“-f”)
5. Runs VNC viewer on the local computer connecting to the remote machine via the newly created SSH tunnel (“vinagre localhost:5900”)

5) Stop Flash from tracking everything you do.

for i in ~/.adobe ~/.macromedia ; do ( rm $i/ -rf ; ln -s /dev/null $i ) ; done

Brute force way to block all LSO cookies on a Linux system with the non-free Flash browser plugin. Works just fine for my needs. Enjoy.

6) A child process which survives the parent’s death (for sure)

( command & )

Test scenario:

* Open xterm (or konsole, …)

* Start xeyes with: ( xeyes & )

* Close the xterminal

The xeyes process should be still running.

 

7) Compare copies of a file with md5

cmp file1 file2

8) backup delicious bookmarks

curl --user login:password -o DeliciousBookmarks.xml -O 'https://api.del.icio.us/v1/posts/all'

Useful script to backup all your delicious bookmarks. With decilicious shutting down soon , it could be useful

9) Run a program transparently, but print a stack trace if it fails

gdb -batch -ex “run” -ex “bt” ${my_program} 2>&1 | grep -v ^”No stack.”$

For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn’t have to mess around with core files.

The one downside is that it does smoosh your program’s stderr and stdout together.

10) back ssh from firewalled hosts

ssh -R 5497:127.0.0.1:22 -p 62220 user@public.ip

host B (you) redirects a modem port (62220) to his local ssh.

host A is a remote machine (the ones that issues the ssh cmd).

once connected port 5497 is in listening mode on host B.

host B just do a

ssh 127.0.0.1 -p 5497 -l user

and reaches the remote host’ssh. This can be used also for vnc and so on.

11) Rename HTML files according to their title tag

perl -wlne'/title>([^<]+)/i&&rename$ARGV,"$1.html"' *.html

The above one-liner could be run against all HTML files in a directory. It renames the HTML files based on the text contained in their title tag. This helped me in a situation where I had a directory containing thousands of HTML documents with meaningless filenames.

No Gui Required




I am a linux advocate, I also believe in freedom in all it’s aspects. Call me old fashion but I still believe “small code” and minimal resources is the way to go. That’s why most of the apps I run have a CLI.
Here are some of my favorite CLI apps.

Pandora – Command Line Alternative

@ https://github.com/PromyLOPh/pianobar

If you’re a command line geek and/or want to keep the strain on your system as low as possible, then Pianobar is an awesome alternative. There are packages available for a number of different distros. The program itself is simple: Open a  terminal, log in to your account, and select the station you want to listen to. You can even ban a song, create a new station, view song history, and everything else you can do in Pandora right from the Terminal. Also there’s no annoying commercial every 3 songs.

Login

receiving your station

Select Station

Hit ? for the menu

+    love current song
–    ban current song
a    add music to current station
c    create new station
d    delete current station
e    explain why this song is played
g    add genre station
h    song history
i    print information about current song/station
j    add shared station
m    move song to different station
n    next song
p    pause/continue
q    quit
r    rename current station
s    change station
t    tired (ban song for 1 month)
u    upcoming songs
x    select quickmix stations
b    bookmark song/artist

cvlc: Console VLC Player

Use ‘cvlc’ to use vlc without interface. This is useful for command line playing or ripping using shell scripts. This will save lots of time.

cvlc '/path/to/my.mp3'

MOC – music on console

@ http://moc.daper.net/

TTYtter for Perl

@ http://www.floodgap.com/software/ttytter/

Noooo, not another Twitter client! Yes, another Twitter client. The difference here is that you’re dealing with a multi-functional, fully 100% text, Perl command line client.

% ./ttytter
trying to find cURL ... /usr/bin/curl
-- no version check performed (use -vcheck to check on startup)
(checking credentials) test-login SUCCEEDED!
-- processing credentials: logged in as screwtape
-- checking for most recent direct messages:
[DM da0][cbqueue/Fri Sep 28 02:01:33 +0000 2007] test test
[DM da1][ttytter/Fri Sep 28 03:01:51 +0000 2007] don't forget to update the website
-- notification: API rate limit is currently 350 req/hr
-- no version check performed (use -vcheck to check on startup)
-- you are logged in as screwtape

You use the -status=... option to post a single tweet, which is more efficient (and can be made bulletproof using the -hold option):

% ./ttytter -status="Writing a letter to my nephew."

There are tons of alternative apps for the CLI

Here are some more

—Office—
.Word ProcessorLaTeX(vim-latexsuite), MS Word 5.5/WP 6.1 (With DOS Emuator)(in DOSemu) http://www.ubuntukungfu.org/blog/2008/08/microsoft-word-linux-command-line-whole-lotta-fun/
.Spreadsheetoleo, sc, slsc, teapot
.Presentationtpp
.PDF Viewerfbgshttp://linux.die.net/man/1/fbgs
..xls Viewer[see File Converters]
..doc Viewerabiword, antiword
..docx Viewer[See File Converters]
.
..abw ViewerAbiword
.Desktop PublishingLaTeX (vim-latexsuite)
.DictionaryDict, edict
.Thesarusthes.shhttp://www.linuxhowtos.org/Tips%20and%20Tricks/cmdline_thesaurus.edit
.Spell Checkerespell, ispell, aspell
.Grammer Checkergrachttp://grac.sourceforge.net/
.PDF Creator[see Document converters]
.Fontsfiglet
.
.—Graphics—
.DrawingImagemagick
.AnimationImageMagick (animate)
.Image Viewerfbi
.Image EditorImageMagick (convert)
.Photo Manager*Create database linked to photo, [script] locate *.jpg | grep <name associated with picture>
.
.3D Modelling/Designingaqsis, freyja, fyre, misfit modeling 3d,http://www.linuxlinks.com/Software/Graphics/Modeling/index.shtml
.3D renderingopengl
.CADBRL-CAD, FreeCADhttp://linux.softpedia.com/get/Multimedia/Graphics/BRL-CAD-105.shtml, http://linux.softpedia.com/get/Multimedia/Graphics/FreeCAD-31097.shtml
.Scanningsane
.
.—Internet—
.Email Clientalpine, mutt, pine
.Internet Browserelinks, links, links2, lynx, netrik, w3m, wget
.Podcatcherbashpodder, podracer
.RSS Feedercanto, raggle, tin, newbeuter, rawdog, snownews
.Remote Connectionssh
.BloggingBash Blogger, chronicle
.Flickrwget [URL] (Download only)
.Youtubeyoutube-dl
.Twittertwitter script, ttytterhttp://www.floodgap.com/software/ttytter/
.Bittorrentrtorrent
.P2Pamulecmdhttp://ergo.rydlr.net/?p=48
.Networkingifconfig, netcat, netstat
.Wirelessiwlist, iwconfig
.Network Sharing/Browsingsamba, nfs
.Wikipedia[script] (download only)http://ubuntulinux.or.id/blog/2006/02/10/wikipedia-command-line/
.FTP Clientftp, lftp, ncftp
.File Transferscp
.Instant Messagingcentericq, finch, naim
.VOIP/SIP Phoneasterisk
.IRC Clientirssi, weechat
.Remote Conferencingssh with VOIP
.Faxhylafax
.Downloadingncftpget, wget,YouGrabber
.Uploading[see FTP clients]
.
.—Organization—
.Calendarcalcurse, gcalcli (google calendar), remind, when, wyrd (curses for remind)
.To-do Listbeeswax, ikog, todo.sh, tofuhttp://todotxt.com/library/todo.sh/
.Address Bookcontact script, abook
.Note Takinghnb, vim-outliner
.Project Managementhnb, vim-outliner
.Flow Charttext::flowcharthttp://linux.softpedia.com/get/Programming/Widgets/Perl-Modules/Text-Flowchart-33327.shtml
.Schedulingskedhttp://linux.softpedia.com/get/Office/Scheduling/Sked-34959.shtml
.
.—Multimedia—
.Video Playergmplayer, mplayer, vlc, xine
.Video Editingffmpeg
.CD Playercdcd, cplay
.Music Playercmus, mp3blaster, mpg123, ogg123,
.Sound Editorsox
.Flash Playermplayer
.Audio Streamingvlc, mplayer, pyradio, realplayhttp://www.coderholic.com/pyradio/
.Music Managermoc, cmus
.ipodgnupod
.TV Applicationmplayer, vlc
.Video Streamingmplayer, vlc
.Webcamhasciicam
.DVD Playermplayer, vlc
.CD Rippingcdparanoia, ripithttp://www.xiph.org/paranoia/faq.html
.
.–File Converters—
.Convert Text to .doc/.odtdocutils (odtwriter)
.Convert .odt to .txtodtwriter
.Convert .odt to .pdfpyodconverterhttp://www.artofsolving.com/opensource/pyodconverter
.Convert .xls to .htmlxlhtml
.Convert .xls to othercatdoc (xls2cvs), gnumeric (ssconvert)
.HTML to .txthtml2text
.Convert .docx to .txtdocx2txthttp://docx2txt.sourceforge.net/
.Any Openoffice.org Convertionopenoffice.org3 -invisible macro:///macro.name.path(/path/to/document/to/convert.ext)http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html
.*macro path/name
.
.—Games—
.Shooterslashem, crawl
.PuzzleBSD-games, greed
.Arcademoon-buggy
.RPGnethack, digitalishttp://home.nedlinux.nl/~florian/
.
.—Development—
.HTML Editorsee Text Editors
.Text Editored, emacs, jed, moe, nano, pico, pie, vi, vim, zile
.DatabasemySQL, PostgreSQL, SQLite
.Adahttp://www.math.utah.edu/faq/compilers
.*Compilersgnat
.Debugger
.C++
.*Compilersc++, cc, g++, g++4, pathcc, pgcc
.*Debuggerlint, splint
.C#
.*Compilerscscc, gmcs, mcs,
.*Debuggerjlint
.C
.*Compilersgcc
.*Debuggerlint, splint
.Fortran
.*Compilersg77, pgf77
.*Debuggerftnchek
.Java
.*Compilersgcj, javac
.*Debuggerjlint
.Pascal
.*Compilersgpc, fdb
.*Debugger
.Pythonpython
.Rubyruby
.Bug Reportinggdb
.Version Trackingbzr, CVS, git, subversion
.
.—Utilities—
.Emulatorsvboxheadless, dosemu, UML
.AntivirusClamAV
.Compression7za, bzip, bzip2, gzip, lz, tar, unrar, zip
.Bluetooth connectivitybluez-utils (sdltool), btscanner
.Palm/Handheld Syncingpalm-link
.CD/DVD Burnerbashburn, cdrecord, mybashburn
.Window Managerscreen, dvtm, twin
.System Monitoringhtop, top
.System Schedulingcron, shush
.Desktop Customization[edit config files]
.Encryptioncrypt, gnupg, pgp, truecrypt
.Authenicationgnupg
.File Searchdoodle, find, locate, slocate
.Screen Saver/Desktop Appsasciiquarium, cmatrix, clockywocky
.Mousegpm
.Screen Capturescript, scrot
.Password Keepervim with password
.File Managermc,vifm
.Power Managerapmd
.Shellsash, bash, csh, ksh, pdksh, sh, tcsh, zsh
.
.Weatherweather
.Text Manipulationawk, sed
.Disk / Folder Usagedf, du, ncdu,
.Miscfsniper (monitor dirs), moreutils, par, detox (clean up filenames)
.
.—Administration—
.Printingcups, lpd, lprng
.Backup and Archievingjar, rdist, rdup, rsync, tar, zip, zoo
.Partition Formattingfdisk, cdisk, parted
.Package Managementapt-get, aptitude, urpmi, yum, zypper
.Firewallsiptables, ufw
.Service Managementsysv-rc-conf
.Network Administrationifconfig, iwconfig
.
.
.—Educational—
.Statisticsr
.Mathematcalnum-util
.
.Typing Tutorgtypist
.
.
.
.
.
.—Hobby/Speciality—
.Accountingchkbk, ledger, SQL Ledger
.
.Geneology/Family Historylifeline
.Calculatorbc, mathomatic, wcalc
.Accessibilityhttp://eklhad.net/linux/app/edbdoc.html
.*Speech-to-Textespeak
.Ham Radiodxcc
.
.Cell Phone Backup[see bluetooth]
.GISgrass
.Investment Trackingquote
.Religious/Bible Readerverse, bible-kjv
.Recipes[see Text Editors or Note Taking]
.
.—Business Speciality—
.Inventory Trackingcustom database
.
.

25 Best Linux Commands For 2011

Here at blog.urfix.com we are kicking off the new year with a new server. Our last server got HN’D. Our poor plug computer could not take the load from being in the front page of Hacker News and finally melted. taking our chances again here are the 25 Best Linux commands for 2011

1) send a circular

echo “dear admin, please ban johnlame” | wall

Broadcast Message from root@urfix.com
(/dev/pts/2) at 20:32 …

dear admin, please ban johnlame

2) Find usb device

diff <(lsusb) <(sleep 3s && lsusb)

I often use it to find recently added or removed device, or using find in /dev, or anything similar.

Just run the command, plug the device, and wait to see him and only him

3) Use file(1) to view device information

file -s /dev/sd*
file(1) can print details about certain devices in the /dev/ directory

(block devices in this example).

This helped me to know at a glance the location and revision of my bootloader, UUIDs,

filesystem status,

which partitions were primaries / logicals, etc.. without running several commands.
See also
file -s /dev/dm-* file -s /dev/cciss/*
etc..

4) Stop Flash from tracking everything you do.


for i in ~/.adobe ~/.macromedia ; do ( rm $i/ -rf ; ln -s /dev/null $i ) ; done

Brute force way to block all LSO cookies on a Linux system with the non-free Flash
browser plugin. Works just fine for my needs. Enjoy.

5) send a circular part 2

wall <<< “Broadcast This”


6) Single use vnc-over-ssh connection

ssh -f -L 5900:localhost:5900 your.ssh.server “x11vnc -safer -localhost -nopw -once -display :0”; vinagre localhost:5900

7) Compare copies of a file with md5

cmp file1 file2

8) back ssh from firewalled hosts

ssh -R 5497:127.0.0.1:22 -p 62220 user@public.ip

host B (you) redirects a modem port (62220) to his local ssh.

host A is a remote machine (the ones that issues the ssh cmd).

once connected port 5497 is in listening mode on host B.

host B just do a

ssh 127.0.0.1 -p 5497 -l user

and reaches the remote host’ssh. This can be used also for vnc and so on.

9) Run a program transparently, but print a stack trace if it fails

gdb -batch -ex “run” -ex “bt” ${my_program} 2>&1 | grep -v ^”No stack.”$

For automated unit tests I wanted my program to run normally, but if it crashed, to add

a stack trace to the output log. I came up with this command so I wouldn’t have to mess around with core files.

The one downside is that it does smoosh your program’s stderr and stdout together.

10) rename files according to file with colums of corresponding names

xargs -n 2 mv < file_with_colums_of_names

Maybe simpler, but again, don’t know how it will work with space in filename.

11) Create a new file

> file

12) stderr in color

mycommand 2> >(while read line; do echo -e “\e[01;31m$line\e[0m”; done)

13) Rename HTML files according to their title tag

perl -wlne'/title>([^<]+)/i&&rename$ARGV,"$1.html"' *.html

The above one-liner could be run against all HTML files in a directory. It renames the HTML files based on

the text contained in their title tag. This helped me in a situation where I had a directory containing

thousands of HTML documents with meaningless filenames.

14) Make vim open in tabs by default (save to .profile)

alias vim=”vim -p”

I always add this to my .profile rc so I can do things like: “vim *.c” and the files are opened in tabs.

15) Look for English words in /dev/urandom

head -100000 /dev/urandom | strings|tr '[A-Z]' '[a-z]'|sort >temp.txt && wget -q http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -O-|tr '[A-Z]' '[a-z]'|sort >temp2.txt&&comm -12 temp.txt temp2.txt

16) Find a CommandlineFu users average command rating

wget -qO- www.commandlinefu.com/commands/by/PhillipNordwall | awk -F\> ‘/num-votes/{S+=$2; I++}END{print S/I}’

17) Set laptop display brightness

echo <percentage> > /proc/acpi/video/VGA/LCD/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/brightnessto discover the possible values for your display.

18) Send your terminfo to another machine

infocmp rxvt-unicode | ssh 10.20.30.40 “mkdir -p .terminfo && cat >/tmp/ti && tic /tmp/ti”

I frequently use this trick to send my terminal settings to HPUX and older RHEL systems.
This is due to the fact that terminfo support for rxvt-unicode (my preferred terminal app) does
not exist on many older Linux and Unices.

19) Efficient remote forensic disk acquisition gpg-crypted for multiple recipients

dd if=/dev/sdb | pigz | gpg -r <recipient1> -r <recipient2> -e –homedir /home/to/.gnupg | nc remote_machine 6969

Acquires a bit-by-bit data image, gzip-compresses it on multiple cores (pigz) and encrypts the

data for multiple recipients (gpg -e -r). It finally sends it off to a remote machine.

20) Look up a unicode character by name

exec 5< <(grep -i “$*” $(locate CharName.pm));while read
<&5;do h=${REPLY%% *};/usr/bin/printf “\u$h\tU+%s\t%s\n”  “$h”  “${REPLY##$h }”;done

21) strips the first field of each line where the delimiter is the first ascii character



cut -f2 -d`echo -e '\x01'` file

22) shell equivalent of a boss button

cat /dev/urandom | hexdump -C | highlight ca fe 3d 42 e1 b3 ae f8 | perl -MTime::HiRes -pnE “Time::HiRes::usleep(rand()*1000000)”

Nobody wants the boss to notice when you’re slacking off. This will fill your shell with random data, parts of it highlighted.

Note that ‘highlight’ is the Perl module App::highlight, not “a universal sourcecode to formatted text converter.” You’ll also need Term::ANSIColor.

23) Open Remote Desktop (RDP) from command line having a custom screen size

xfreerdp –plugin rdpsnd -g 1280×720 -a 24 -z -x m -u $username -p $password 10.20.30.40

This example uses xfreerdp, which builds upon the development of rdesktop. This example usage will also send you the remote machine’s sound.

24) Show memory stats on Nexenta/Solaris

echo ::memstat | mdb -k

25) Create a pdf version of a manpage

man -t manpage | ps2pdf – filename.pdf

Quick and dirty version. I made a version that checks if a manpage exists (but it’s not a oneliner).
You must have ps2pdf and of course Ghostscript installed in your box.

Have fun with these new commands and may the new year bring you and yours prosperity and joy.

25 Even More – Sick Linux Commands

I know how much you guys love top Linux commands. Lets consider this list a part two of my 25 More – Sick Linux Commands

Be sure to check out commandlinefu for more awesome gems.

1) Monitor progress of a command

pv access.log | gzip > access.log.gz

Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. Source: http://www.catonmat.net/blog/unix-utilities-pipe-viewer/

2) Graphical tree of sub-directories

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'

Prints a graphical directory tree from your current directory

3) Delete all files in a folder that don’t match a certain file extension

rm !(*.foo|*.bar|*.baz)

Deletes all files in a folder that are NOT *.foo, *.bar or *.baz files. Edit the pattern inside the brackets as you like.

4) Easy and fast access to often executed commands that are very long and complex.


some_very_long_and_complex_command # label

When using reverse-i-search you have to type some part of the command that you want to retrieve. However, if the command is very complex it might be difficult to recall the parts that will uniquely identify this command. Using the above trick it’s possible to label your commands and access them easily by pressing ^R and typing the label (should be short and descriptive).

5) Define a quick calculator function

? () { echo "$*" | bc -l; }

defines a handy function for quick calculations from cli.

once defined:

? 10*2+3

6) Display a cool clock on your terminal

watch -t -n1 "date +%T|figlet"

This command displays a clock on your terminal which updates the time every second. Press Ctrl-C to exit.

A couple of variants:

A little bit bigger text:

watch -t -n1 "date +%T|figlet -f big"You can try other figlet fonts, too.

Big sideways characters:

watch -n 1 -t '/usr/games/banner -w 30 $(date +%M:%S)'This requires a particular version of banner and a 40-line terminal or you can adjust the width (“30” here).

7) intercept stdout/stderr of another process

strace -ff -e trace=write -e write=1,2 -p SOME_PID

8) Remove duplicate entries in a file without sorting.

awk '!x[$0]++' <file>

Using awk, find duplicates in a file without sorting, which reorders the contents. awk will not reorder them, and still find and remove duplicates which you can then redirect into another file.

9) Record a screencast and convert it to an mpeg

ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg

Grab X11 input and create an MPEG at 25 fps with the resolution 800×600

10) Mount a .iso file in UNIX/Linux

mount /path/to/file.iso /mnt/cdrom -oloop

“-o loop” lets you use a file as a block device

11) Insert the last command without the last argument (bash)

!:-

/usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2 http://www.google.com/then

!:- http://www.urfix.com/is the same as

/usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2 http://www.urfix.com/

12) Convert seconds to human-readable format

date -d@1234567890

This example, for example, produces the output, “Fri Feb 13 15:26:30 EST 2009”

13) Job Control

^Z $bg $disown

You’re running a script, command, whatever.. You don’t expect it to take long, now 5pm has rolled around and you’re ready to go home… Wait, it’s still running… You forgot to nohup it before running it… Suspend it, send it to the background, then disown it… The ouput wont go anywhere, but at least the command will still run…

14) Edit a file on a remote host using vim

vim scp://username@host//path/to/somefile

15) Monitor the queries being run by MySQL

watch -n 1 mysqladmin --user=<user> --password=<password> processlist

Watch is a very useful command for periodically running another command – in this using mysqladmin to display the processlist. This is useful for monitoring which queries are causing your server to clog up.

More info here: http://codeinthehole.com/archives/2-Monitoring-MySQL-processes.html

16) escape any command aliases

\[command]

e.g. if rm is aliased for ‘rm -i’, you can escape the alias by prepending a backslash:

rm [file] # WILL prompt for confirmation per the alias

\rm [file] # will NOT prompt for confirmation per the default behavior of the command

17) Show apps that use internet connection at the moment. (Multi-Language)

ss -p

for one line per process:

ss -p | catfor established sockets only:

ss -p | grep STAfor just process names:

ss -p | cut -f2 -sd\"or

ss -p | grep STA | cut -f2 -d\"

18) Send pop-up notifications on Gnome

notify-send ["<title>"] "<body>"

The title is optional.

Options:

-t: expire time in milliseconds.

-u: urgency (low, normal, critical).

-i: icon path.

On Debian-based systems you may need to install the ‘libnotify-bin’ package.

Useful to advise when a wget download or a simulation ends. Example:

wget URL ; notify-send "Done"

19) quickly rename a file

mv filename.{old,new}

20) Remove all but one specific file

rm -f !(survivior.txt)

21) Generate a random password 30 characters long

strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo

Find random strings within /dev/urandom. Using grep filter to just Alphanumeric characters, and then print the first 30 and remove all the line feeds.

22) Run a command only when load average is below a certain threshold

echo "rm -rf /unwanted-but-large/folder" | batch

Good for one off jobs that you want to run at a quiet time. The default threshold is a load average of 0.8 but this can be set using atrun.

23) Binary Clock

watch -n 1 'echo "obase=2;`date +%s`" | bc'

Create a binary clock.

24) Processor / memory bandwidthd? in GB/s

dd if=/dev/zero of=/dev/null bs=1M count=32768

Read 32GB zero’s and throw them away.

How fast is your system?

25) Backup all MySQL Databases to individual files

for I in $(mysql -e 'show databases' -s --skip-column-names); do mysqldump $I | gzip > "$I.sql.gz"; done

That’s all for today and I hope you enjoyed this list.