Using Terminal

Using Terminal is like computing in the good old days, pre Graphical User Interface. MAC OS X is based around a UNIX operating system. So for advanced users, there is an application that allows the user to run UNIX commands to control the system. This is called "Terminal". The advantage of this application, is that it allows the user to have a lot more power. However the down side is that it uses some form of foreign language, that is at best cryptic. Or is it! Well no actually it is not too difficult to learn. I have listed a view useful commands below. Grouped into categories

In order to run "Terminal" you need to run it from applications, it is located in the "Utilities" folder. To locate and run "Terminal" just start a finder window, and to quickly navigate to the "Utilities" folder press and hold down [⇧ + ⌘ + U] or [Shift + Cmd + U]. Find the "Terminal" Icon (highlighted in the "Finder" screenshot on the left), then double click it to open the application. As shown by the screenshot on the right.

When the Terminal window opens it shows a prompt this is made up of the computer name and user logged in. Followed by either a # or $. The normal prompt terminator will be a $ symbol. The terminator differs to signify the power of user i.e. normal user level ($), or root level (#). In most of the command samples, I have started the line with a # (hash), but you more often will be using a $ (dollar). Where you need to use the command with root privilege I will specify it in the text. In most cases all you will have to do is precede the command with the “sudo” command “Substitute User DO

Also note that you can increase the size of the font shown within the Terminal Window, which is good if like me you have poor eyesight. Use the key combination [⌘ + + or ⌘ + -] or [cmd + + or cmd + -] - Note repeated presses of either the plus (+) or minus(-) keys together with the ⌘ or cmd key will increase or decrease the font size in small increments.

For more information on any command or tools click on the Apple logo next to the command and this will display more information.

Network Tools

File Management Tools

Disk Management Tools

Andy Banks's Tips



The "ifconfig" command is used to set parameters for the networking interface.

#> ifconfig


#> ifconfig -a

The "ifconfig" command without any switches will just list details of all the available ethernet ports on the system. As will the the [-a] switch

#> ifconfig en0

To just list the details about a specific port, follow the command with the name of the port. The sample command (shown above), lists the current settings for the standard network port "en0" the first ethernet port.

#> ifconfig en0

         inet6 fe80::216:cbff:feaf:9748%en0 prefixlen 64 scopeid 0x4
         inet 192.168.x.y netmask 0xffffffc0 broadcast 192.168.x.y
         ether 00:16:cb:af:97:48
         media: 1000baseT <full-duplex,flow-control> status: active
         supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none

Note that the useful information is as follows.

  • inet6 - Is the IP version 6 address
  • inet - Is the standard Version 4 IP address, shown here with the last two octets hidden with x and y.
  • netmask - Is shown in hex for some strange reason.
  • broadcast - This address typicaly the end of the network range is again shown in standard dotted decimal format.
  • media - This shows the Speed of the connection "1000baseT" Gigabit ethernet.
  • either - Finaly the last useful bit is "ether" and shows the MAC address of the interface.



Another network tool simular to ifconfig, ipconfig's really useful command is "getifaddr" this returns the IP address without the clutter you get with ifconfig.

#> ipconfig getifaddr en0

Shown below with the output from the command.

#> ipconfig getifaddr en0


As you can see the address is only is shown without any padding. Please note for illustration here I have deliberately shown the last address without the last two octets, since this would giver away the real ip address.



Ping Command



Tar Archiving is useful, it allows you to copy files into an archive and preserve the structure. This archive can be compressed as well to save space. A normal uncompressed tar file will just have the extension .tar, while if this was compressed you just also add the .gz (gun zip) extension so the file would end .tar.gz

The following command creates a compressed archive from the specified folder

#> tar czf filename.tar.gz FolderToArchive

Note that this creates the archive without interaction on the screen, so if you wish to see what is happening, useful when you archiving large folders. Then optionally use the v (verbose) switch.

#> tar czfv filename.tar.gz FolderToArchive

In order to unexpand the archive file we need to use a different set of parameters.

#> tar xvfz filename.tar.gz

If you wish to expand to a specific folder you can use the -C option to expand to a different target folder. Note the C is upper case and is case sensitive.

#> tar xvfz filename.tar.gz -C FilePath

The other options are x = Extract files, v = Verbose mode, f = read or write from/to specified file, z = Use Gun Zip compression, c = Create. There are a host of other options as this tool is big and complex, so click on the apple logo for more complete list of options. I have chosen a few of the more popular to show how the command works.



To split a file into multi parts in order to post online is quite useful. The command that does that is called "split" and this has a number of options.

The following command will split the file into 50m chunks the with a filename of FileName_split_[aaa] for the first file, and FileName_split_[aab] for the second file.

#> split -a 3 -b 50m FileName Filename_split_

The Switches above are "a" (suffix) number of characters used for the suffix, in the sample this is 3, this will create suffix starting with "aaa" for the first part, "aab" for the next one, "aac" after that and so on until "zzz" was reached after which the command would fail if more parts are required. The use of 3 letters for the suffix would allow up to a maximum of 263 (twenty-six cubed). That's a lot of parts and should be enough for most peoples requirements.

The other switch above is "b" (byte count), this is the size for each part, with an optional letter after the size to state if it is line (l) text files only, Kilobyte (k), or Megabyte (m) which follows the size. So the full option would be -b 50m = 50 megabytes for the split size. Each file would be the same 50 megabytes except for the last part created which would be the remainder of the file.



In order to join up the files again it is required to run the "cat" command. This should be run in the same folder as the split files, otherwise you will have to be specific about the paths within the command parameters.

The following command will join all the files starting with FileName1_ and the suffix are combined using the wildcard * (multi charter selection). All these files will be combined to create a new file specified as FileName2 in the command line.

#> cat FileName1_* > FileName2



To Switch Boot mode to verbose mode on a permeant basis can be achieved by change the NVRAM pramaters. This is done by using the command line, as directed below.

Switch Verbose Mode on

#> sudo nvram boot-args="-v"

To turn off again

#> sudo nvram boot-args=



To Switch Boot mode to single user mode on a permeant basis can be achieved by change the NVRAM pramaters. This is done by using the command line, as directed below.

Switch Single User Mode on

#> sudo nvram boot-args="-s"

To turn off again

#> sudo nvram boot-args=



The SSH Known Hosts file is contained in a hidden folder called ".ssh" it is located in the user home folder. it contains a file called "known_hosts"

First off, you need to use Terminal to copy the known_hosts file so you have a backup to go back to if things go wrong. Note that there is also a file called "known_hosts.old" this file is automatically generated, when the ssh-keygen command is run, however this file is overwritten each time it is used so to get a point-in-time backup copy the file with a number tag on the end as a 2nd copy. Replace the xx with the next number in the list. You will need to run a LD command to note the next number to use.

#> cd ~/.ssh
#> ls -a
#> cp known_hosts known_hosts_xx

In order to remove entries from this file use a command called "ssh-keygen". Please replace the domain-name with the actual domain name of the site or server you wish to remove.

#> ssh-keygen -R domain-name



First check the disk partition table by using diskutil command with the list switch.

#> diskutil list

Use the following command to mount the Server HD

#> diskutil mount /dev/disk1s2