Home arrow OSX Tips
OSX Tips
Format a drive in OSX with a FAT16 partition type PDF
Monday, 22 April 2013
If we want to format an USB stick for example in MSDOS FAT16 partition type from OSX terminal, first we will find out our drive name which will be formatted:

  diskutil list

/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 GB     disk1
   1:                    FreeBSD                         306.0 MB   disk1s1
   2:                    FreeBSD                         306.0 MB   disk1s2
   3:                    FreeBSD                         1.5 MB     disk1s3

To format our /dev/disk1 using fat16 we will run:

  diskutil partitionDisk /dev/disk1 1 MBRFormat "MS-DOS FAT16" "UNTITL" 1000M


 
Copy DVD Disk to an File From OSX Command Line PDF
Wednesday, 31 October 2012
Let's say you have a DVD that you want to backup and you've tried to copy files from it but some files cannot be copied because the DVD is cratched and it returns you read errors. If files that cannot be read entirely are video files you can still copy those file partially by ignoring read errors.

To copy/backup a DVD from OSX and ignore errors we will use dd command from OSX's terminal:

  sudo dd if=/dev/disk1 of=file.img bs=1m conv=noerror,notrunc

Last Updated ( Wednesday, 31 October 2012 )
 
Eject a DVD from OSX Shell PDF
Wednesday, 31 October 2012
If you want to eject a DVD from OSX command line (OSX's terminal) you can do it easely with hdiutil command:

  sudo hdiutil eject -force /Volumes/MY_DVD

To list your drives from OSX terminal run:

  diskutil list

 
Use a better terminal on OSX rather than default one PDF
Thursday, 22 March 2012
If you are a sysadmin and you need a better terminal app (better than Terminal) there's a usefull app called iterm2:

It's free. To install it go to: http://www.iterm2.com/

It's has more options than OSX's Terminal and you will notice your F-keys will work with Midnight Commander.

 
Configure OSX's wireless from command line PDF
Thursday, 22 March 2012
If you do not want to change your default settings from your wifi card but you want just to manually configure wifi from command line so next time when you restart your previous settings will be keeped do the following steps.

This is usefull to test/use a different wifi network for a while then reboot and keep your regular wifi settings.

1. Start terminal from Finder / Applications / Utilities / Terminal


2. Switch to root user with:

  sudo su
(you will need to input root password


3. Delete default route with:

  route delete default


4. Add an IP alias to your network wifi card

  ifconfig en1 192.168.1.100 netmask 255.255.255.0 alias


5. Add default route to new wifi router

  route add default 192.168.1.1


The setup works if you are previously connected to that router wifi. For example if you have an access point that connects you to multiple networks. Or if not, just connect first to this second Access Point and then run previous commands.

 
OSX to Samba Error, You don't have permision to rename PDF
Sunday, 12 February 2012
If you get the error:

  You don't have permision to rename

when you try to access a Samba resource on FreeBSD or Linux machine from OSX the problem is that you need to add the following line to your smb.conf file:

  unix extensions = no

If this does not solve the problem look for the name of your directory/file you want to rename. It might contain characters not supported by OSX to Samba conversion.

For example having a dir name with @ might give you that error. Like: @@@@this_is_the_folder_to_rename.

In that case the problem can be fixed by manually renaming the folder from your FreeBSD/Linux machine that hosts Samba and then do not use such characters anymore.

 
Fixing Rudix Apps Crash on Snow Leopard PDF
Monday, 06 February 2012
Let's say you want to run Midnight Commander (or wget or other app available usually on FreeBSD or Linux) on your OSX. You will install Rudix from Terminal and then Midnigt Commander (note that apps installed with Rudix are compiled for Mac and are not FreeBSD or linux binaries).

  Run Terminal in OSX and then from command line run:

  curl -O http://rudix.googlecode.com/hg/Ports/rudix/rudix.py
  sudo python rudix.py install rudix
  sudo rudix install coreutils
  sudo rudix install mc
  sudo rudix install wget
  sudo rudix install lynx


So you've installed Total Commander (or Wget or other app) for example using Rudix on Snow Leopard and when you try to launch one of those apps you get the following error:

  Abort Trap

The problem is that you did not installed some compatibility apps for Snow Leopard.

Just also install compat libraries:

  sudo rudix install compat-aria2
 
sudo rudix install compat-bzr
 
sudo rudix install compat_gettext
 
sudo rudix install compat_lua
 
sudo rudix install compat-mercurial
 
sudo rudix install compat-pip
 
sudo rudix install compat-pycurl
 
sudo rudix install compat-scons
 
For Midnight Commander you will need compat_gettext but just to make sure install all.

Also if you are using other version of OSX (Lion for example) don't forget to install libraries:

  sudo rudix install check
 
sudo rudix install pcre
 
sudo rudix install gmp
 
sudo rudix install lcms
 
sudo rudix install libev
 
sudo rudix install libevent
 
sudo rudix install libintl
 
sudo rudix install libjpeg
 
sudo rudix install libmemcached
 
sudo rudix install libpng
 
sudo rudix install lzo

I would also install all utilities:

  sudo rudix install check
 
sudo rudix install pcre
 
sudo rudix install gmp
 
sudo rudix install lcms
 
sudo rudix install libev
 
sudo rudix install libevent
 
sudo rudix install libintl
 
sudo rudix install libjpeg
 
sudo rudix install libmemcached
 
sudo rudix install libpng
 
sudo rudix install lzo

 
sudo rudix install asciidoc
 
sudo rudix install aspell
 
sudo rudix install cabextract
 
sudo rudix install coreutils
 
sudo rudix install dialog
 
sudo rudix install dtach
 
sudo rudix install findutils
 
sudo rudix install mc
 
sudo rudix install optipng
 
sudo rudix install rudix
 
sudo rudix install tmux
 
sudo rudix install xz

There is the wiki page for Rudix apps: http://code.google.com/p/rudix/wiki/Packages

Last Updated ( Monday, 06 February 2012 )
 
Convert ISO file to DMG file or convert DMG to ISO file PDF
Thursday, 19 January 2012
It is possible in OSX to convert a file from DMG format to ISO format or viceversa.

To convert from ISO to DMG run in OSX's Terminal:

  hdutil convert in_file.iso -format UDRW -o out_file.dmg

To convert an image file from DMG to ISO run in OSX's Terminal:

  hdutil convert in_file.dmg -format UDTO -o out_file.iso

Note: Before converting make sure your in_file is ejected (not mounted).

Last Updated ( Thursday, 19 January 2012 )
 
Compile an XCode Project from Command Line PDF
Friday, 25 November 2011
You can compile any XCode project from Terminal's command line using xcodebuild.

Run from command line:

  xcodebuild

And it will compile the project from current directory.

On successfull compilation you will get:

** BUILD SUCCEEDED **

Last Updated ( Friday, 25 November 2011 )
 
Get Attributes of Files and Directories in OSX PDF
Friday, 25 November 2011
You can get attributes of files and directories in OSX using GetFileInfo tool. For example you can see if a directory is a bundle for an app in OSX using GetFileInfo tool from Terminal command line:

  GetFileInfo /Applications/iMovie.app

You will get:

directory: "/Applications/iMovie.app"
attributes: avbstclinmedz
created: 07/08/2011 18:52:51
modified: 07/26/2011 14:13:48

Last Updated ( Friday, 25 November 2011 )
 
Selecting Multiple Files with Midnight Commander under OSX PDF
Wednesday, 23 November 2011
If you want to select multiple files in mc (Midnight Commander) under OSX you will notice your insert key is not working (or you do not have an insert key). To select multiple files in mc you can use Ctrl + T shortcut.

 
Burn an ISO file in OSX from Command Line (Terminal) PDF
Thursday, 17 November 2011
There's an easy way to burn .iso files in OSX right from command line using hdiutil:

  hdiutil burn file.iso

 
Resize an OSX Partition From Command Line (Terminal) PDF
Thursday, 17 November 2011
If you want to resize an OSX partition from command line (terminal) here's how to do it:

  sudo diskutil resizeVolume /dev/disk1s2 100GB

Where /dev/disk1s2 is the partition you want to resize.

If you want to see how much can you decrease or increase the partition size run:

sudo diskutil resizeVolume /dev/disk1s2 limits


 
Disable Spootlight Indexing in OSX PDF
Thursday, 17 November 2011
If we want to disable Spotlight indexing process that is currently running we run from command line:

  sudo mdutil -i off "/Volumes/Macintosh HD 1"

Where '/Volumes/Macintosh HD 1' is the path to our volume that is being indexed.

This is usefull for example if you do not want to index an external hard drive.

 
Writting an FreeBSD USB image to a stick from OSX Terminal PDF
Thursday, 10 November 2011
For that purpose we will use diskutil to identify our USB drive and then dd command to write our FreeBSD image to our USB drive:

  diskutil list

To get more info about a drive from the liste we've got by running previous command we could run:

  diskutil info disk1

We notice our drive is /dev/disk1, then we use dd to write image on our USB drive:

  dd if=FreeBSD-9.0-RC1-amd64-memstick.img of=/dev/disk1 bs=1m

The image must be .img (which is USB stick image, and not .iso which is for CDs) downloaded from ftp.freebsd.org (or from other FreeBSD mirrors).

Don't forget to specify block size (bs=1m parameter), otherwise it will take too long, by writting image in blocks of 512bytes.

Last Updated ( Thursday, 11 October 2012 )
 
See a list of disk drives in OSX Terminal PDF
Thursday, 10 November 2011
For example you have a USB stick and you want to create a newfs on it, it is usefull to know the drive name of that USB drive. Or you want to erase it with DD. There's a tool from command line for drive management called diskutil:

To list your drives:

  diskutil list

Your output of the command might be something like this:
using diskutil to list installed drives
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                                                   *4.0 GB     disk1

You can use diskutil for other tasks like mounting a disk, erasing a disk, eject, verify, etc.

Last Updated ( Thursday, 10 November 2011 )
 

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?