Posts Tagged Linux
MCOD – 9.28.2011 – Simple OS X Bash Changes
Posted by Jon Zobrist in Mac Command of the Day, Macintosh on September 28, 2011
Macintosh Command of the Day Sept 28, 2011
I have no idea why I did not do this sooner!
On my Macs I always had that md5sum the command doesn’t exist, and I hate that the output of the md5 command that does exist is not the same as the GNU tools. Sure it’s BSD (And I’ll always love my BSD), but I think compatibility to the GNU tools buys more for BSD and OS X than incompatibility.
Add this to your ~/.bashrc (and source it or restart your terminal)
alias md5sum='md5 -r '
Now your md5sum <filename> works the same as on the 1,000,000,000 Linux boxes out there.
Also in my .bashrc on my Macbook Air is
alias ll='ls -Falh' alias lg='ls -Falh|grep -i ' declare -x EDITOR="/usr/bin/vim" declare -x JAVA_HOME="/usr/"
-Jon
Ubuntu codenames, my own cheat sheet, rant, and link
Posted by Jon Zobrist in Linux on June 1, 2011
I love Ubuntu.
I use it everywhere. I love the Debian based dpkg, the default installs, the Amazon AWS compatible EUC cloud.
I’m also a big fan of cool names, I like having printers and domains and whatever on some big, geeky, internal naming schema, like everything relates to Norse mythology or Star Trek.
But, I CANNOT STAND the code names for Ubuntu projects being used to refer to the version. I’m running Ubuntu 9.04, or 8.04 LTS, or 10.04 LTS, etc. I am not running Ubuntu Honey Badger, or whatever code name they developed under.
This is only annoying when I’m trying to find instructions about how to do something and people say things like ’Well, I tried this and it worked on Hoary’. WTF is a Hoary? Please, don’t tell me, I don’t care.
So, for my own sanity I am posting this rant, and linking to the page with a list of Development Codes for Ubuntu, as I’m sure, going forward, I’m going to need it.
https://wiki.ubuntu.com/DevelopmentCodeNames
And for my quick use, the versions I use most:
8.04 Hardy Heron
9.04 Jaunty Jackalope
10.04 Lucid lynx
11.04 Natty Narwhal
LCOD 5.29.2011 – 2 quick TCP port check scripts in Python
Posted by Jon Zobrist in Programming, Python on May 29, 2011
Disclaimer : These scripts could be considered malicious and should only be used to test servers with permission from the server administrator. I accept no responsibility for your use of these scripts, and make no warranty about their usefulness either express or implied.
I often find myself troubleshooting someone’s network connectivity, or one of my servers ability to receive connections or mass connections.
For this, nmap is invaluable, but sometimes it’s easier to just send someone a script to run, especially in larger companies where things like nmap, and other port scanners are frowned on.
So, here are 2 scripts that take the same arguments HOST PORT.
They are tcpcheck.py (here is the gzipped version), and tcpcheck-bulk.py (here is the gzipped version).
tcpcheck.py makes 1 connection to a TCP port and reports success or failure.
Example usage and output :
./tcpcheck.py jonzobrist.com 80
Success. Connected to jonzobrist.com on port: 80
./tcpcheck.py jonzobrist.com 81
Failure. Cannot connect to jonzobrist.com on port: 81
tcpcheck-bulk.py is hard wired to attempt 1500 connections to a TCP port and reports success/failures.
Example usage and output is :
./tcpcheck-bulk.py jonzobrist.com 80
Done with jonzobrist.com on port: 80
Done. Failures : 0 Successes : 1500
This script was very useful when we tried to determine server performance over a link that seemed to be killing our connections.
Please feel free to use it, and share if it helped.
Delete lots of EC2 EBS volumes
Posted by Jon Zobrist in AWS, Bash, EBS, Programming on May 23, 2011
Here is a quick script to delete lots of EBS volumes on Amazon EC2.
The output from something like
ec2-describe-instances i-6fc30f01 | grep ‘^BLOCKDEVICE’ | awk ‘{ print $3 }’ > delete-these-volumes.txt
Then run
./delete-volumes.sh delete-these-volumes.txt
Can be fed into this script (you may want to edit the file first, I accept no responsibility for you deleting your volumes, with or without my script.
Download the gzipped script here.
Example output from me deleting 60 real volumes:
My EC2 EBS RAID-0 creation script
Posted by Jon Zobrist in AWS, Bash, EBS, EC2, Linux, Linux Support - Servers, Programming on May 4, 2011
I want to write up a full howto/tutorial, but have not had the time.
Here is the script that I referred to in my post at http://jonzobrist.com/2011/04/16/ec2-raid0-on-linux-with-ebs-volumes-notes/
This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License HERE for more details.
http://jonzobrist.com/files/setup-ec2-raid-0.zip
http://jonzobrist.com/files/setup-ec2-raid-0.sh.gz
This script needs an AWS command line setup, and may need some minor tweaking if you’re not running a Ubuntu server.
Ubuntu’s latest AMI’s are available for 10.04 here.
Please feel free to submit patches, comments, or questions.
Thanks to everyone whose helpful posts online and in the AWS forums helped me with this script. I could not have done it with out your generous sharing of work.
Enjoy!
Getting started with Chef.
Posted by Jon Zobrist in AWS, Chef, EC2, Linux, Linux Support - Servers on April 21, 2011
I write a lot of scripts, configure a lot of systems, and do a lot of snapshot related backup/restore/sync stuff on servers in house, and in the cloud.
Chef is a Ruby-based configuration management engine. There is a good intro here.
I set up a Chef Server. There’s a good overview here.
I followed the instructions to setup a Chef server from this Wiki on Opscode.
I also referred to the information from Grig Gheorghiu’s blog here.
Now that my server is up, I’m hoping to port my server configurations to Chef, with heavy reliance on EC2 and hopefully UEC.
LCOD – 7.24.10 – Get su to respect /etc/security/limits.conf
Posted by Jon Zobrist in Linux, Linux Command of the Day, Linux Support - Servers on July 24, 2010
Get su to respect settings in /etc/security/limits.conf
Click to continue reading “LCOD – 7.24.10 – Get su to respect /etc/security/limits.conf”
LCOD – 4.12.10 – Quick Mysqlreport to e-mail setup
Posted by Jon Zobrist in Linux, Linux Command of the Day, MySQL Server Support on April 12, 2010
This will be a quick install to setup your server to e-mail you daily mysql reports using the cool mysqlreport application at hackmysql.com
Click to continue reading “LCOD – 4.12.10 – Quick Mysqlreport to e-mail setup”
LCOD – 6.18.09 Useful command line grepping (grep!)
Posted by Jon Zobrist in Linux, Linux Command of the Day on June 18, 2009
There are a few regular expressions I find myself using all the time via grep on the command line. Here are a few, along with a few frequently used commands I can’t live without.
Find the non comment parts of a file.
(Useful if you want to see or compare the active parts of a config file.)
Most Unix config files use # as a comment tag, indicating everything after the # is a comment.
grep ‘^[^#]‘ filename.conf
To break this down, first we have grep , which is a command line program to find lines that match a regular expression pattern, and display them. The single quotes indicate that we’re passing the entire section enclosed in single quotes as the first argument, which doesn’t matter as much in this example, but it’s good to practice, so when you have a space or some other character, you won’t be confused when your shell interprits it. The regular expression used is
^[^#]
Which is slightly trick, as far as regular expressions go, for only one reason; the character ^ is used twice, with different meanings.
Normally the ^ is regular expression for the start of a line, and we use it here as this, the first time. The second time, inside the brackets, it means NOT.
Brackets in regular expressions are like a giant OR statement, with every non-escape character (like the forward slash / ) as a possible match. This can hang people up when they expect [bob] to match the full word bob, instead of just the first b.
Then we have the #, which just matches our comment character, #.
Then the closing bracket, since we’re not doing any other options.
The net result of this is to match any line that has a # right after the start of the line.
To do the same thing on a config file that uses a ; as a comment indicator:
grep ‘^[;]‘ filename.conf
OR, to be even trickier, you could just add the # and ; in the same set of brackets, like
grep ‘^[;#] fliename.conf
Note the order of items inside the bracket doesn’t really matter in this case.
Next, often times I have a file with a bunch of empty lines in it, and I want to quickly get rid of them all. To do this I use a combination of a simple grep and a output redirect.
grep . filename
The . character is a regular expression match for any character, but it won’t match empty lines (the regular expression ^$ does though).
To get this into the file, first redirect it to a new file, then move the file back.
grep . filename > newfile
mv newfile filename
or, if you want to sort, just run
sort newfile > filename
perhaps you now want to just get the unique lines
uniq newfile > filename
Of course, I should mention the very obvious ones.
Grepping for words in files.
grep Word filename
Note that grep is case sensitive, but you can turn that off with the -i flag.
grep -i word filename
There is an infinite amount of uses for grep, but the foundation for grep/sed/awk/perl use for patterns is regular expressions. More than any single book I’ve read about techonlogy, the O’Reilly book “Mastering Regular Expressions”, by Jeffrey Friedl has helped me the most in my IT career. I highly suggest you buy and read it.
LCOD 2.23.09 Setup Polycom Soundstation 6000 w/Asterisk
Posted by Jon Zobrist in Asterisk, Linux, Linux Command of the Day, VoiP on February 23, 2009
Setup/install notes, Polycom Soundstation IP 6000 with Asterisk 1.4
Have tftp setup, in this we use /tftpboot as the main tftp folder, and it’s world readable/writable, (LIMIT ACCESS VIA IPTABLES/FIREWALL/SOMETHING)
Have a dhcp server setup that’s giving out the normal things for SIP phones,
option tftp-server-name “[ASTERISK-SERVER-IP";
option time-offset -23400; # Mountain Standard Time
option ntp-servers 10.0.2.1;
Have asterisk up and running, make a SIP extension/entry like you would for a normal SIP client, although don't use type=friend, use type=peer
like this for extension 101, username 101, password temp
[101]
type=peer
username=101
secret=temp
host=dynamic
context=[your default context for phones]
qualify=150
accountcode=[optional accounting code]
mailbox=[extension for mailbox]
reload asterisk’s sip module
asterisk -vvvngrd
asterisk*>CLI>sip reload
Setup the Polycom:
download the latest rpm for firmware for trixbox from
http://yum.trixbox.org/centos/5/RPMS/
this time it was:
http://yum.trixbox.org/centos/5/RPMS/firmware-polycom-3.0.1-2.noarch.rpm
unzip this, put the tftpboot files into your tftpboot dir, put the setup-polycom.rpm_tmp_update in
/usr/local/sbin/setup-polycom.rpm_tmp_update
check which NIC your asterisk interface system is on and run
/usr/local/sbin/setup-polycom.rpm_tmp_update
(my ntp server doesn’t like our SIP clients sntp requests, so I use time.nist.gov and nat that outbound for the phones)
edit /tftpboot/server.cfg
change
tcpIpApp.sntp.address=”192.43.244.18″
Now download the latest version of the sip firwmare from polycom
http://downloads.polycom.com/voice/voip/sp_ss_sip/spip_ssip_3_1_2_release_sig_combined.zip
unzip and put all the files in /tftpboot/
edit /tftpboot/000000000000.cfg
add server.cfg on the CONFIG_FILES line, so mine looks like this
note there were 2 other application lines but i left them the same as they looked like they were for SPIP300/500′s
now, per conference phone, copy the /tftpboot/000000000000.cfg to /tftpboot/[phone mac address].cfg
the mac address is also the serial number of the phone (on the back!)
I’m not sure if it’s case sensitive but I did all lower case and it worked, tail your tftp servers logs to see what’s getting requested.
edit the /tftpboot/[phone mac address].cfg
on the line where you added server.cfg, add a custom config for this device, calling it whatever you want, so if you wanted, call it conference1.cfg, your application line would look like:
now edit that file /tftpboot/conference1.cfg (or whatever you called it)
username and password should match what you put in asterisk’s sip.conf
it should look something like this
< ?xml version="1.0" encoding="UTF-8" standalone="yes"?>
reg.1.label="101"
reg.1.auth.userId="101"
reg.1.auth.password="password"
reg.1.lineKeys="6"
/>
I mostly followed the directions from here (I am using a self compiled asterisk, version 1.4.19.1 on Gentoo Linux, not trixbox)
http://www.sureteq.com/asterisk/polycom.htm
and used the following links for reference:
http://www.voip-info.org/wiki/view/polycom+trixbox
http://www.voip-info.org/wiki/view/Polycom+Phones
http://www.polycom.com/support/voice/soundstation_ip_series/soundstation_ip6000.html
http://blog.voipsupply.com/new-products/polycom-sip-firmware-31-released-whats-in-it-for-me
http://blog.voipsupply.com/voip-software/unleash-your-polycom-soundpoint-ip-phone%e2%80%a6introducing-the-polycom-productivity-suite-package
http://yum.trixbox.org/centos/5/RPMS/repodata/repoview/firmware-polycom-0-3.0.1-2.html
http://www.voip-info.org/wiki/view/Asterisk%40Home+Handbook+Wiki+Chapter+7#7224HowtouseProvisioningCentralBootServe
http://www.asteriskvoipnews.com/polycom/polycom_releases_soundstation_ip_7000_and_ip_6000_conference_phone.html
