Home || Mac Articles and Links || Basics | Information | Environment | fink | Perl 5.8 | Other Articles
I'm an inveterate note taker and I work at the command-line in Terminal, which is in the Applications:Utilities folder. I also like to use Perl for various tasks. I'm running MacOS X 10.2.8 (Jaguar), the highest version I can run on my Wallstreet Powerbook G3. Here are some notes I have for getting information from MacOS X, reviewing settings, and some of my setup tasks after a fresh MacOS install.
Here are some handy command-key shortcuts I use working in the Finder and applications:
In the Finder:
In Terminal:
At the command-line:
% file Movies samba.tar.gz testfile.txt /usr/sbin/httpd ~/bin/testipaddress.pl
Movies: directory
samba.tar.gz: gzip compressed data, deflated, original filename,
last modified: Tue Nov 2 12:14:40 2004, os: Unix
testfile.txt: ASCII text
/usr/sbin/httpd: Mach-O executable ppc
/Users/me/bin/testipaddress: perl commands text
% tar -czvf Sites.tgz Sites % mkdir SitesBackup % ditto Sites SitesBackup
As you did in MacOS 9, you can get basic information on your Mac setup in the MacOS X Apple menu under "About This Mac". It lists OS version, installed memory, and processor. The "More Info" button will open the Apple System Profiler (ASP) application that will give you an enormous amount of information on devices, drives, vendors, applications (and versions!), system extensions and access to a number of logs. You can use Applications:Utilities:Console to review individual logs, if desired.
You can get basic information on your operating system with only the 'sw_vers' command. If you want to verify your OS version and get more detailed information, enter the following line of semicolon-separated commands (the 'echo' commands are for inserting blank lines in the output) at the prompt in Terminal:
date; echo ""; sw_vers; hostinfo; echo ""; uname -a; echo "";
Here's what that returns for me:
Wed Mar 17 12:13:32 EST 2004
ProductName: Mac OS X
ProductVersion: 10.2.8
BuildVersion: 6R73
Mach kernel version:
Darwin Kernel Version 6.8:
Wed Sep 10 15:20:55 PDT 2003; root:xnu/xnu-344.49.obj~2/RELEASE_PPC
Kernel configured for a single processor only.
1 processor is physically available.
Processor type: ppc750 (PowerPC 750)
Processor active: 0
Primary memory available: 192.00 megabytes.
Default processor set: 40 tasks, 103 threads, 1 processors
Load average: 0.75, Mach factor: 0.47
Darwin pjcpb.local. 6.8 Darwin Kernel Version 6.8: Wed Sep 10 15:20:55 PDT 2003;
root:xnu/xnu-344.49.obj~2/RELEASE_PPC Power Macintosh powerpc
Often the Developer Tools are needed to install something, especially open source software. To verify if the BSD subsystem is installed, and whether the Developer Tools are installed, enter the following semicolon-separated commands at the prompt in Terminal:
cd /Library/Receipts ; ls -d *Dev*; ls -d *BSD*
This returns:
Dec2002DevToolsExtras.pkg/ DevSDK.pkg/ DevDocumentation.pkg/ DevTools.pkg/ DevExamples.pkg/ BSD.pkg/
By the way, you can get the latest Developer Tools at http://developer.apple.com/ You will have to register, but the tools, a large download, are free. Burn them onto a CD as a backup.
You can get some details of your shell (current Terminal window) environment with these commands:
- whoami
- your [short] username, which determines your home directory name
- who, w
- display who is connected to your Mac, and show time and how many Terminal windows you have open. Each command gives slightly different information.
- echo $SHELL
- your current shell in Terminal
- echo $HOME
- your home directory
- printenv
- all your environment variables and their values; use 'echo' and a dollar '$' prefix to list individual variable as above
- clear
- will clear the current Terminal window screen. (Cmd-K will clear the screen and the scrollback buffer.)
You can get information on your network interfaces with 'ifconfig'. Ethernet interfaces use the 'en' prefix. On my Mac, 'en0' is the built-in Ethernet and en1 is my wireless card, when it is inserted. Macs with an AirPort card, would show 'en1' for that. If you just need your LAN IP address and the WAN address that the world would see, get "MyIP" on versiontracker.com.
While you can use the Find utility (Cmd-F) in the Finder to search for files, you can also use the Terminal to search for files ('locate filename' that returns a lot of listings), or within man pages ('man -k keyword') for information on command-line programs, as you become more familiar with command-line programs. To assist in this, you have to build a couple supporting database files. Run this command:
sudo periodic weekly
I also add a runtime configuration (rc) file, .tcshrc, to my home directory. It will control characteristics of the Terminal command-line and operating environment. The standard MacOS X shell is 'tcsh' and its 'rc' file is .tcshrc. Here is part of mine, with explanatory comments preceded by the hash '#' character:
# set up more useful contextual menu for Terminal in Dock
# see: http://www.entropy.ch/software/macosx/docs/customization/
setenv SHORTHOST `echo -n $HOST | sed -e 's%\..*%%'`
alias precmd 'printf "\033]0;%s @ $SHORTHOST\007" "${cwd}" | sed -e "s%$HOME%~%"'
sched +0:00 alias postcmd 'printf "\033]0;%s @ $SHORTHOST\007" "\!#"'
# for more informative file listings
alias ls ls -F
alias lss 'pwd;ls -la|sort +4 -rn'
alias ll ls -la
alias lf ls -F
# confirm file removals
alias rm rm -i
# command to check a process [modified from an OSXFAQ suggestion]
# Usage: xps cron
alias xps 'ps aucx | head -1; ps aucx | grep -i \!:1'
These lines are actually flush left and I edit the file using pico, a command-line editor: 'pico .tcshrc'. The commands to move around in pico are at the bottom of the screen and require using the Control key, for example, '^X' to exit. I also have BBEdit installed and I could edit it there by using its command-line tool to open the file: 'bbedit .tcshrc'.
Here's an example of running the last 'xps' alias command on two background processes, one at a time:
% xps cron USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 299 0.0 0.1 14124 116 ?? Ss 9:51AM 0:00.05 cron % xps cupsd USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 323 0.0 0.1 15320 200 ?? Ss 3:36PM 0:04.79 cupsd
There is a really nice AppleScript, Open Terminal Here, that allows you to open a Terminal window in a particular directory from a Finder window or dropped item. Installation details and a download link might be available at: http://www.versiontracker.com/ or http://www.macupdate.com/ Search for the name. [It appears to be missing as I write this.]
fink is a package manager for MacOS X, similar to RPM for RedHat Linux. The fink Web site states:
The Fink project wants to bring the full world of Unix Open Source software to Darwin and Mac OS X . We modify Unix software so that it compiles and runs on Mac OS X ("port" it) and make it available for download as a coherent distribution. Fink uses Debian tools like dpkg and apt-get to provide powerful binary package management.
The Web site has download instructions, support discussion, docs, package descriptions, etc. A related utility, Fink Commander, is a GUI interface to fink. I use both to install Unix programs I've used in the past and find very handy like lynx, ncftp, fortune (for daily quote), pine, tidy, etc.
fink places all of its source archives, executables, etc. in a unique '/sw' directory hierarchy so it doesn't interfere with other software installations, which might prefer '/opt' or '/usr/local'. In installing fink, I add a few related environment variables to my .tcshrc file to allow me to more easily install non-fink open source software.
Note, there are now two versions of fink: one for 10.2 (fink v6.3) and one for 10.3 (). I have an old Wallstreet G3 Powerbook with processor upgrade and I can't run 10.3. It's nice that OS version is still supported.
Versions of MacOS X 10.2 and earlier come with Perl 5.6.0, which is a bit buggy. Get a recent version of Perl 5.8, download and expand it into your home, or a 'downloads' directory. It will expand into its own directory.
Caveat: At this writing, Perl's latest version is 5.8.3 but Apple is using 5.8.1 RC3, according to http://www.apple.com/opensource/. I'm using Jaguar so I'll stick with this version of Perl. Most of fink's packages rely on 5.8.0 or 5.8.1 at the latest and fink has a 'system' pointer package for manually installed Perl.
The first thing you want to do is set up an environment property list file to set the locale for Perl. in Terminal, create a '.MacOSX' subdirectory in your home directory and enter that directory.
% cd % mkdir .MacOSX % cd .MacOSX % pico environment.plist
Paste the following into that editing window in pico and then exit with Ctl-O, Ctl-X.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM
" file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>LANG</key>
<string>us_ENG</string>
<key>LC_ALL</key>
<string>C</string>
</dict>
</plist>
---
% sudo sh ./Configure -de -Dprefix=/usr -Dperladmin=corrp@pobox.com -Dcf_email=corrp@pobox.com
% sudo make
% sudo make test
---
# The final install report mentioned two tests will probably
# fail and can be ignored. Reviewing the buffer text, I see:
#
ext/DB_File/t/db-btree...............#
# This test is known to crash in Mac OS X versions 10.2 (or
earlier) because of the buggy Berkeley DB version included
with the OS...
ext/DB_File/t/db-recno...............#
# Some older versions of Berkeley DB version 1 will fail
# db-recno tests 61, 63, 64, and 65.
#
# For example Mac OS X 10.2 (or earlier) has such an old
# version of Berkeley DB.
Failed 2 test scripts out of 759, 99.74% okay.
---
# you definitely need 'sudo' for this command:
% sudo make install
---
A default Perl install would put it in '/usr/local/', but we used the '/usr' prefix in the 'Configure' command to replace Apple's 5.6.0. Following the perl install, have fink install its 'system-perl581' pointer package:
---
Looks like perl 5.8.1
Setting up system-perl581 (5.8.1-1) ...
---
You can verify your Perl installation with these two commands:
which perl; perl -v
You could now install fink packages you like. I use fink to install:
fileutils pine lynx ncftp wget gpg readline vim-nox
These fink packages might install other prerequisite packages, and except for 'fileutils' and vim-nox (non X-windows replacement for vi editor), are desired by Perl when configuring CPAN. You could then run and configure CPAN. I use 'sudo cpan' to do this and for subsequent runs of cpan to get Perl modules.
Naturally, I'm not the only one to publish my working notes on Terminal. Here are a couple others: