Think before you type

su –

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Password: _

Yay root. I am paranoid guy, I don’t use root unless its required. I believe K-dog is a root kind of guy… but here are some sobering commands I have had to recover from.. either myself or from others:

hostname i

Instead of hostname -i. This changed the name of the production server to i… Luckily we just changed it back real quick.. WHEW! I typed that one.

rm -rf /

Maybe the worst command to run.. Remove everything with force (don’t ask, just do it) Instead of rm -rf ./ (force remove the current folder) This was not me…and what a terrible idea. DON’T RUN THIS! So this system was done. DON’T USE ROOT WHEN ANOTHER CAN DO IT

service network restart  # (after pasting a ifcfg-eth0 config wrong)

EVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETWORK=10.0.1.0
NETMASK=255.255.255.0
IPADDR=10.0.1.27
USERCTL=no

Top line should be DEVICE=eth0. Mistake by rushing, and now the NIC is down because of an incomplete config file.. These are my favorite phone calls:

Me: “Hi, anyone on site near the system?”
Dude: “Me!”
Me: “I lost network connection, how comfortable are you in linux and vi?”
Dude: “What is vi”
Me: (FUCK) Okay login as root.
Me: Okay cd slash etc slash sysconfig slash network… no…ECHO TANGO CHARLIE… its not there? It HAS to be there…Is there a slash before it? Where are you now? Type PWD……

[***PAIN***]

Me:….ok we are there, type vi ifcfg-eth0
Me: Now push lowercase i
Dude: Nothing happen
Me: Does it show insert mode on the bottom
Dude: You would think these systems would have a better editor here.. The mouse doesn’t work either
Me: Type a capital D
Dude: Ok the top line is gone now
Me: (YOU WERE NOT IN INSERT MODE) Okay type u, that should undo the remove
Dude: Nothing
Me: Push ESC like 50,000 times and try again
Me: Nothing? Okay let’s quit without saving push ESC then :q!
Me: Yes actually colon q exclamation. Are we back to the command line……….

[***AGONY***]

Me: ……Great, let me try to ping it…

[***FEAR***]

Me: …works!  thanks! /throw headset

All for a D…

su –

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Password: _

Recursive downloading using wget

Here’s a little one liner to help ya out.

#> wget -A jpg,jpeg,gif -r http://myCoolWebsite.com/puppyPower/2/4.html

#> wget -A jpg,jpeg,gif -r http://myCoolWebsite.com/puppyPower/3/3.html

and then through a loop in there:

counter1=4
counter2=4

{psuedo-code}

while $counter1 -gt 0;

do wget -A jpg,jpeg,gif -r http://myCoolWebsite.com/puppyPower/2/$counter1.html

done

{psuedo-code}

 

Also wanted to remember this little gem. I was trying to recursively mirror/download some Oracle Linux. I kept getting the index.html only. Or other stuff I didn’t want. So after looking through the man page and finding it lacking (suprise!) I went and consulted Google. It’s to bad the name Oracle was already taken, how cool would it be to tell someone “Go ask the Oracle” when you wanted to find something out.

This little one-liner allowed me to pull down the Oracle repo onto one of our local Yum repos.

#> wget -r -e robots=off http://public-yum.oracle.com/repo/OracleLinux/OL5/7/base/x86_64/

Boy, the guys are gonna be happy with me when they find out that they can update there OVS servers from our internal Yum!

K-dog

:wq

 

Using wget to download internet content

We’ve all been there, right? You just found a cool site with tonnes of art pics on it. You explore around the site and then wonder if there is more. So begins the Address Surfing routine. This results in: “Ah Ha!” Yes, there IS more content there than you first found. Now, of course, you want to pull down all of those cool pics… [Read more…]

Web address surfing

Address surfing, oldest hack in the book. Let’s say you’ve got a url that is like this http://myfamilywebsite.com/Vacations/Finland.html
Well what if the webmistress didn’t add very good navigation to her pages. And you want to see [Read more…]

Intel SCSI Sense Codes

We all have these memorized.. right..?

Mar 9 06:14:05 backup2 MR_MONITOR[3213]: Controller ID: 0 Unexpected sense: PD #012 = Port 4 – 7:1:11Power on, reset, or bus device reset occurred, CDB = 0x88 0x00 0x00 0x00 0x00 0x00 0x1a 0x87 0x7e 0x00 0x00 0x00 0x00 0x80 0x00 0x00 , Sense = 0x70 0x00 0x06 0x00 0x00 0x00 0x00 0x0a 0x00 0x00 0x00 0x00 0x29 0x00 0x00 0x00 0x00 0x00

NSFW Response:

SFW Response:

How is this helpful to anyone, anywhere, in the history of ever anything…?

For the people not forced to read this at work all day, this is from /var/log/messages and means a SCSI error of “6 29 0” on Disk 7:1:11. The “6 29 0” is the 3rd, 12th, and 13th Hex code after the word Sense… Yeah…. To the CLI!

~$ grep Unexpected /var/log/messages | perl -pe 's/[A-Za-wyz]//g' | awk '{print $14, $39, $49, $50}' | sort | uniq -c
1 7:1:11 0x06 0x29 0x00

NSFW response to myself while proofreading this post:

SFW response to myself while proofreading this post:

Is this easier? The output maybe, but what is this command above it….

Breakout:

1. grep Unexpected /var/log/messages – Gimme any line that has the word “Unexpected” in it
2. perl -pe 's/[A-Za-wyz]//g'– Find all CAPITAL LETTERS, and all lowercase letters (excluding x) and replace with nothing. (Nothing is between the “//” at the end). g means globally, as in all of it.. not just the first one found

Further Example. This would replace the text “Winnebago Man” with the text “My Dad”. Few would disagree.
perl -pe 's/Winnebago Man/My Dad/'

3. awk '{print $14, $39, $49, $50}‘ – Break it up like a spreadsheet and print these columns.
4. sort – sort by the first column
5. uniq -c – Don’t show me all of the output idiot.. just gimme the name, the error, and how many times it showed up.

#Music during this post:
##Lots of Winnebago Man editing.
##Agent Alvin – This Feeling – http://open.spotify.com/track/6FheAKBfuwp4p39Y9Pl1CT

#SCSI Errors reading:
##http://en.wikipedia.org/wiki/Key_Code_Qualifier

#Warnings:
##Command needs more testing.

#################

BREAKING NEWS:

my command has been altered:

grep Unexpected /var/log/messages | perl -pe ‘s/[a-z][a-z,]+//ig’ | perl -lane ‘print “$F[12], $F[34] $F[44] $F[45]”‘ | sort | uniq -c

HOT.

FSCK

So…I went ahead and made a thing.

All proceeds to go K-dog, as it was his idea 🙂

Simple directory listing for sorting, easy reading

Ever run into one of those times when you need to get the filenames out of a directory. You only want the filenames, and not all that other junk that normally comes with the output of the “ls” command?

Introducing the “-1″ (that’s numeral one) option to ls. This will give you only what you want: filenames.

Example out put of ll or ls -la:
It’s kinda messy, right?

[root@HMUFUJNFS02 network-scripts]# ll
total 264
-rw-r–r– 1 root root 147 Apr 16 14:43 22APR2014-ifcfg-bond1.131
-rw-r–r– 1 root root 145 Apr 16 14:44 22APR2014-ifcfg-bond2.133
-rw-r–r– 1 root root 142 Apr 16 14:44 22APR2014-ifcfg-bond2.134
-rw-r–r– 1 root root 146 May 7 2013 ifcfg-bond0
-rw-r–r–. 1 root root 101 Apr 22 2013 ifcfg-bond0.129
-rw-r–r– 1 root root 145 Apr 29 2013 ifcfg-bond1
-rw-r–r–. 1 root root 147 Apr 22 2013 ifcfg-bond1.131
-rw-r–r– 1 root root 146 May 7 2013 ifcfg-bond2
-rw-r–r– 1 root root 145 Apr 29 2013 ifcfg-bond2.133
-rw-r–r– 1 root root 142 May 2 2013 ifcfg-bond2.134

—- —-

Now check out the ls -1 option:
Nice and clean. Now we can pipe that to a file or into another command.

[root@HMUFUJNFS02 network-scripts]# ls -1
22APR2014-ifcfg-bond1.131
22APR2014-ifcfg-bond2.133
22APR2014-ifcfg-bond2.134
ifcfg-bond0
ifcfg-bond0.129
ifcfg-bond1
ifcfg-bond1.131
ifcfg-bond2
ifcfg-bond2.133
ifcfg-bond2.134

Happy Linuxing!

K-Dog

Death and Taxes

“In this world nothing can be said to be certain except
death and taxes.”

 -Benjamin Franklin, in a letter to Jean-Baptiste Leroy 1789.

 

deathmtaxes11

Well, in order to motivate me to actually do my taxes (it’s about time, right?) I thought I would throw on some Metal and get to work! I always hate tax time and therefore put it off until I can’t any more.

So I went to the FreeFillableForms website to file my Federal taxes. I was able to log in quickly and start banging away, filling up the text boxes. God, remember when there was no online tax service and you had to use one of those ancient pencil things? So, everything was good and this wasn’t turning out to be the Spirit Crusher that I thought it would be. Even getting a refund.

Then I went to the Utah State online tax site. This caused me some frustration. I couldn’t seem to log in at all. I double checked  my previous account info – “yup, that’s all correct, WTF? why can’t I log in?”  So I clicked around a bit and then I found some thing on the Utah state site referring to Silverlight.  What?!  Why is a state website using a proprietary, closed source program! Microsoft Silverlight! Damnit don’t the web-geeks at the state know this will cause issues? Even with Novell’s hearty attempts to clone it for Linux with “MoonLight“, it still is a PITA for Linux users everywhere. This made me want to “Scream Bloody Gore“.  The neighbors could probably hear me yelling my battle cry of “Open Standards For ALL!!!”

For a while I thought I was doomed. I keep looking though, determined. Eventually I stumbled onto some part of the Utah state site which allowed me to create a new account. So far, so good, I’m thinkin Chrome and Fedora, getting the job done. I get through the state site clickies, checkboxes and text boxes. All set, right? Wait, why does it say that I owe $3000 to Utah?! Bastards!!!    “Oh,  K-Dog, just double check your maths, alright?” Ok so I do. Whoops, looked like I skipped one section. Add that section… recalculate…  YES!  Utah Tax Owed is $0.00. Take that, Utah.

So, knowing that I’m getting money back from the US and not owing Utah (first time, ever) gave me a feeling of Spiritual Healing“. Alright, so that bloody ritual is over for one more year.

Happy Tax Time!

K-Dog

Asymmetric Routing

####################################################
#03 Apr 2014
#
#Beer of the night:
#Boulder Beer’s Shake Chocolate Porter.
#
#Music during this post:
# Joe Hisaishi’s Spirited Away
# Agent Alvin
#
#Revisions: Only 11
####################################################

First off….nightmares of Cisco questions with multiple router icons………

Rage

This was a Thursday night Linux rant with K-Dog celebrating his B-Day with dark beers and games. I had a situation where no matter which default gateway I set, one of the subnets couldn’t ping/connect/whatevertheF….

Potential resolutions:
http://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/
(Editing /etc/iproute2/rt_tables to add a top down rule for routes. )

Or maybe:
https://access.redhat.com/site/solutions/53031
(Accept asymmetrically routed packets)

Try it out K-Dog…

#Update:
#08 Apr 2014:
Setting net.ipv4.conf.default.rp_filter to 2 really worked…!  Of course its not supported in our environment.

 

Tux’s Gallery