Redirect wget output to screen (STDOUT)
Jan 25

wget is a great tool for grabbing web pages from the command line, but one issue is it downloads the file and saves to the local directory.  Some times you just want to see the output of what is retrieved.  To do this, use the following command:

wget -qO- http://www.mywebsite.com/file.htm

Piping Tar over SSH
Oct 25

I recently had the issue where I wanted to Tar/Gzip up a large directory but didn’t have the available space on the server, but I need to get it transfered over to another server.  So I came up with two options.  First, Tar/Gzip it and pipe it over SSH and create the tgz file on the remote host, or just pipe and extract it directly on the other host.

The first option, creating the tgz on the remote host can be accomplished by doing this

cd /my/path
tar czf – . | ssh remoteserver “cat > /new/path/file.tar.gz”

The second option, creating the tgz but extracting the contents directly on the remote host can be accomplished by doing this.

cd /my/path
tar czf – . | ssh remoteserver “cd /remote/path; tar xzf -”

Another thing you can do is if you want a path on a remote server but you want to pull it to the local server and extract it you can run the following

cd /my/path
ssh remote “cd /my/path; tar czf – .” | tar xfz -

BeanTownHost.com launches new website
Sep 14

We have launched a new website.  Make sure you check it out at www.beantownhost.com.  This time around we decided to try not to cram as much information in and instead try to keep the site nice and clean.  Also with the website launch we’ve officially launched our Twitter and Facebook accounts (we’ve had them for a while, just never used them).  Follow us on Twitter and Like Us on Facebook and maybe we’ll give our followers a special surprise.  More to come later

Grepping in a Windows World
May 31

Lately I’ve been doing more work on Windows platforms and I’ve been missing the Linux command line.  I’m a huge user of cat, sed, awk and most of all grep. I’m also a huge bash script writer to help with everyday issues.  Recently I started playing around with Windows PowerShell and so I’ll be starting to list PowerShell tips from time to time.  No I haven’t totally gone to the dark side, I’m still a huge Linux user, but PowerShell does seem like a nice option when you have to use Windows.

So, my latest issue is I needed to search through lots of logs to find an email address.  Normally I’d use grep to parse through the files.  Instead I opened up a Powershell prompt and used the following command

findstr /I my@email.com logfile.log

Findstr is just like grep and has a lot of the same options.  The /I tells it to be case-insensitive.  The my@email.com is what I’m looking for in logfile.log.  Here are the different settings that you can use:

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
[/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
strings [[drive:][path]filename[ ...]]

/B         Matches pattern if at the beginning of a line.
/E         Matches pattern if at the end of a line.
/L         Uses search strings literally.
/R         Uses search strings as regular expressions.
/S         Searches for matching files in the current directory and all
subdirectories.
/I         Specifies that the search is not to be case-sensitive.
/X         Prints lines that match exactly.
/V         Prints only lines that do not contain a match.
/N         Prints the line number before each line that matches.
/M         Prints only the filename if a file contains a match.
/O         Prints character offset before each matching line.
/P         Skip files with non-printable characters.
/OFF[LINE] Do not skip files with offline attribute set.
/A:attr    Specifies color attribute with two hex digits. See “color /?”
/F:file    Reads file list from the specified file(/ stands for console).
/C:string  Uses specified string as a literal search string.
/G:file    Gets search strings from the specified file(/ stands for console).
/D:dir     Search a semicolon delimited list of directories
strings    Text to be searched for.
[drive:][path]filename
Specifies a file or files to search.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C.  For example, ‘FINDSTR “hello there” x.y’ searches for “hello” or
“there” in file x.y.  ‘FINDSTR /C:”hello there” x.y’ searches for
“hello there” in file x.y.

Regular expression quick reference:
.        Wildcard: any character
*        Repeat: zero or more occurrences of previous character or class
^        Line position: beginning of line
$        Line position: end of line
[class]  Character class: any one character in set
[^class] Inverse class: any one character not in set
[x-y]    Range: any characters within the specified range
\x       Escape: literal use of metacharacter x
\<xyz    Word position: beginning of word
xyz\>    Word position: end of word

For full information on FINDSTR regular expressions refer to the online Command
Reference.

Rebooting Windows Machines Through Remote Desktop
Mar 11

With Windows XP, Vista, 7, and Windows Server 2003 and 2008 you now cannot shutdown the machine from the Start button when you are logged in via Remote Desktop (RDP).  To reboot the server run:

shutdown -t 0 -r -f

If you want to just shut it off, run (notice that -r is missing, this means it will not be rebooted):

shutdown -t 0 -f

The “-t 0″ tells the system to wait zero seconds be shutting down or rebooting.  You can change the zero to any number of seconds you want.  The “-f” tells the system to not prompt for confirmation.  So make sure you really want the server shut down or rebooted.

There are other options that you can use, you can see all the options on the Microsoft site here

What me, reboot? Never
Feb 22

I came across an excellent article the other day which talks about server rebooting.  I’ve followed the same practice for many years.  There are very few cases where you should reboot a server.  From experience I’ve actually seen server end up in a worse state because the server was rebooted.  Lesson, it’s always better to troubleshoot a running server, than to reboot and not be able to get into the operating system.

Leatherman: Don’t leave home without it
Dec 14

You’ve probably heard the Amex commercial where they say “Don’t leave home without it”.  Well, as a systems/network admin there are many tools that we use in our trade.  But over the years I’ve found that you should always carry a good multi-tool.  I’ve gone through 50 or 60 different ones, but recently (a couple years ago) found the ones made by Leatherman, the Leatherman Wave.  I have to say I’m extremely impressed with the quality that they put into their products.  Not to mention the fact that they have a 25 year guarantee on all their products.

The way I found out about them was a coworker of mine had one he purchased 10-15 years ago and recently broke.  He contacted Leatherman who replaced it.  No questions asked, they just replaced it.

Now I’ve had mine for only a few years, but it’s days like today that I forget mine when I really realize just how useful the tool is.

Fun with WIFI
Dec 1

Do you have people that connect to your WIFI without your permission?  This here’s a great hack to have a little fun with those people.  If someone connects that’s unauthorized, the first hack turns all their images upside-down.  The second hack makes all the images blurry.

Oh the fun I could have if I had spare time.

http://www.ex-parrot.com/pete/upside-down-ternet.html

My new best friend: RackTables
Nov 29

For years I’ve been using a piece of software that a friend wrote to help me manage servers, switches, routers, workstations, asset tracking, IP address management, and how all my devices are connected to each other.  It was a very good piece of software, but even though one of the features was to tell the system when the equipment is located (office, datacenter, etc), I couldn’t tell where in that location it was.  So I searched around and found quite a few open source applications that have popped up in the last few years, most of them were garbage, some of them were decent but even if they had a few of the features I wanted, they usually were missing key features.

That’s when I came across RackTables.  It’s simply amazing.  It let’s me keep track of all my hardware, keep track of my locations (office, datacenter, etc), keep track of where my hardware is located, how my hardware is interconnected, keeps track of all IP subnets and what’s allocated, and much more.  Anyone who’s responsible for managing servers, networks or datacenters should definitely check out RackTables.  There’s a great demo on their site.

With RackTables you can:

  • Have a list of all devices you’ve got
  • Have a list of all racks and enclosures
  • Mount the devices into the racks
  • Maintain physical ports of the devices and links between them
  • Manage IP addresses, assign them to the devices and group them into networks
  • Document your firewall and NAT rules
  • Describe your loadbalancing policy and store loadbalancing configuration
  • Attach files to various objects in the system
  • Create users, assign permissions and allow or deny any actions they can do
  • Label everything and even everyone with flexible tagging system
  • And, of course, you can access all that from anywhere in the world. All you need is a browser and internet connection!

Find out what version of Ubuntu
Nov 23

I’ve recently had to start using Ubuntu, I’m normally a RedHat/Fedora/CentOS guy.  I’ve been using RedHat or derivatives since 1995,  and while I’ve played a bit with other distro’s, I really dislike any of the Debian derivatives.  Anyway, I’ve been needing to do an audit of a bunch of linux servers and find out what version of Ubuntu they were running.  So here’s how I was able to find out.

On a command line type:

cat /etc/lsb-release

If you’re using the Gnome Desktop:

  1. Go to the Main Menu
  2. Click System, Administration, then select System Monitor
  3. Select the System tab.
  4. The version of Ubuntu will be displayed

« Previous Entries


Switch to our mobile site