Friday, July 01, 2011

301 permanent redirect using IIS

Here's a quick post describing how to place a 301 permanent redirect on a Microsoft IIS web server; specifically IIS6. On a Microsoft server, you can do a HTTP 301 Permanent Redirect two ways by using:
  • Javascript or Visual Basic code within your ASP page or
  • server administrative tools (the IIS management server console, iis.msc)
This is different from a Linux box, where you can use not only code or Apache to do the 301, but you can also take advantage of the .htaccess file for redirects.

Since the page I was trying to redirect was an HTML page, I wasn't able to put in any VB or Javascript code to perform the redirect. If I was using an ASP page, I could use some VB code like this:
< %@ Language=VBScript %>
< %
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, http://www.example.com
%>

Instead, I used the IIS management console to edit the attributes of the file to permanently redirect the destination location of the file. In the example below, I have right-clicked on the Properties of a web resource available to IIS (a file under the wwwroot), have input my other blog "http://crazedmuleproductions.blogspot.com" as the destination URL and checked "a permanent redirection for this resource."

Lo and behold, this works..I am redirected to the proper location (shown below). However, when I use Firebug to inspect how the server is doing the redirects, I find that Firebug shows a "301 error" for the response code:

To confirm that it wasn't Firebug misinterpreting the response from the server, I used this site to confirm the response code:
http://www.internetofficer.com/seo-tool/redirect-check/
Using the internetofficer site's redirect checker, I found that the redirect checker showed the same response from the IIS server. So Firebug wasn't reporting incorrect information.

Finally, after a bit of googling, it seems that the "301 error" is just the way that the IIS server responds to the 301 permanent redirection setting. This is confusing, non-standard terminology, as it caused me to think that I had implemented the redirect incorrectly. Perhaps Microsoft will fix this in the future.

anyway..Happy 4th of July!
TAG

Wednesday, April 27, 2011

s3cmd through a proxy

For those who use Amazon's EC2/S3 cloud.
sodo@linux-8u67:~/Downloads/s3cmd-1.0.0> ./s3cmd --configure

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3
Access Key: enter accesskey
Secret Key: enter secretkey

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/usr/bin/gpg]:

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can't be used if you're behind a proxy
Use HTTPS protocol [No]:

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't conect to S3 directly
HTTP Proxy server name [http-proxy]:
HTTP Proxy server port [8888]:

New settings:
 Access Key: enter accesskey
 Secret Key: enter secretkey 
 Encryption password:
 Path to GPG program: /usr/bin/gpg
 Use HTTPS protocol: False
 HTTP Proxy server name: http-proxy
 HTTP Proxy server port: 8888

Test access with supplied credentials? [Y/n] y
Please wait...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

Save settings? [y/N] y
Configuration saved to '/home/sodo/.s3cfg'

sodo@linux-8u67:~/Downloads/s3cmd-1.0.0> ./s3cmd ls
2011-04-05 19:03  s3://testbucket
2011-03-26 04:42  s3://trendtop

Yay! It works.
sodo

Also, I received this error message from YaST2 using SuSE Enterprise Linux 11 64-bit 11.1:
Problem: nothing provides python(abi) = 2.6 needed by s3cmd-1.0.0-4.1.i586

Resolution: install manually from http://s3tools.org/s3cmd

Reference
http://www.saltycrane.com/blog/2010/02/s3cmd-notes/

Sunday, April 17, 2011

resizing a linux partition using Parted Magic

I was running out of space on the root filesystem of my OpenSuSE 11.4 virtual machine. I needed a few extra gig, so I wanted to enlarge the root filesystem from 18GB to 22GB:
sfrase@linux-8u67:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 14G 4G 22% /
devtmpfs 372M 88K 372M 1% /dev
tmpfs 372M 1.1M 371M 1% /dev/shm
Thinking I could use Gparted, I stumbled upon something even easier..the Parted Magic OS. Parted Magic is a compilation of open source partitioning utilities in one smooth-looking OS in bootable iso format. The bootable iso is about 160MB and is available here:
http://partedmagic.com/doku.php?id=downloads

Overview
I had to do a few things to get the filesystem resized.
1) resized the virtual disk that VMware uses
2) booted the VM with the Parted Magic ISO in the virtual CD of the VM
3) ran GParted and expanded my filesystem
4) rebooted the system to see the expanded disk

Detail
I'll show you the steps in depth below:

In VMware Player settings, select the hard disk, click the Utilities link and press "Expand":


Specify a new maximum disk size:


After VMware resizes the virtual disk, I got a success message:


I mounted the ISO in the virtual CD drive:


Next, I booted the virtual machine. I pressed ESC (escape) while the vm is booting to display the boot menu:


I highlighted CDROM and press enter to start booting the Parted Magic iso:


Parted Magic has a really nice interface. Love the system monitors on the desktop!


Next, I double-clicked the icon labeled "partition editor". This is Gparted, the GNOME partition manager:


I double-clicked the filesystem I wanted to resize. In order to expand the size of the filesystem, I pulled the right tab in the graphic from its current position all the way to the right.


I clicked the resize button and saw the change I made:


I clicked Apply to confirm the changes:


It took a minute or two to resize the filesystem:


I checked out the steps the resize performs by clicking the little twisty:


Once resized, I rebooted the machine:


Now my disk has the extra 4GB of space that I needed! Hooray!
sfrase@linux-8u67:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 22G 14G 8G 22% /
devtmpfs 372M 88K 372M 1% /dev
tmpfs 372M 1.1M 371M 1% /dev/shm


Shrink
You can also shrink filesystems. For instance, I wanted to reduce the size of my root partition from 38GB to 7GB. Again, I used GParted and PartedMagic CD for the task.

Here's the Resize screen after I dragged the right arrow almost to the area on the filesystem that is used, as indicated by the yellow color:


Here's the screen while the job is in progress:


Once finished you'll see a message "All operations successfully completed." The job took about five minutes to complete.

So far, I've used GParted on ext3 and ext4 filesystems without issue.

Please, don't forget to donate a few dollars to the nice folks who compiled this very useful set of utilities.

TAG

Monday, April 11, 2011

weblogic 6.1 nastiness

I had to resurrect an old WebLogic 6.1 system today. Ooof! A conversion from IIS5 to IIS6. Went through quite a bit of h3ll.

1) Under Control Panel -> System -> Advanced -> Performance -> Data Execution Prevention had to be enabled for the specific WebLogic and java processes:
-beasvc
-java
-javac

Otherwise, I'd get errors in the Application Event Log and to the desktop.

See more here:
http://en.wikipedia.org/wiki/Data_Execution_Prevention#Windows

2) In IIS, the WebLogic ISAPI filter priority was set to *Unknown*. I resolved with help from Vivek's post here:
http://blogs.msdn.com/b/vivekkum/archive/2009/02/20/unknown-status-for-isapi-filter.aspx
-otherwise, IIS would hang

3) In IIS, the WebLogic DLLs need to be configured as Web Service Extensions and set to a status of Allowed

4) In IIS, unknown ISAPI extensions need to be Allowed
-otherwise, I'd get 404s from .wlforward

5) In IIS, the website needs to be run in IIS5 isolation mode
-otherwise, IIS would hang

6) The iisproxy.ini file needed to be copied to c:\weblogic
-otherwise, I'd get an HTTP 500 from .wlforward

7) Faulting application w3wp.exe, version 6.0.3790.3959, faulting module iisforward.dll
-caused by dll memory corruption trying to access Physical Address Extension memory
-resolved by adding /nopae to boot.ini
http://forums.iis.net/t/1158864.aspx
http://support.microsoft.com/kb/895575

Ugh!
TAG

Friday, April 08, 2011

rdp: ERROR: recv: Connection reset by peer

Strangely, the RDP (rdesktop) sessions to my Windows Servers were timing out within five minutes. I'd get an error like this:
Autoselected keyboard map en-us
ERROR: recv: Connection reset by peer


The Terminal Services Configuation on the destination server were set to timeout after an hour. So something was definetly amiss. Even more weird, when I exited GNOME and logged onto Enlightenment, the problem went away. So that meant the problem was with my window environment. Reading up here:
http://ubuntuforums.org/showthread.php?t=398447

To fix the problem, one guy had to change his keyboard in GNOME:


I changed my keyboard from Unknown to Microsoft Natural Keyboard Pro, restarted GNOME and voila..problem gone!

I love it when a plan comes together!
TAG

Saturday, April 02, 2011

what window manager am I running?

Recently, I've installed quite a few new Linux distributions as virtual machines. They all use different window managers and it is difficult to tell what window manager I have installed. The "wmctrl" program clears this fog. Run the command like this:
sodo@linux-nie4:~> wmctrl -m
Name: Metacity
Class: N/A
PID: N/A
Window manager's "showing the desktop" mode: OFF


Et voila! You have the name of your window manager. Also, you could grep your process list for a known window manager like metacity or compiz like so:
sodo@linux-nie4:~> pidof metacity
5134
sodo@linux-nie4:~> ps -ef | grep metacity
sodo 5134 4984 0 10:36 ? 00:00:01 /usr/bin/metacity
sodo 30798 5467 0 11:35 pts/0 00:00:00 grep metacity


Also, it might be helpful to know your X session setup. This can be determined by looking at your environment variables:
sodo@linux-nie4:~> printenv | egrep 'MANAGER|SESSION' | sort
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1UXtH7rCgE,guid=9b7438cbc749781f920116e54d973474
DESKTOP_SESSION=gnome
GDMSESSION=gnome
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
SESSION_MANAGER=local/linux-nie4:@/tmp/.ICE-unix/4984,unix/linux-nie4:/tmp/.ICE-unix/4984
WINDOWMANAGER=/usr/bin/gnome
XDG_SESSION_COOKIE=74cab8c1ad6aab7a0cf6c38f4d8dc6fa-1301754995.529512-1092139338
XSESSION_IS_UP=yes


A KDE Example
sodo@linux-z6tw:~> printenv | egrep 'MANAGER|SESSION' | sort
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-mzeA1Sx0fF,guid=43e3b1dcb893bbe684e0bdfe00001fe6
DESKTOP_SESSION=default
KDE_FULL_SESSION=true
KDE_SESSION_UID=1000
KDE_SESSION_VERSION=4
KONSOLE_DBUS_SESSION=/Sessions/1
SESSION_MANAGER=local/linux-z6tw:@/tmp/.ICE-unix/11242,unix/linux-z6tw:/tmp/.ICE-unix/11242
SHELL_SESSION_ID=985449ee0b7140008fe9978a32662d10
WINDOWMANAGER=/usr/bin/startkde
XDG_SESSION_COOKIE=6b050dcfcaf094a4a7c7a30e000002ae-1301545596.870464-842889003
XSESSION_IS_UP=yes

sfrase@linux-z6tw:~> wmctrl -m
Name: KWin
Class: kwin
PID: 11247
Window manager's "showing the desktop" mode: OFF


cool.
TAG

Wednesday, March 23, 2011

git behind a proxy

This gentleman's technique worked for me:
http://bardofschool.blogspot.com/2008/11/use-git-behind-proxy.html

In short..
* Plop the connect and proxy files somewhere
* Edit proxy to point to connect and reference your proxy
* Export the GIT_PROXY_COMMAND environment variable

To use like so:
[sodo@computer ~]$ export GIT_PROXY_COMMAND=/home/sodo/proxy
[sodo@computer ~]$ git clone git://github.com/datawrangling/trendingtopics.git
Cloning into trendingtopics...
remote: Counting objects: 2794, done.
remote: Compressing objects: 100% (860/860), done.
remote: Total 2794 (delta 1853), reused 2792 (delta 1853)
Receiving objects: 100% (2794/2794), 475.10 KiB, done.
Resolving deltas: 100% (1853/1853), done.
enjoy.
TAG

Tuesday, March 15, 2011

running ntp on linux in windows environment

Here's a quick entry I'm writing because I can't remember the few ntp commands to get time sync running on my Fedora box in my company's predominantly Windows environment.

Configure /etc/ntp.conf
Let's add a single time server to our /etc/ntp.conf file:
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server timeserv.corpdomain

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
#server 127.127.1.0 # local clock
#fudge 127.127.1.0 stratum 10

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys


Is the ntp daemon currently running on my box?
From the output of ntpq and the service command, I'd say no:
[sodo@computer ~]$ ntpq
ntpq> peers
ntpq: read: Connection refused
ntpq> assoc
ntpq: read: Connection refused
[sodo@computer ~]$ service --status-all | grep ntp
ntpd is stopped


Start up ntpd!
First, we'll configure ntpd to start at the various multiuser levels:
[sodo@computer ~]$ sudo chkconfig --list | grep ntp
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[sodo@computer ~]$ sudo chkconfig --levels 2345 ntpd on
[sodo@computer ~]$ sudo chkconfig --list | grep ntp
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off


Then, we'll start 'er up!
[sodo@computer ~]$ sudo service ntpd start
Starting ntpd: [ OK ]


Validate
Once started, we'll wait about ten minutes and then check ntpq to see if the ntpq is talking to the time server we configured in /etc/ntp.conf:
[sodo@computer ~]$ ntpq
ntpq> peers
remote refid st t when poll reach delay offset jitter
==============================================================================
*timeserve.corpdomain 192.168.62.30 5 u 71 128 377 0.448 19.236 24.240

ntpq> assoc

ind assid status conf reach auth condition last_event cnt
===========================================================
1 4341 967a yes yes none sys.peer sys_peer 7


Sweet! Looks like we're sync'd up!
TAG

Sunday, February 27, 2011

open sound control using touchOSC

Open Sound Control is a very cool technology, sort of an updated MIDI. With TouchOSC, you can send OSC messages over the network via WIFI to control OSC-aware softwares, like music recording software. I'm controlling the GForce Oddity software synth within Reaper in the video below.


Recording the audio/video from the mac to Cinelerra on my Linux box was a bit of a pain and took some work:
1) on mac: esd -public -promiscuous -bind mac -trust -tcp
2) on mac: esdrec -s mac | esdcat -s ogre
3) on linux:
gnome-sound-settings: hw
analog stereo output + digital stereo input
or
digital stereo output + digital stereo input (best for recording)
-input from microphone line in (for voice only) on Mackie Alt3-4
or
-input from mac monitor of m-audio digital stereo (null device)
or
-both if both are on Mackie Alt3-4

Alt 3-4 -> ch1/ch2 line in on M-Audio MobilePre

pavucontrol dialog settings
-output device: MobilePre analog speakers
-playback: null device from esound server created above
-record monitor (once Audacity/Cinelerra record monitor enabled):


If you'd like to download the Oddity layout and the Osculator settings, here they are:
Oddity Ipad Touch OSC Layout
Osculator Settings for the Above

More detail on ESD/PulseAudio here:
2011/02/pulseaudio-streaming-from-mac-to-linux.html

Wednesday, February 23, 2011

PulseAudio: streaming iTunes from the mac to linux

After beating my head against a wall for the past three days, I finally overcame my mental block and was able to get audio streaming from iTunes to my Linux box. This was to help facilitate the production of a video that will be the subject of my next post.

For this project though, I had to jump through a good number of hoops to get the streaming going. The side benefit was that the project allowed me to educate myself on the benefits of PulseAudio, which I had previously believed to be a piece of crap that only served to bollucks your workstation's audio. Now that I have a better understanding of PulseAudio, I've changed my mind.

Here's an article on why you might want to care about PulseAudio.

Still, the implementation of audio streaming over the network using PulseAudio is somewhat programmer-centric and thus, it is not easy. The faint of heart might choose to simplify their lives and buy one of these Apple AirPort Express with Air Tunes.

This post will give an overview of the tools used to stream audio from a Mac running the Enlightment Sound Daemon (ESD) sound server to any PC running PulseAudio. I'll include links to the more detailed resources, rather than repeating information already available on the web.

Overview
Here's an overly simplified signal chain of what's happening to make this work.

On the Mac
iTunes -> Soundflower audio driver -> eSound daemon -> Linux box

On the Linux box
audio stream from Mac -> PulseAudio -> ALSA -> PC's audio interface -> speakers

It's a bit of a funky setup, over-explained semi-coherently here:
http://blog.haynberg.de/?p=14
and here:
https://labitat.dk/wiki/Apple/Mac_OS_X#PulseAudio

The Process
On the Mac
Prerequisites: iTunes and esound macport
1) install Soundflower, the audio driver that ESD will use
2) setup an ESD sound server using ESD and open a network connection for the Linux box
3) format and forward the sound onto the Linux box

On the Linux box
Prerequisites: pulseaudio, paprefs(pa prefs), pavucontrol(pa volume control), pulseaudio-utils
4) make sure paprefs is setup properly
5) start pulseaudio
6) verify that data is being sent over the network

Detailed Steps
On the Mac
1) install Soundflower and select Soundflower 2ch as your System Prefs -> Sound -> Output and Input
Best explained here:
https://labitat.dk/wiki/Apple/Mac_OS_X#PulseAudio

For debugging purposes, enter the commands below in separate terminals. In both cases, if the commands execute correctly, the command prompt should not return to you.

2) setup an audio server using the Enlightment Sound daemon (ESD) and open a port for your Linux box to connect to. To do this, open a terminal and run a command similar to this:
mac:~ sodo$ esd -tcp -bind [mac]:16001 -public -promiscuous -trust
- accepting connections on port 16001


3) format and forward the sound to the Linux box (make sure PA is running on the Linux box first):
esdrec -s [mac]:16001 esdcat -s [linux]

On the Linux box
4) make sure paprefs is setup properly
There's more detail at this link, but here are the prefs you want to set:



5) start (or kill and restart) pulseaudio
[sodo@ogre ~]$ pulseaudio -k
[sodo@ogre ~]$ pulseaudio --start
[sodo@ogre ~]$ ps -ef grep pulse
sodo 3860 1 0 00:06 ? 00:00:01 /usr/bin/pulseaudio --start --log-target=syslog
sodo 3862 3860 0 00:06 ? 00:00:00 /usr/libexec/pulse/gconf-helper
sodo 5298 5045 0 00:09 pts/4 00:00:00 grep pulse


Here are some other notes regarding pacmd, the command line interface to PulseAudio.

pacmd list-modules
>>> [sodo@ogre ~]$ pacmd list-modules
Welcome to PulseAudio! Use "help" for usage information.
>>> 23 module(s) loaded.
index: 4
name:
argument:
used: 1
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "ALSA Card"
module.version = "0.9.21"


pacmd list-sinks
[sodo@ogre ~]$ pacmd list-sinks
Welcome to PulseAudio! Use "help" for usage information.
>>> 1 sink(s) available.
* index: 0
name:
driver:
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL LATENCY DYNAMIC_LATENCY
state: RUNNING
..


Once you've verified the daemon is up, look for a sound source in the PulseAudio Volume Control app, Playback tab:

I'm not sure why the stream from the mac is listed as null.

6) verify that data is being sent over the network
First, I look at netstat. Netstat is telling me that my Linux box (.8) on port 16001 has an established connection to my Mac (.12) on port 62356:
[sodo@ogre ~]$ netstat -na grep \.12
tcp 0 0 192.168.1.8:16001 192.168.1.12:62536 ESTABLISHED


Most likely, the Linux box initiated the connection from 16001 and the Mac responded back by opening port 62356. I am not sure how ESD works in this regard either, as the ports identified on the ESD command line would suggest that the Mac should have port 16001 open and not the Linux box. Weirdness.

And make sure access to port 16001 is not disabled on the bloody firewall, either local on each box or a remote firewall between the machines!  I use an exclamation point here because this got me twice when I was setting this whole thing up:


Also, I use iptraf to show me the volume of my network traffic. Here we see the lion's share of data is coming from .12 (my Mac) and .8 (my Linux box) is shuttling a lot less data. Observed over time, I see that the Linux box sends about 1% of the audio stream's data quantity simply to manage the connection:


Lastly, you could take a look at the files PulseAudio keeps open by looking at TCP port 16001:
[sodo@ogre ~]$ lsof -i TCP:16001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
pulseaudi 3860 sfrase 30u IPv6 48581 0t0 TCP *:16001 (LISTEN)
pulseaudi 3860 sfrase 31u IPv4 48582 0t0 TCP *:16001 (LISTEN)
pulseaudi 3860 sfrase 36u IPv4 49374 0t0 TCP ogre:16001->mac:50314 (ESTABLISHED)



PulseAudio is quite cool. I think it works a bit more consistently if you have two machines with PulseAudio on both ends. I've tried this and it works very well. Here's an article on how to stream music between two computers using only PulseAudio:
http://ubuntuforums.org/showthread.php?p=10374057

Of course, I needed to stream from the Mac and there is no port of PulseAudio for the Mac. Still good stuff this PulseAudio, once you understand more about it.

Example of this working


Update 2012/12/03
After upgrading both my Fedora box from F15 to F17 and upgrading my Mac from Leopard to Lion, pulseaudio streaming broke.  I had to do the following:
1) on the mac, download and install the latest version of SoundFlower (reboot necessary)
http://code.google.com/p/soundflower/
2) on the linux box, download and install pulseaudio-module-zeroconf (above and beyond the normal pulseaudio installation)
3) on the linux box, make sure iptables is turned off (just for testing purposes..reenable with an exception for port 16001).  On Fedora 17, this would be:
systemctl stop iptables.service

Updated Process
Also, I streamlined my process for getting this to work.  Try the below steps in this same order:
1) on the mac, make sure both input and output is set to SoundFlower (2CH)
2) on the mac, stream eSound to a public port, like so:
esd -tcp -bind ::0
3) on linux, make sure pulseaudio is running and that paprefs is set (as above)
4) on the mac, open an eSound stream to the Linux box
esdrec -s ::0 | esdcat -s
5) you should then see a nice volume control named "null" appear under the Playback tab in the PulseAudio volume control (pavucontrol)

Good luck!
TAG

Other References
PulseAudio Sink, Streams, Clients
http://wm161.net/2007/06/24/how-pulseaudio-made-my-openhouse-awesome/

How to: AirTunes without AirPort
http://blog.haynberg.de/?p=14

network audio between mac and linux 1&2
http://community.livejournal.com/evan_tech/241437.html
http://community.livejournal.com/evan_tech/241887.html

Remote sound playback through a Nokia 770
http://taint.org/2008/02/03/222043a.html

Using the PulseAudio sink
https://labitat.dk/wiki/Apple/Mac_OS_X#PulseAudio

PulseAudio Wiki
http://pulseaudio.org/wiki/PerfectSetup%20

Linux: exporting audio and video
http://blog.smr.co.in/linux/linux-exporting-audio-and-video/

burning an iso to cd using cdrecord

The past few years, as Linux distributions get larger, I've been burning more DVDs than CDs. So my CD burning chops have lapsed. I recently wanted to fire up a Live version of Fedora 14 for some PulseAudio experiments, so I downloaded the ISO which came CD-sized.

*** Update 3/4/2013 ***
I used Brasero on my Fedora 17 and that burned a copy of Clonezilla quite nicely.  Hooray!  Of course, my clone didn't work, but that's another story.
*** end update ***

Troubles
First, for convenience sake, I burned the first F12 Live CD using my Macbook's Disk Utility. But when I plopped the CD into my desktop, the boot never finished and the DVD player kept humming for about 45 minutes. Something definitely wrong there. Testing on a second PC yielded the same result.

Researching Google, I found that other people had similar problems if the application they burned the CD with burned the CD at too fast a rate. This causes the laser in the DVDs to have difficulty reading the source data. Guess I'll have to reburn that bad boy. I tossed that CD out and thought I'd give Linux tools a try. I didn't know this next stage was going to turn into a two-hour extravaganza.

Burning an ISO in Linux is Easy, No?
Starting from scratch on my Fedora 12 box, I popped in a blank CD and good old Nautilus CD/DVD creator pops up:


I dragged and dropped the ISO onto the blank CD:


Selected "Burn contents"


And POOF..nautilus immediately craps out with a buffer error in dmesg:
[ 78.116252] Buffer I/O error on device sr0, logical block 0

OK, so I guess I won't use that. Next, I try Brasero:


Same result. OK. So let me try cdrecord, from the CDR toolset. Things seems to go well and then ba-BANG:
wodim: Cannot fixate disk

What the? Thinking the media was bad, I yanked it out and put a new CD in the drive. Same result. OK, this is getting tiresome. Time to Google:
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=wodim:+Cannot+fixate+disk

Surfing around does not yield much usable information; however, one post hinted at a drive or BIOS issue. I rebooted and checked the BIOS..nothing far from standard there. So I figured I'd run cdrecord again using the -dummy switch that means "do everything the burn will do, except turn off the laser." So I did this, again using another CD. If you're counting, that's three.

I first ran a scanbus:
[sodo@computer ~]$ cdrecord -scanbus
scsibus2:
2,0,0
200) 'HL-DT-ST' 'DVD+-RW GH50N ' 'B103' Removable CD-ROM
2,1,0
201) *
2,2,0
202) *
2,3,0
203) *
2,4,0
204) *
2,5,0
205) *
2,6,0
206) *
2,7,0
207) *


Then I ran cdrecord with the dummy parameter:
[sodo@computer ~]$ cdrecord -v -tao driveropts=burnfree -dummy -dev=2,0,0 Downloads/Fedora-14-i686-Live-Desktop.iso
TOC Type: 1 = CD-ROM

wodim: Operation not permitted.
Warning: Cannot raise RLIMIT_MEMLOCK limits.

scsidev: '2,0,0'

scsibus: 2 target: 0 lun: 0

WARNING: the deprecated pseudo SCSI syntax found as device specification.

Support for that may cease in the future versions of wodim. For now,
the device will be mapped to a block device file where possible.
Run "wodim --devices" for details.
Linux sg driver version: 3.5.27

Wodim version: 1.1.11
Driveropts: 'burnfree'
SCSI buffer size: 64512
Device type : Removable CD-ROM

Version : 5
Response Format: 2

Capabilities :
Vendor_info : 'HL-DT-ST'
Identification : 'DVD+-RW GH50N '

Revision : 'B103'

Device seems to be: Generic mmc2 DVD-R/DVD-RW.

Current: 0x0009 (CD-R)

Profile: 0x0012 (DVD-RAM)

Profile: 0x0011 (DVD-R sequential recording)
Profile: 0x0015 (DVD-R/DL sequential recording)
Profile: 0x0016 (DVD-R/DL layer jump recording)

Profile: 0x0014 (DVD-RW sequential recording)
Profile: 0x0013 (DVD-RW restricted overwrite)
Profile: 0x001A (DVD+RW)
Profile: 0x001B (DVD+R)
Profile: 0x002B (DVD+R/DL)
Profile: 0x0010 (DVD-ROM)
Profile: 0x0009 (CD-R) (current)
Profile: 0x000A (CD-RW) Profile: 0x0008 (CD-ROM)
Profile: 0x0002 (Removable disk)

Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).

Driver flags : MMC-3 SWABAUDIO BURNFREE

Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R96R

Drive buf size : 1053696 = 1029 KB

Beginning DMA speed test. Set CDR_NODMATEST environment variable if device
communication breaks or freezes immediately after that.
Drive DMA Speed: 16168 kB/s 91x CD 11x DVD

FIFO size : 4194304 = 4096 KB

Track 01: data 686 MB

Total size: 787 MB (78:03.12) = 351234 sectors

Lout start: 788 MB (78:05/09) = 351234 sectors
Current Secsize: 2048

ATIP info from disk:

Indicated writing power: 5 Is not unrestricted Is not erasable Disk sub type: Medium Type A, high Beta category (A+) (3) ATIP start of lead in: -11634 (97:26/66)
ATIP start of lead out: 359846 (79:59/71)
Disk type: Short strategy type (Phthalocyanine or similar)

Manuf. index: 3

Manufacturer: CMC Magnetics Corporation

Blocks total: 359846 Blocks current: 359846 Blocks remaining: 8612
Speed set to 8468 KB/s

Starting to write CD/DVD at speed 48.0 in dummy TAO mode for single session.

Last chance to quit, starting dummy write in 0 seconds. Operation starts.

Waiting for reader process to fill input buffer ... input buffer ready.

Starting new track at sector: 0

Track 01: 686 of 686 MB written (fifo 100%) [buf 91%] 49.9x.

Track 01: Total bytes read/written: 719323136/719323136 (351232 sectors).
Writing time: 143.394s

Average write speed 32.7x.
Min drive buffer fill was 87%

Fixating...

WARNING: Some drives don't like fixation in dummy mode.

Fixating time: 22.123s

wodim: fifo had 11331 puts and 11331 gets.

wodim: fifo was 0 times empty and 6563 times full, min fill was 85%


OK! So this time, the "fake" burn worked! That's promising. I then ran the "real" burn (same command without the -dummy parameter) and prayed that it would work:
[sodo@computer ~]$ cdrecord -v -tao driveropts=burnfree -dev=2,0,0 Downloads/Fedora-14-i686-Live-Desktop.iso
...
Starting to write CD/DVD at speed 48.0 in real TAO mode for single session.

Last chance to quit, starting real write in 0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.

Performing OPC...

Starting new track at sector: 0

Track 01: 686 of 686 MB written (fifo 100%) [buf 91%] 49.7x.

Track 01: Total bytes read/written: 719323136/719323136 (351232 sectors).

Writing time: 149.247s

Average write speed 31.4x.
Min drive buffer fill was 87%

Fixating...

Fixating time: 22.165s

wodim: fifo had 11331 puts and 11331 gets.

wodim: fifo was 0 times empty and 6552 times full, min fill was 84%.


Ho HO! It worked!! Fabulous. But why?

It seems I made two changes that could have an effect:
1) I rebooted the computer
2) I used a different disc

My bet is on #2. But if you think differently, let me know. I'm just glad to having a working process for burning ISOs to a CD!

Cheers,
TAG

Tuesday, February 08, 2011

fun (?) with Enlightenment window manager

As much as I'm used to it, I've finally bored of Metacity, the default window manager in Fedora. Metacity is very nice if you live in the Windows world from 9-5 like I do..the keybindings are very similar. So I decided to upgrade..

For the past three days, I've spent a good amount of time with Enlightenment, a visually striking, light(-er)weight window manager for Linux (and other OSs). The initial install was simple, as Enlightenment is in Fedora's repos:
[sodo@computer ~]$ sudo yum info enlightenment
[sudo] password for sodo:
Loaded plugins: presto, refresh-packagekit
Installed Packages
Name : enlightenment
Arch : x86_64
Version : 0.16.999.050
Release : 5.fc12
Size : 10 M
Repo : installed
From repo : fedora
Summary : Highly optimized and extensible desktop shell
URL : http://enlightenment.org/p.php?p=about/e17&l=en
License : MIT
Description : Enlightenment 0.17 is desktop shell based on Enlightenment Foundation
: Libraries. It's highly optimized and provides extensive theming capabilities.
: A Desktop shell means it's a window manager plus a file manager, plus
: configuration utilitys all in one. It works reasonably fast even on old and low
: range computers, providing eye-candy environment.


Documentation
As a new user, I've found the documentation and resources for Enlightenment to be difficult to navigate. The best source for a new user is to visit the Wiki and choose "User Guides":
http://trac.enlightenment.org/e/wiki

Module Installation
Also, module installation is buried in the Wiki:
http://trac.enlightenment.org/e/wiki/Gadgets

Update 2011/02/12
I've since installed from source to give me the latest and greatest. The source install was relatively painless downloading the latest E packages from here:
http://www.enlightenment.org/p.php?p=download&l=en

Install the sources in this order:
eina-1.0.0
eet-1.4.0
evas-1.0.0
ecore-1.0.0
embryo-1.0.0
edje-1.0.0
efreet-1.0.0
e_dbus-1.0.0
eeze-1.0.0
enlightenment-0.16.999.55225


For each of the sources, after extracting the source code via "tar xvfz ", run:
./autogen
make
sudo make install


The only occasional problem that I had was a missing library here and there, like liblua. I resolved this by installing the -devel package. A second problem I encountered was that I needed to set:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
***end update***

Enlightenment is very cool, very pretty, but it takes quite a bit of getting used to especially if you're coming from the world of Metacity.

I think I like it, but the jury is out due to all the configuration I've had to do.

A battle, as always
So here are a few of the problems I encountered, and some workarounds:
1) ALT-PrntScreen didn't work

I had to rebind the PrtScn key to gnome-screenshot, the default Gnome screen capture program.

Binding keys
The key bindings interface in Enlightenment is a little funky. You get there by clicking on the desktop, go to Settings, Settings Panel, Input category, Key Bindings:


The left part of the screen is the key and the right hand side shows the Action you want to perform. In my case, ALT+Print was not in the list, so I first had to Add Binding. Then I needed to bind the key to an action, which was to Launch a Command:
/usr/bin/gnome-screenshot -w


The -w parameter screencaps a single window. If you leave off the -w parameter, your entire desktop will be screencapped to a PNG file. Once I created this key binding, all was well and I was able to capture screens again.

2) ALT-space to maximize/restore windows was not bound to anything

Again, I had to bind this command to a Window:State:


The nice thing about the Maximize window state is that it toggles between Maximize and Restore (or Unmaximize in the Enlightenment world).

3) Icons for some of the programs I selected for my Icon Bar were missing:


I had to go and find individual icons by right-clicking on the space in the icon bar, select Change Icon Properties, select Icon, and navigate to the following directory:
/usr/share/icons/apps/scaleable

You can also find icons in any of the sized directories; for example:
/usr/share/icons/apps/32x32


I had to do this for Google Chrome, gnome-terminal, vmware player and my nvidia settings. I'm surprised that Enlightenment did not automatically find these for some of the more popular programs.

4) the Shelf's icon bar seems to start programs in their own environment separate from your user environment

I found this out because when I started Google Chrome in Enlightenment, Google Chrome no longer respected any of my proxy settings. The workaround was to create a simple shell script that exports my proxy environment variables and starts Chrome:
[sodo@computer ~]$ cat googleStartup.sh
#!/bin/bash
export http_proxy=http://http-proxy:8080/
export https_proxy=http://http-proxy:8080/
export no_proxy=localhost,127.0.0.0/8
/opt/google/chrome/google-chrome &


I then put that script in the Executable section of the icon. Don't forget the ampersand on the end of the command. If you don't have it, you may see an Enlightenment dialog popup saying something like "Enlightenment was unable to run the application..the app failed to start" when exiting out of the app.

5) The "Remember" feature:

..to remember size, position and settings of a windowed program (in this case, gnome-terminal) plain ol' just doesn't work. Haven't got a workaround for this yet.

Other bothersome things I have yet to fix
1) it is meant as a convenience, but it is irritating when the cursor jumps to the Save dialog
* this was corrected via Settings -> Settings Panel -> Windows -> Window Focus -> Advanced -> uncheck "Slide pointer to a new focused window"


2) desktop switches to the adjacent one when your mouse is next to a desktop's far edge
* this was corrected via Settings -> Settings Panel -> Input -> Edge Bindings and removing the binding for the Right Edge. Erg!!


3) ctrl-shift left or right does not select text, it brings you to the adjacent desktop
* ARGH..still no fix

4) clicking on an application does not make the applications in front of the clicked application disappear..erg!
* this was corrected via Settings -> Settings Panel -> Windows -> Window Focus -> "Click Window to Focus".


5) I miss the GNOME system monitor panel widget. Weep.


It's always a tough row to hoe in the Linux world..nothing great or tasty or beautiful comes without some work.

Keep you posted..
TAG

References
E User Guide
http://jeffhoogland.blogspot.com/2010/10/e17-basics-faq.html
http://jeffhoogland.blogspot.com/2010/12/more-enlightenment-faq.html
good info on features and keybindings of Metacity: https://github.com/tthurman/metacity
themes http://exchange.enlightenment.org/

Tuesday, February 01, 2011

projectM visualizer

I've been looking for a decent visualization software for Linux for quite some time. In my search, I stumbled upon this neat gadget, essentially a visualizer in a box:
http://www.milkymist.org/

I didn't really need all that. But further reading and a hop onto the forums of the Milkymist site gave me a lead. One of the folks on the user boards kindly turned me onto projectM, a visualizer modeled off of MilkDrop.

The good news is that I got projectM running and it seems to work very well:

Of course, the install wasn't without its difficulties. I had a few hurdles, the primary one self-imposed because I didn't want to spend time building from source. I was in luck: my current version of Fedora (12, x86-64) had the projectM libs in the updates repo:
[sodo@ogre ~]$ rpm -qa | grep projectM*
projectM-jack-2.0.1-2.fc12.x86_64
libprojectM-2.0.1-7.fc12.x86_64
libprojectM-qt-2.0.1-2.fc12.x86_64
projectM-pulseaudio-2.0.1-3.fc12.x86_64
projectM-libvisual-2.0.1-2.fc12.x86_64


The next limitation was that the audio apps that projectM works with that utilize libvisual were limited in my repository: XMMS and Amarok only. And the XMMS in my repo did not have the projectM-xmms build. Thus Amarok was my only choice.

Once I got Amarok installed, I needed to reconfigure it to send its audio through Pulse and not plain ALSA. I already had alsa-plugins-pulseaudio installed, but I had no way to control Pulseaudio, so I had to install pavucontrol. Once that was done, good to go man! Running my favorite tunes with visuals! I have yet to customize it, but some nice features seem to be possible:
http://ubuntuforums.org/showthread.php?t=749793

And I am impressed with Amarok. Really fast search, easy to create and navigate playlists, search playlists and configurable interface:


Start projectM
projectM-pulseaudio

Controls for projectM
m - brings up a menu
f - toggles fullscreen on/off
l - "locks" to a particular preset
y - toggles shuffle mode
n - next preset
p - previous preset
r - selects random preset

F1 - Help menu
F2 - Toggles song title on/off (doesn't work in libvisual or pulseaudio as far as I can tell)
F3 - Toggle preset name on/off
F4 - Toggel rendering info on/off
F5 - Shows fps


Hooray!

Monday, January 24, 2011

installing flash 10.2 preview 3 64-bit on Fedora 14 x86-64

This is a quick tech note for myself.

1) download the flash 10.2 preview 3 build from here:
http://labs.adobe.com/downloads/flashplayer10_square.html

2) follow install instructions from here:
http://fedoraproject.org/wiki/Flash

3) watch out for MP3 audio bug (usually seen with YouTube vids)
http://fedoraproject.org/wiki/Common_F14_bugs#flash-64-sound

Workaround (thanks Linus!) here: https://bugzilla.redhat.com/show_bug.cgi?id=638477#c55

These install instructions work. Happily, they also get Flash to work in Chrome on Fedora 14.

TAG

Wednesday, January 19, 2011

ubuntu vm networking weirdness

Over the past week, I've been working quite a bit with Ubuntu 10.04 and VMware. Two problems confronted me:
1) /etc/resolv.conf was getting overwritten
2) /etc/network/interfaces was missing my eth0 network interface

Number One
The first problem was more easily solved than the second issue. What I did to resolve this issue was to edit /etc/dhcp3/dhclient.conf and add the following line:
supersede domain-name-servers [server1],[server2],etc;
(yes, supersede is misspelled)

Number Two
The second problem was a little more esoteric. What I found was that the network interface of my Ubuntu VM kept getting renamed (from eth0 to eth1 and then eth2). The cycling interface names may be caused by moving the VM to different machines. This is because Ubuntu will remember the MAC address of the first machine it was installed on. Ifconfig can see the newly named interfaces, but the ifup and ifdown commands to start and stop the network interfaces cannot see the new names. Ifup and ifdown rely upon entries in /etc/network/interfaces.

In order for ifup and ifdown to see eth0, I added the interface back into /etc/network/interfaces with the following lines:
auto eth0
iface eth0 inet dhcp


By the way, you can use a second command to restart a network interface:
sudo invoke-rc.d networking restart

Back to the original problem, that of the switching network interface names. Ubuntu uses the udev service to detect hardware. So, the solution was to either edit /etc/udev/rules.d/70-persistent-net.rules or delete it and have udev the system regenerate the file. As deleting the file was easier, I opted for that method. After deleting the file, I reboot the vm and voila, my eth0 interface was back.

all in a good days work,
TAG

Reference
http://serverfault.com/questions/63103/newsid-program-for-linux
http://en.wikipedia.org/wiki/Udev

Tuesday, January 18, 2011

fun with nmap

I left a Linux virtual machine on at work, but forgot to write down the IP address. So I thought I'd use nmap to figure out what IP the machine had based upon the services running on it. First though, I wanted to familiarize myself with the basic nmap commands.

The -A option seemed the best choice for a first time user. -A enables host operating system and version detection, script scanning and a traceroute. For my local machine, the output looks like this:
[sodo@ogre ~]$ nmap -A localhost

Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-18 18:23 EST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00053s latency).
rDNS record for 127.0.0.1: ogre
Not shown: 993 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.3 (protocol 2.0)
ssh-hostkey: 1024 a3:bd:bf:bd:bd:6a:64:1a:f8:2d:11:56 (DSA)
_2048 77:8d:ab:86:98:30:05:28:41:53:30:78:db:a2:f7:9c (RSA)
80/tcp open http Apache httpd 2.2.15 ((Fedora))
_html-title: Test Page for the Apache HTTP Server on Fedora
111/tcp open rpcbind
rpcinfo:
100000 2,3,4 111/udp rpcbind
100024 1 34022/udp status
100000 2,3,4 111/tcp rpcbind
_100024 1 58402/tcp status
443/tcp open ssl/http Apache httpd 2.2.15 ((Fedora))
_html-title: Test Page for the Apache HTTP Server on Fedora
631/tcp open ipp CUPS 1.4
888/tcp open ssl/http 3ware 3DM2 Serial RAID http config 2.0
_sslv2: server still supports SSLv2
_html-title: 3ware 3DM2 - ogre - Summary
3306/tcp open mysql MySQL 5.1.47
mysql-info: Protocol: 10
Version: 5.1.47
Thread ID: 16
Some Capabilities: Long Passwords, Connect with DB, Compress, ODBC, Transactions, Secure Connection
Status: Autocommit
_Salt: i:$CfYg}]azzsSZ1(;1#
Service Info: Device: storage-misc


Not that I didn't know this information, but it is interesting that you can find out quite a bit about a machine just by doing a portscan with nmap. In the example above, I can see that I have the following ports open and available (at least to the localhost):
-port 22 (SSH)
-port 80 (HTTP or the apache daemon)
-port 111 (RPC)
-port 443 (HTTPS via apache again)
-port 631 (CUPS, the linux printing system)
-port 888 (3Ware RAID web configuration tool)
-port 3306 (mysql web-based configuration utility)


Cool. Now if I change nmap to use the IP of my workstation instead of the loopback (localhost) address, you'll see that some of the information that was available at the localhost is not available at the proper IP of the box:
[sodo@ogre ~]$ nmap -A 192.168.1.8

Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-18 18:49 EST
Nmap scan report for ogre (192.168.1.8)
Host is up (0.00055s latency).
Not shown: 994 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.3 (protocol 2.0)
ssh-hostkey: 1024 a3:d6bf:bd:bd:6a:64:1a:f8:2d:11:56 (DSA)
2048 77:8d:ab:86:98:30:05:28:41:53:30:78:db:a2:f7:9c (RSA)
80/tcp open http Apache httpd 2.2.15 ((Fedora))
_html-title: Test Page for the Apache HTTP Server on Fedora
111/tcp open rpcbind
rpcinfo:
100000 2,3,4 111/udp rpcbind
100024 1 34022/udp status
100000 2,3,4 111/tcp rpcbind
_100024 1 58402/tcp status
443/tcp open ssl/http Apache httpd 2.2.15 ((Fedora))
_html-title: Test Page for the Apache HTTP Server on Fedora
888/tcp open ssl/http 3ware 3DM2 Serial RAID http config 2.0
_html-title: 3ware 3DM2 - ogre - Summary
_sslv2: server still supports SSLv2
3306/tcp open mysql MySQL (Host blocked because of too many connections)
Service Info: Device: storage-misc


Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 26.12 seconds


Here is another device on my network, a Motorola NIM 100 ethernet over cable bridge that actually has telnet and a web service up and available:
[sodo@ogre ~]$ nmap -A 192.168.1.3

Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-18 18:00 EST
Nmap scan report for 192.168.1.3
Host is up (0.00070s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
23/tcp open telnet Linux telnetd
80/tcp open http Boa httpd
robots.txt: has 1 disallowed entry
_/
_html-title: Ethernet Coax Bridge - Login
Service Info: OS: Linux

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.39 seconds


Note that only two ports are open and available on the real IP of the box. Also, it is interesting that nmap shows "Service Info: OS: Linux" on the real IP address. You can use the -p switch to scan for a particular port on a device:
[sodo@ogre ~]$ nmap -p 80 -A 192.168.1.3

Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-18 19:12 EST
Nmap scan report for 192.168.1.3
Host is up (0.0015s latency).
PORT STATE SERVICE VERSION
80/tcp open http Boa httpd
robots.txt: has 1 disallowed entry
_/
_html-title: Ethernet Coax Bridge - Login


The verbose (-v) switch to that last command will display exactly what nmap is doing..ping, DNS lookup, port connections, service scanning, script scanning, latency, count of closed ports and a summary of how many hosts nmap scanned and how long the scan took:
[sodo@ogre ~]$ nmap -v -A 192.168.1.3

Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-18 18:00 EST
NSE: Loaded 36 scripts for scanning.
Initiating Ping Scan at 18:00
Scanning 192.168.1.3 [2 ports]
Completed Ping Scan at 18:00, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 18:00
Completed Parallel DNS resolution of 1 host. at 18:00, 0.03s elapsed
Initiating Connect Scan at 18:00
Scanning 192.168.1.3 [1000 ports]
Discovered open port 80/tcp on 192.168.1.3
Discovered open port 23/tcp on 192.168.1.3
Completed Connect Scan at 18:00, 1.11s elapsed (1000 total ports)
Initiating Service scan at 18:00
Scanning 2 services on 192.168.1.3
Completed Service scan at 18:00, 6.06s elapsed (2 services on 1 host)
NSE: Script scanning 192.168.1.3.
NSE: Starting runlevel 1 (of 1) scan.
Initiating NSE at 18:00
Completed NSE at 18:00, 0.04s elapsed
NSE: Script Scanning completed.
Nmap scan report for 192.168.1.3
Host is up (0.00098s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
23/tcp open telnet Linux telnetd
80/tcp open http Boa httpd
robots.txt: has 1 disallowed entry
_/
_html-title: Ethernet Coax Bridge - Login
Service Info: OS: Linux

Read data files from: /usr/share/nmap
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.88 seconds


With this basic information about a single host, I graduated to scanning the network using the CIDR notation for network subnetting. I left out the above machines in the output below. Also, before I did the nmap, I started a Mac and an old XP box that I had in the environment, just to see what a really insecure Windows machine looks like.
[sodo@ogre ~]$ nmap -A 192.168.1.0/24

Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-18 18:46 EST
Nmap scan report for mac (192.168.1.12)
Host is up (0.0085s latency).
Not shown: 500 closed ports, 494 filtered ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.2 (protocol 1.99)
_sshv1: Server supports SSHv1
ssh-hostkey: 2048 c:c4:b6:69:6c:4e:27:5c:5a:fe:fe:09 (RSA1)
2048 f1:ce:c0:3c:a0:83:db:24:0c:7d:8a:ca:48:41:ea:44 (DSA)
_2048 db:20:90:c5:5a:bc:3d:ea:cd:12:7b:17:03:79:6b:ad (RSA)
88/tcp open kerberos-sec Mac OS X kerberos-sec
548/tcp open afp Apple AFP (name: MACLTSODO; protocol 3.3; Mac OS X 10.5)
2170/tcp open tcpwrapped
49152/tcp open tcpwrapped
Service Info: OS: Mac OS X

Nmap scan report for xp (192.168.1.89)
Host is up (0.050s latency).
Not shown: 990 closed ports
PORT STATE SERVICE VERSION
25/tcp open smtp Microsoft ESMTP 6.0.2600.2180
80/tcp open http Microsoft IIS webserver 5.1
_html-title: Site doesn't have a title (text/html).
_http-favicon:
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn
443/tcp open https?
445/tcp open microsoft-ds Microsoft Windows XP microsoft-ds
1025/tcp open msrpc Microsoft Windows RPC
1026/tcp open msrpc Microsoft Windows RPC
1027/tcp open msrpc Microsoft Windows RPC
3389/tcp open microsoft-rdp Microsoft Terminal Service
Service Info: Host: computer; OS: Windows

Host script results:
smb-os-discovery:
OS: Windows XP (Windows 2000 LAN Manager)
Name: WORKGROUP\COMPUTER
_ System time: 2011-01-18 18:43:07 UTC-5
_nbstat: NetBIOS name: COMPUTER, NetBIOS user: , NetBIOS MAC: 0d:0c:11:a4:23:4a
_smbv2-enabled: Server doesn't support SMBv2 protocol

You can see that the XP box has its pants down, so to speak. Lots of insecure services running..even the MAC address..eesh. (The names have been changed to protect the innocent.) Better turn that puppy off. So, you can see that we can gather quite a bit of information just by doing a portscan using nmap. Beware, people!

Rounding out the post, I was able to discover my new server at work using the -O switch. Not surprisingly, my Linux box at work was the most secure among all the Windows boxes nmap found with only one port open. Though, nmap did a good job at guessing the OS.

[sodo@computer ~]$ nmap -A 192.168.113.0/24
Interesting ports on 192.168.113.25:
Not shown: 999 filtered ports
PORT STATE SERVICE
22/tcp open ssh
MAC Address: D8:CA:2F:8E:FB:26 (Unknown)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purposefirewallWAProuter
Running (JUST GUESSING) : Linux 2.6.X (94%), Check Point Linux 2.4.X (87%), D-Link embedded (87%), Linksys embedded (87%), Peplink embedded (87%), Linksys Linux 2.4.X (86%)
Aggressive OS guesses: Linux 2.6.9 - 2.6.18 (94%), Linux 2.6.9 - 2.6.26 (94%), Linux 2.6.22 (Fedora Core 6) (92%), Linux 2.6.18 (CentOS 5, x86_64, SMP) (90%), Linux 2.6.17 - 2.6.28 (89%), Linux 2.6.18 (CentOS 5) (89%), Linux 2.6.18 (Centos 5.3) (89%), Linux 2.6.23 (89%), Linux 2.6.24 - 2.6.28 (89%), Linux 2.6.9 - 2.6.27 (89%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 1 hop


Compare those results to the very revealing XP box:
[sodo@computer ~]$ nmap -A 192.168.113.2
Starting Nmap 5.21 ( http://nmap.org ) at 2011-01-19 10:12 EST
Nmap scan report for SODOWORK (192.168.113.2)
Host is up (0.0016s latency).
Not shown: 984 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp Microsoft ftpd
_ftp-anon: Anonymous FTP login allowed
22/tcp open ssh SCS sshd 5.3.2.10 (protocol 2.0)
_ssh-hostkey: 1536 cc:f7:a1:be:d8:c8:ed:f0:08:c0:3d:fc:bc (RSA)
25/tcp open smtp Microsoft ESMTP 6.0.2600.5512
80/tcp open http Microsoft IIS webserver 5.1
_html-title: Under Construction
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn
443/tcp open https?
445/tcp open microsoft-ds Microsoft Windows XP microsoft-ds
1074/tcp open msrpc Microsoft Windows RPC
2030/tcp open oracle-mts Oracle MTS Recovery Service
3389/tcp open microsoft-rdp Microsoft Terminal Service
5000/tcp open tcpwrapped
5631/tcp open pcanywheredata?
8009/tcp open ajp13 Apache Jserv (Protocol v1.3)
8222/tcp open http VMware Server 2 http config
_html-title: VMware Server 2
8333/tcp open ssl/http VMware Server 2 http config
_html-title: VMware Server 2
Service Info: OS: Windows

Host script results:
_nbstat: NetBIOS name: SODOWORK, NetBIOS user: , NetBIOS MAC: 0d:0e:9c:96:96:29
smb-os-discovery:
OS: Windows XP (Windows 2000 LAN Manager)
Name: CORP\SODOWORK
_ System time: 2011-01-19 10:12:35 UTC-5
_smbv2-enabled: Server doesn't support SMBv2 protocol


Hope you enjoyed this exploration of nmap basics. It certainly was revealing for me!
TAG

Reference
http://nmap.org/
Feel free to drop me a line or ask me a question.