Home Blog Page 1338

Assorted Fun Linux Command Line Hacks

Today’s fun command line festivities are inspired by Command Line Magic, who hangs out on Twitter sharing excellent Linux command line incantations for all occasions. Today’s assortment includes shell rainbows, Is the Internet on Fire?, Star Wars Traceroute, and creating annoying sounds from the console.

Rainbows In Your Shell

This little gem creates a colorful scrolling display. Ctrl+c stops it:

$ grep -o --binary-files=text '[[:alpha:[[' /dev/urandom |tr -d '[a-zA-Z]' |xargs -n $(($COLUMNS/2)) |tr -d ' '| lolcat -f | pv -L80k

fig-1 alien

lolcat creates the colors, pv controls the speed, and the COLUMNS value controls the width of the columns. Let’s add figlet to make words (figure 1):

$ grep -o --binary-files=text '[[:alpha:[[' /dev/urandom |tr -d '[a-zA-Z]' |xargs -n $(($COLUMNS/2)) |tr -d ' '| figlet | lolcat -f | pv -L80k

So maybe they’re alien words. This makes scrolling bands of colors (figure 2):

$ yes "$(seq 231 -1 16)" | while read i; do printf "x1b[48;5;${i}mn"; sleep .02; done 

fig-2 rainbow

Change the seq and printf numerical values to get different results.

Is the Internet on Fire?

You can get the answer to this question by visiting Is The Internet on Fire.com. Or you can run a fast command-line query:

$ host -t txt istheinternetonfire.com
istheinternetonfire.com descriptive text "Yep. 
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-6271https://www.mozilla.org/security/announce/2014/mfsa2014-73.htmlhttp://blog.jquery.com/2014/09/24/update-on-jquery-com-compromises/"

All that does is use the host command to query the TXT DNS record type for istheinternetonfire.com. You can do this for any site, though most of them are boring SPF records and not clever at all. Try the dig command for a more thorough result:

$ dig -t txt istheinternetonfire.com
; <<>> DiG 9.9.5-3-Ubuntu <<>> -t txt istheinternetonfire.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54734
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;istheinternetonfire.com.       IN      TXT
;; ANSWER SECTION:
istheinternetonfire.com. 9385   IN      TXT     "Yep. 
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-6271https://www.mozilla.org/security/announce/2014/mfsa2014-73.htmlhttp://blog.jquery.com/2014/09/24/update-on-jquery-com-compromises/"
;; AUTHORITY SECTION:
istheinternetonfire.com. 84967  IN      NS      a.ns.joker.com.
istheinternetonfire.com. 84967  IN      NS      b.ns.joker.com.
istheinternetonfire.com. 84967  IN      NS      c.ns.joker.com.
;; Query time: 34 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Tue Sep 30 20:13:48 PDT 2014
;; MSG SIZE  rcvd: 316

Use the short option to get the same results as with the host command, though when you do that you miss the funny nameservers in the AUTHORITY section:

$ dig +short -t txt istheinternetonfire.com
"Yep. https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-6271https://www.mozilla.org/security/announce/2014/mfsa2014-73.htmlhttp://blog.jquery.com/2014/09/24/update-on-jquery-com-compromises/"

So how do you create fun TXT records? It all depends on which DNS server you are using. If you’re using a hosting service or domain name registrar, then they will have a Web form. If you’re running BIND or Dnsmasq it’s a line in a configuration file, like this example for dnsmasq.conf:

txt-record="Hellos! This is my amazing TXT record. You are l33t to find and read it."

The quotation marks are just normal punctuation; they’re not required because a TXT record can contain any arbitary text.

Star Wars Traceroute

This is an oldie but still ingenious goodie, created by Ryan Werber when he was snowed in and bored. Mr. Werber had an unused /24 address space to play with, a gaggle of Cisco routers, and PowerDNS + MySQL to create the fake domain names like the.DEATH.STAR and destroy.an.entire.planet. First try the plain traceroute with no options:

$ traceroute  216.81.59.173
[...]
24  the.DEATH.STAR (206.214.251.46)  148.961 ms  144.843 ms  146.098 ms
25  an.armored.space.station (206.214.251.49)  146.510 ms with.enough.power.to (206.214.251.54)  144.928 ms an.armored.space.station (206.214.251.49)  148.835 ms
26  destroy.an.entire.planet (206.214.251.57)  147.232 ms with.enough.power.to (206.214.251.54)  145.949 ms  142.546 ms
27  destroy.an.entire.planet (206.214.251.57)  147.386 ms  146.206 ms  148.834 ms
28  Pursued.by.the.Empires (206.214.251.62)
[...]

The first run came out a little garbled for me, but there is a message near the end: Please.Try.Again.Tracerote.to.obiwan.scrye.net. Let’s try that, spelled correctly of course:

$ traceroute obiwan.scrye.net

That looks a little better. But it’s cut off before it finishes because traceroute defaults to 30 hops. So let’s try 100 hops:

$ traceroute -m 100 obiwan.scrye.net

You can see the complete output on Pastebin. So how far does this go? Far enough to get Rickrolled. Thanks a lot, Ryan Werber!

But we’re not done yet, because clever use of the seqxargs and dig commands pretties it all up nicely:

$ ( seq 1 8 200 ; seq 6 8 200 ) | sort -n | xargs -I{} -n 1 dig +short -x 206.214.251.{}

fig-3 star wars

You may also enjoy ASCII Star Wars:

$ telnet towel.blinkenlights.nl

Turning Command Output into Audio

Way back in the olden daze we thought it was awesome fun to run cat /proc/kcore > /dev/dsp, which piped kernel activity to the audio device to make weird noises. (Hey, we were dull and proud of it.) Everything is different now and there is no /dev/dsp, so try this instead:

$ sudo cat /proc/kcore | aplay
Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono

You can pipe just about anything to aplay, like tcpdump:

$ sudo tcpdump -i eth1 | aplay

Or list all files and directories on your system:

$ ls -R / | aplay

Perl translates an English sentence into…I’m not sure what:

$ perl -e '@w = split / /, "First it rubs the lotion in, then it eats the crispy skin. Sometimes it rhymes, sometimes it doesnt."; print "$_n"x1000 foreach @w;' | aplay

You can use any text you want (except single or double quotes), and the longer the text the longer it plays. Change the print value of 1000 to control the speed; smaller is slower and larger is faster.

This one keeps going until you stop it with Ctrl+c:

$ perl -e 'use bytes; for($t=0;;$t++){ print chr($t*(($t>>11|$t>>23)&83&$t>>3)); }' |play -t raw -b8 -r8k -e un -

It sounds like a hypnotic robot march. Play around with the numerical values in ($t>>11|$t>>23)&83&$t>>3) to get different effects.

This little jewel plays a cool space-age sound every time you open a new terminal:

$ echo '(play -q -n synth sine F2 sine C3 remix - fade 0 4 .1 norm -4 bend 0.5,2399,2 fade 0 4.0 0.5 &)' >> ~/.bashrc

Playing with commands like these is a fun way to learn advanced options, and how to ingeniously combine commands. Please share your own favorites here in the comments, and with Command Line Magic on Twitter.

Cumulus Linux: First Impressions

Typically, when you buy a network router or switch, it comes bundled with some version of the manufacturer’s operating system. Cisco routers come with IOS (or some derivative), Juniper routers come with Junos, and so on. But with the recent proliferation of merchant silicon, there seem to be fewer and fewer differences between competing devices under the hood. For instance, the Juniper QFX3500, the Cisco Nexus 3064, and the Arista 7050S are all powered by an off-the-shelf Broadcom chipset rather than custom ASICs developed in-house. Among such similar hardware platforms, the remaining differentiator is the software.

One company looking to benefit from this trend is Cumulus Networks. Cumulus does not produce or sell hardware, only a network operating system: Cumulus Linux. The Debian-based OS is built to run on whitebox hardware you can purchase from a number of partner Original Device Manufacturers (ODMs). (Their hardware compatability list includes a number of 10GE and 40GE switch models from different vendors.)

Read more at PacketLife.

GNOME 3.14 Improves Linux Desktop Visual Detail, Other Features

The GNOME 3.14 desktop release is the second major update to the popular Linux user interface in 2014. Take a look at new and enhanced features.

Read more at eWeek

Red Hat Storage Server 3: Not Your Usual Software-Defined Storage

Red Hat’s new storage server does more than just help you get a handle on your enterprise storage. It also gives you what you need to manage big data and ready-to-run partner storage solutions.

Shellshock Vulnerability Spreads to NAS Devices

Shellshock is getting “NASty.” The vulnerability is being exploited in network-attached storage devices, FireEye reports.

Read more at eWeek

Other Projects Participating In This Winter’s Women Outreach Program

While we’ve covered the X.Org Foundation’s inaugural participation in the GNOME OPW women outreach program given our focus at Phoronix on the Linux graphics stack, women looking for other open-source projects to get involved with in the months ahead have a large choice for this winter OPW cycle…

Read more at Phoronix

Zalewski on the Other Bash RCEs (CVE-2014-6277 and CVE-2014-6278)

Those interested in the more recently discovered bash vulnerabilities will likely want to have a look at this detailed posting from Michal Zalewski. Then make sure your systems are updated. “I initially shared the findings privately with vendors, but because of the intense scrutiny that this codebase is under, the ease of reproducing these results with an open-source fuzzer, and the now-broad availability of upstream mitigations, there seems to be relatively little value in continued secrecy.

Read more at LWN

ownCloud, Red Hat Join Hands to Bring Secure Cloud to Enterprise Customers

Red Hat and ownCloud have come together to offer a secure, private on-premises alternative for file sync and share by combining Red Hat Storage Server 3 with ownCloud’s Enterprise Edition on-premises enterprise file sync and share. 

The collaboration means better pricing and support. “Estimated pricing for a solution deployed on industry-standard big data servers starts at $4.45 per user per month for 1,000 users, inclusive of server hardware, ownCloud and Red Hat Storage Server 3 subscription licensing,” says ownCloud in a press statement.

Read more at The Mukt

OpenWRT “Barrier Breaker” 14.07 released

The long-awaited OpenWRT 14.07 release is out. It includes an update to the 3.10 kernel, a new init system (procd), improved IPv6 support, support for system snapshots and rollbacks, support for dynamic firewall rules, a new MDNS daemon, DNSSEC validation support, and more.

Read more at LWN

PHP As A Next-Generation Programming Language?

Frank Karlitschek, the founder of the ownCloud project, is making the case that PHP isn’t that bad of a scripting language and should be taken to the next level with its shortcomings addressed so it can regain some of its popularity…

Read more at Phoronix