The Terminal in OS X

Share this article

The Terminal utility is a great feature within Macintosh OS X, and with the Panther version OS, standardized on the Bash shell. Bash is one of the most commonly found and popular shells in Unix variants, including Linux.

Fortunately for those of us who migrate between operating systems on a regular basis, when returning to the Mac, Bash functions much the same as anywhere else.

If you use OS X as your primary workstation os, you can access local and remote servers with shell access and perform all of your system administration and other efforts from the Terminal. However, there are a few areas unique to the Mac that may come in handy.

For starters, Terminal is found in the Applications folder, within Utilities. if you are using the Terminal to work on your OS X system, some directory structures are mildly different. As an example, several directories are actually aliased inside of /private, such as /etc and /var. To review these, you can type ‘man hier’ in the Terminal for an overview.

Additionally, sudo (the ability to become a superuser for a single command line operation) is automatically on and enabled for the admin user of the machine. In essence, to edit a file that is privileged, a user can type ‘sudo vi /private/etc/httpd/httpd.conf’, is prompted for their admin password and is temporarily elevated to superuser for the event.

You will also find the files you create on the Mac have resource forks associated with them. The explanation of resource forks is a long one so I will not go into it here – however a great overview can be found on the Wikipedia.

Normally, these are not an issue, even across platforms as of Panther, with support for Windows-friendly attachments built into the system and Microsoft’s Office more capable of packaging documents for interoperability. However, from a developer or administrator’s perspective, many file operations may occur in the Terminal. Apple has included some utilities to accommodate the resource forks.

For example, one can use traditional shell programs like cp and mv to work with files and directories. However, those files will be copied or moved without resource forks and could potentially lose data or important file information if restored and accessed at a later date.

Ditto, CpMac and MvMac resolve these technicalities. The three work much like cp and mv, in that they copy or move files or directories to new locations. Ditto has a handy option for preserving resource forks by using ‘ditto -rsrc sourcefile destinationfile’. CpMac and MvMac automatically preserve metadata and forks when used. One limitation is MvMac does not work across filesystems and volumes other than the one mounted as primary.

For backup purposes, ditto or CpMac will work fine, preserving the important resource data while getting your files and directories moved onto remote filesystems or external volumes such as cd-rw or hard drives.

Blane WarreneBlane Warrene
View Author
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week