Mac OSX DHCP debuging

Apple, CLI, DHCP, Macintosh, OSX
Once in a while you might want to dig deep into OSX's dhcp client and find out what dhcp packet the server sent it. A quick command to spit out this info:# ipconfig getpacket en0This produces the following output: op = BOOTREPLY htype = 1 dp_flags = 0 hlen = 6 hops = 0 xid = 1956115059 secs = 0 ciaddr = 0.0.0.0 yiaddr = 192.168.4.10 siaddr = 192.168.4.1 giaddr = 0.0.0.0 chaddr = 0:3:93:7a:d7:5c sname = dhcp.mycompany.net file = options: Options count is 10 dhcp_message_type (uint8): ACK 0x5 server_identifier (ip): 192.168.4.1 lease_time (uint32): 0x164a subnet_mask (ip): 255.255.255.0 router (ip_mult): {192.168.4.1} domain_name_server (ip_mult): {192.168.4.1} domain_name (string): mycompany.net end (none):
Read More

USB-to-Serial console for Mac (OSX)

Apple, CLI, Macintosh, OSX, Serial port, USB
Here are some notes for those of us working with Macs, who also have to deal with networking gear that usually have a serial console for local control. I recently purchased a IOGEARĀ USB 1.1 to Serial Converter Cable that uses the PL2303 chipset (pretty much any brand of these usb to serial converters use this chip). I was hoping that this dongle would allow me to access our network switches serial interface (which you kinda need when the switch has goneĀ berserk). So after looking around the net I found that there is a opensource driver out there for it and that it performs better than the driver provided by Prolific (the company that manufactures the chip). So once everything was installed I hooked up the serial cable and realized that…
Read More

OSX Webmaster special: Shared webserver, bad umask settings, group permissions and filenames with spaces…

Apple, CLI, Linux, Macintosh, OSX, Reference, Shell Script, Tricks, Tutorial, Ubuntu, Unix
Okay so this all started with our users not being able to share files on our webserver. We use SSH only for upload/download and interactive access (ie: no ftp). Through trial and error we found out that the default umask (under OSX Server) for sftp uploaded files are 0033 (ie: rwxr--r--) and directories are 0022 (ie: rwxr-xr-x). This creates a problem when one user uploads a file and another user downloads/modifies and tries to re-upload it -- they simply can't because the group permissions are wrong.If we were using ftp (which we are not) there are some solutions on the net that allow you to modify the startup parameters for the ftp server so that the default umask for all files is 0013 -- which would allow a group of…
Read More

screen…it’s not just for nerds anymore.

CLI, Opensource, Tutorial, Unix
So after hearing from people at work how great the "screen" command was (yeah welcome to gnuland boys and girls), I decided to do a short tutorial on screen. This way I can stop telling them to RTFM and instead tell them to RTFB (Blog). Anyways, What is "screen" first of all....From the pages of wikipedia:GNU Screen is a free terminal multiplexer developed by the GNU Project. It allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program. GNU Screen can be thought of as a text version of graphical window managers, or as a way of putting virtual…
Read More

Couple of cool remote ssh commands for your UNIX arsenal

CLI, Reference, Shell Script, Unix
Here is a easy way to copy an entire directory tree from one Unix machine to another, while retaining the permisssions and ownership, using ssh as the middle man. Assuming that you want to copy everything under source_directory to destination_directory on another machine here is the command you would issue on the source machine (first cd to the directory containing source_directory): tar -cf - source_directory/ | ssh userid@your.destination.machine.com "cd /somedir/destination_directory ; tar -xvlpf -" or if you want to copy everything from the remote server's source directory to the local machine's destination directory: ssh userid@your.source.machine.com "(cd /somedir/source_directory ; tar -cf - .)" |(cd /somedir/destination_directory ; tar -xvlf -) Here is another similar command that allows you to backup a HD partition to another host via ssh: dd bs=1M if=/dev/sdb |…
Read More

Immediate delete for USB drives under OSX

CLI, Macintosh, OSX
Okay so how many times have you "deleted" a file on a USB drive under OSX only to find out later that the storage is still tied up in .Trashes directory. Well there is a easy way to fix this. Open terminal, cd to your USB drives root directory (mounted under /Volumes) and issue the following:rm -rf .Trashestouch .TrashesThis creates a file called .Trashes on your USB drive (don't worry the file size is zero). The side effect of this is that if you delete files off the USB stick, OSX will delete them immediately (since it can not create a .Trashes directory).
Read More

Couple of quick shell tips

CLI, Shell Script
Okay these are bash goodies, so they'll work in any environment. If you're in a situation where you're switching between two different directory paths over and over again, here is a quick tipcd - Another little annoyance that I've gotten around is when you want to edit a system file and you type in the command (ie: vi /etc/this/is/a/really/long/path/config.cfg), only to realize that you forgot to sudo. This used to mean that I would quit vi, curse, recall the command, insert a sudo infront of the vi command and try again....well here is the quicker way.sudo !!This will (re)sudo your last command. And if that's not enough you can actually narrow the sudo down to the last command that started with a certain string.sudo !apacheWhich will look in the history…
Read More

Quickway to check your DNS settings under OSX

CLI, Macintosh, OSX
This is another CLI command, so get your terminal ready. This gives you a quickway to check the DNS settings on OSX. Now one way is to just cat /etc/resolv.conf , but what if you wanted to see what the system is actually using (not just what it was configured for). Well scutil comes to rescue and gives us an interface to the "dynamic store" data maintained by configd. Here is the command:scutil --dnsThe output will list all four resolver your system is configured for. scutil is another one of those deep OSX commands, so I suggest you have a look at the manual for it (man scutil) or get on google and search for more details (Tech Zendo has a detailed article on how to perform actions during fast…
Read More

OSX Directory Services from Command-line

CLI, Macintosh, OSX
New day, new command. dscl is the command in question. It gives you access to Mac OSX's Directory Services Command Line interface. Very powerful stuff for those of us who like the command line and hate to do the same task a million times. A useful example is the ability to grant Administrator privileges to a user from command line. Normally you would have to pull up System Preferences/Accounts/Click User and check the "Allow user to administrate this computer" box. Well not anymore....Here is how:First you probably want to check who is an admin on the machine in question:dscl . read /Groups/admin GroupMembershipNext you might want to add a user (we call him uberuser here) to the admin list:dscl . append /Groups/admin GroupMembership uberuserAnd maybe you want to revoke the…
Read More