Monday, June 3, 2013

Sending File Attachments from the Shell

There is bad news and more bad news on this subject.  The first bad news is there is no simple, standard, default tool that will allow you to do this on the commandline.  The second bad news is that the old standard way to do this seems to have been stopped as a security problem in Outlook.  Specifically, you used to be able to use the 'uuencode' tool piped to 'mail' to accomplish this, but Outlook no longer interprets that as an attachment (probably to fight the spread of viruses).

The old way of doing it
uuencode filename.csv filename.csv | mail -s 'Subject of email' recipient@domain.com
'uuencode' was a fairly common tool and was packaged for most Linux variants and was even installed by default on some.  Now we have to scavenge a bit, but the tool I have used most is 'mpack'.  It is packaged for both Debian and Ubuntu by the distribution, and you can find pre-rolled versions for Redhat/CentOS/etc.  Once you get it installed, using it is easy.

The new way of doing it
mpack -s 'Subject of email' filename.csv recipient@domain.com
echo
Hopefully the target doesn't move again.

Friday, May 31, 2013

Space, I need space

This is nothing new, but it bears repeating so here we are.  Spaces in filenames under Linux are an annoyance, but one that isn't that hard to deal with.  How do I deal with them?

In one offs, the \.  So `ls Annoying\ File\ With\ Spaces`

How to kill the space?
rename 's/ /_/' *
will replace spaces with _ for all files/dirs in the current directory.

How to deal with spaces while using find?
find . -name \*wav -print0 | xargs -0 ls
This terminates files with the null character instead of a space. Both xargs and find need to do this.

Tuesday, April 16, 2013

ionice is Pretty Darn Nice on IO

I have not often used 'ionice' but I really should be. 'ionice' does for disk IO on linux what standard 'nice' does for processor load. The standard implementation of ionice under linux allows for 3 settings, "Best Effort" "Idle" and "Real Time". The Best Effort setting is the default setting for new processes. Real Time grants priority access above Best Effort. And "Idle" is granted disk access only when another process is not trying to access disk. In this case, we are interested in Idle.

Class:
0 = 2 = None = Best Effort (Medium Priority)
1 = Real Time (High Priority)
3 = Idle (Low Priority)

A standard example would be:
ionice -c3 aide.wrapper --update

This can be used in combination with standard 'nice' to create a uber nice process

ionice -c3 nice -n 19 aide.wrapper --update

References:
Fried CPU
switch-sched.txt in Kernel Source

Friday, April 12, 2013

Getting Medieval on Linux Shutdown

Until today, I had never run into a circumstance where I couldn't reboot a linux box with the 'reboot -f' command.  A reboot this way is definitely not recommended, as it bypasses the system shutdown, doesn't unmount disks, etc.  So always try to use your typical 'shutdown -r now' type of reboot first.

If your machine has a disk error, it is possible that 'shutdown -r now' will never complete.  That is when you can try 'reboot -f'.  If that doesn't complete you have to kick it up a notch and utilize Magic SysRq.

First enable Magic SysRq:
echo 1 > /proc/sys/kernel/sysrq

Then use it remotely to reboot the machine at a very low level:
echo b > /proc/sysrq-trigger

No guarantee you will be able to remotely access that machine again, but it will be going down.

Thanks to http://blog.mohammadzadeh.info/index.php/howto-force-a-immediate-reboot

Tuesday, April 2, 2013

Windows 8 and Office 2013

I wrote the following for my works intranet forum.  I figured it would serve decently here as well


Having had an opportunity to play with both Windows 8 and Office 2013, I figured I would create a topic here to allow people to see some comments about them.


When you first login to Windows 8, you are presented with a start screen that looks like the Windows Phone, a full screened tiled view that has various tiles to launch apps, software, view news, etc.  One of those tiles is "Desktop"

Once you are at the Desktop, it will look similar to Windows 7, but with a couple of major caveates.
1) No Start button.  There are various third party start button applications, including a decent (if a bit ugly) one that is distributed via Ninite.com.  This fails in my opinion in a business environment where change can be difficult for some people to deal with.
2) It's hip to be square.  There are no rounded corners and curves in Windows 8.  It is designed for full screen on a tablet not on monitors, so the asthetic is that everything be full screen.  This fails in my opinion in a business  environment, where you are more likely to have large monitors and multiples.
Because Microsoft is turning your desktop into a glorified handset, they are pushing "Apps"  Apps are a different paradism than software in how you purchase, maintain, how much they cost, etc etc.  But the big thing is it seems that apps are updated through the MS App Store, not through Microsoft Update which still handles the Operating System, and core software from Microsoft.  Again a big fail for business in my opinion.

Anti-virus is built in to Windows 8 by default.  This is something they should have done 15 years ago, but now it is actually not a great thing for businesses because it conflicts with managed anti-virus.  Specifically, we have no way to have an integrated control panel where we can view the anti-virus status of all the machines under our care with it.  We need to use third party AV, and that can't be installed until Windows Defender is disabled.

Office 2013:
The good:  Multiple windows are back, so you can easily put one spreadsheet on one monitor and a different on the other and work efficiently.

The bad:
Visually I think Office 2013 is awful.  It has inherited the squareness of Windows 8, it also has a terrible color scheme.  These two things added together get rid of all the visual queues I used to tell the end of one window and start of another.  Some of this may be the fact that I am color blind, but there is a decent populace of color blind people.

How emails are visually identified as unread changes, and again I find it less visual obvious than earlier versions.



I guess those are my initial comments, feel free to chime in and disagree with me, tell me how smart I am, etc etc.

Monday, March 11, 2013

An Issue of Resolve

Running ISC's bind can be liberating, allowing you to do interesting things, but it can also be frustrating.  I don't know that this is actually an issue with Bind, or with DNS in general.  But definitely, you can see the issues with bind.  The two most common weird issues I have run into relate to IPv6 and eDNS.  Well and primarily IPv6 and eDNS in networks not fully prepared for either (shame on me).

For IPv6 issues, really the simple answer is to turn off IPv6 on your name server.  Debian's more recent versions of bind allow for the addition of a '-4' command line flag, most easily facilitated by editing /etc/default/bind9 to add that commandline option.  You can also turn off IPv6 on the machine in question.  Or *gasp* get yourself fully on IPv6.

If the problem isn't that you are resolving IPv6 addresses that are going no where, the next likely culprit is eDNS.  eDNS and it's ilk cause larger than normal DNS response packets.  Large enough that some routers, firewalls, NAT devices, etc. don't know how to handle those packets and DNS resolution breaks.  If you have effective logging you will see messages like "success resolving 'www.facebook.com/A' (in 'facebook.com'?) after reducing the advertised EDNS UDP packet size to 512 octets"

To test where eDNS is going amiss, you can use the following commands:
dig +norec +dnssec example.com @a.root-servers.net
dig +dnssec +norec +ignore dnskey se @A.NS.se

The first tests if eDNS packets larger than 512 bytes work, while the second tests if everything can handle IP fragmentation.  If the first fails, you need to disable edns.  If the first succeeds and the second fails, you need to limit the edns packet size to prevent fragmentation.  The bind option edns-udp-size can help with both:
edns-udp-size 512; or
edns-udp-size 1460;

Friday, March 8, 2013

Linux Cheatsheet

It can be very useful to have a cheat sheet of information about a command or system you don't often use.  I have created my own cheat sheets for things like mdadm, exim, sendmail, etc.  But today on LifeHacker, a general Linux Cheat Sheet was covered.  The person who wrote it, did a great job, it is meant to be saved in your home dir and viewed via either Emacs or Vi.  Of course, you can just use more/less and it works just as well.  So onto the brilliance:

https://github.com/WilliamHackmore/linuxgems/blob/master/cheat_sheet.org.sh