From rbachwiki
Jump to navigation Jump to search

Mac Troubleshooting

Recover Broken Drive

Run the following command in, replacing N by the corresponding disk number, which you can find by running diskutil list:

  • diskutil eraseDisk FAT32 UNTITLED MBRFormat /dev/diskN

Changing Vnc Port number

sudo nano /etc/services

Then change the port from 5900 to another number Restart vnc server

sudo /System/Library/CoreServices/RemoteManagement/ -restart -agent

Reset Lost password

First up, you need to reboot your computer while holding the Command and the R keys down. Hold your Mac’s power button down for about six seconds, and it will turn off. Wait a couple of seconds more, and then hold down Command-R on your keyboard while pressing the power button again to turn the machine on. Keep holding the Command-R combination until you see the little spinning circle just below the Apple logo on the boot up screen.

Once your Mac boots, you’ll see a window with various options. Use your mouse to select Terminal from the Utilities menu, and Terminal will launch. Type in


and you’ll get a dialog box that will let you do just that. Choose the user you want to change the password for, and type in the new password twice. Hit OK, close the reset password window, and reboot your Mac.

Show Hidden Files in finder

defaults write AppleShowAllFiles TRUE
killall Finder
To set it back (that .DS_Store on the Desktop is hella irritating), execute those same commands, but just switch that TRUE to FALSE

Useful OX 10 Shortcuts

Task Key Command
Open the Force Quit window Command-Option-Escape
Cycle through active applications in the Dock Command-Tab
Cancel operation Command-.
Open Mac Help Command-?
Go back in the finder view to the previous item Command-[
Go to folder Command-~
Select all Command-A
Hide Finders toolbar Command-B
Copy Command-C
Duplicate; creates a duplicate copy of a selected items. Command-D
Turn Dock hiding on/off Command-Option-D
Move item to trash Command-Delete
Empty Trash Shift-Option-Delete
Eject the selected disk image, CD, etc. Command-E
Find Command-F
Hide application Command-H
Show info Command-I
Show view options in the Finder. Command-J
Connect to Server Command-K
Make alias Command-L
Minimize window Command-M
Minimize all open windows for an application Command-Option-M
Open a new Finder window Command-N
Create a new folder Command-Shift-N
Open file or folder Command-O
Print file Command-P
Quit application Command-Q
Show original Command-R
Add to Favorites Command-T
Paste Command-V
Close window Command-W
Close all windows Command-Option-W
Cut Command-X
Redo Command-Shift-Z
Go to Applications view in the Finder Command-Option-A
Go to Computer view in the Finder Command-Option-C
Go to Favorites view in the Finder Command-Option-F
Go to Home view in the Finder Command-Option-H
Go to iDisk view in Finder Command-Option-I
Take a screenshot of the entire display Command-Shift-3
Make and capture a rectangular selection of the display Command-Shift-4

Mac Terminal Commands only

ls -lah | pbcopy
will copy the output to the clipboard
say "hello"
will speak hello
say -f filetoread.txt
will read contents of text file
say -f filetoread.txt -o audiofile.aiff
will output to an audio file
defaults write AppleShowAllFiles -bool TRUE
Show . files in finder
defaults write _FXShowPosixPathInTitle -bool TRUE
Display Unix path in Finder Windows
defaults write type PNG
Modify Screen caputre type formats are PNG, BMP, GIF, JPED, PICT, PSD, SGI, TGA, TIFF
defaults write location "Users/robert/Desktop"
Modify screen capture location

Grep: searching with regular expressions

Grep Options (exmple: grep -Rl filename // will return filenames only
-i Case insensitive
-w Whole words
-v lines that don't match
-c return count
-n add line nunbers with search
-R search Directories Recursively
-Rl return only filenames
-RL Filename that do not match
--color=auto searchcriteria
ps aux | grep Applications // will return all running applicatiosn

Use Single User Mode to Solve Issues

Shutdown the Mac, wait 15 seconds

Hold down the Command and S Key While pressing the power button to start the mac.

At the Terminal prompt type,

fsck -yf

//filessytem check -y means asnswer yes to any questions  f means force

type reboot when finished

Apache, PHP, MySql setup on Mac

Check Apache Version: httpd -v

Check php Version: php -v

sudo apachectl start

sudo apachectl stop

sudo apachectl restart

Change directory where apache serves from

cd /etc/apache2/users

create a conf file, name it the log on user name


<Directory "/Users/robert/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all

Save file
change permissions : sudo chmod 644 filename.conf
sudo apachectl restart
Upgrade Php to latest version

Edit PHP.ini to fix time zone; you have to modify two places




Install MYSql

dmg, 64 bit version

Add the mysql dir to your path

nano .bashrc ; add line below

export PATH="/usr/local/mysql/bin:$PATH"

set mysql password

mysqladmin -u root password

To change the password

mysqladmin -u root -p password

Restarting Apache in OSX

 Open Terminal, you have to have root access

type command;  apachectl restart

Turning on Root access in OSX

 Go to the Terminal:


sudo passwd root

and follow instructions

Mac OX 10 Directory Structure

File or Folder           Description

/.DS_Store - Contains Finder settings for the current directory. This folder is generated for any directory viewed in Finder.

/.Spotlight‐V100 - Contains Spotlight‐specific metadata

/.Trashes - Contains files that have been dragged to the Trash

/ - Indicates that a drive can be used by Time Machine as a backup target

/.fseventsd - Used by the FSEvents API

/.hotfiles.btree - A B‐Tree index that provides fast access to frequently used files

/Applications - Holds all Mac OS X applications

/bin - Contains essential system binaries

/Desktop DB - Contains housekeeping information used by Finder

/Desktop DF - See /Desktop DB

/dev - Contains device‐specific files

/Developer - Contains Apple's XCode tools and documentation (but only if you've installed them)

/etc - Contains system configuration files. This is a symbolic link to /private/etc.

/home - Used by the automounter for NFS‐mounted home directories

/Installer Log File - Used by some third‐party installers

/Library - Contains support files for locally installed applications

/lost+found - Stores orphaned files discovered by fsck

/mach_kernel - Contains the Darwin kernel

/mach_kernel.ctfsys - Contains an alternate copy of the kernel (used by dtrace)

/net - Used by the automounter for NFS‐mounted directories

/Network - Contains network‐mounted Application, Library, and User folders

/opt - Contains the MacPorts installation (if installed)

/private - Contains the tmp, var, etc, and cores directories

/sbin - Contains executables for system administration and configuration

/sw - Contains the Fink installation (if installed)

/System - Contains various folders, the most important of which is Library, which holds support files for the system and system applications

/tmp - Holds temporary files. A symbolic link to /private/tmp.

/User Guides and Information - An alias to /Library/Documentation User Guides and Information

/Users - Contains home directories for users on the system (root user's home is /var/root)

/usr - Contains BSD UNIX applications and support files

/var - Contains frequently modified files, such as log files. Symbolic link to /private/var.

/Volumes - Contains all visible mounted file systems, including removable media and mounted disk images

Finding Php.ini File in OsX

The Php.ini is not necessary in OSX but if it exists it would be in the /Private/etc dir

Well Known Mac OS X Ports

TCP Port Numbers Commonly Used by Macintosh Services

Port Usage Reference Notes
20 FTP Data RFC 959 Only used as a source port
21 FTP Control RFC 959</a>  
22 SSH (secure shell remote login) SSH RFC</a>  
23 Telnet RFC 854</a> Common port for attacks
25 SMTP (email) RFC 821, 822</a>  
53 DNS RFC 1034, 1035</a> Mainly uses UDP, not TCP
70 Gopher RFC 1436</a>  
79 Finger RFC 1288</a>  
80 HTTP (Web) RFC 1945</a>  
88 Kerberos RFC 1510</a>  
105 PH (directory)    
106 Poppass (change password) Wesleyan tech note</a>  
110 POP3 (email) RFC 1081, 1082</a>  
111 Remote Procedure Call (RPC) RFC 1057</a> Used for many Unix applications
113 AUTH RFC 931</a>  
115 SFTP RFC 913</a>  
119 NNTP (News) RFC 977</a>  
139 NETBIOS Session RFCs 1001, 1002</a>
143 IMAP (new email) RFC 2060</a>  
384 ARNS (tunneling) Univ. of Melbourne</a>  
387 AURP (tunneling) RFC 1504</a>  
389 LDAP (directory) RFC 1777, 1778</a>  
407 Timbuktu 5.2 or later Netopia technote</a> Previous versions use other ports
427 SLP (service location) RFC 2165</a> Only uses TCP for large responses
443 HTTP over SSL (HTTPS) Draft RFC</a>  
445 MS Directory Service    
465 SMTP over SSL (SSMTP)    
497 Retrospect   UDP for finding clients
510 FirstClass server</a>  
515 LPR (printing) RFC 1179</a>  
548 AFP (AppleShare) AFP 2.2 spec</a>  
554 RTSP (QuickTime server) Apple tech note</a> Also uses UDP 6970+
591 FileMaker Pro Web FileMaker tech note</a> Recommended alternate to 80
625 Remote Open Directory Proxy (DSProxy)   Unregistered usage, registered to DEC/DLM
626 IMAP Admin   Apple extension in ASIP 6</a>
631 IPP (Internet Printing Protocol) RFCs 2565-2569</a> Available in Mac OS X 10.2 through CUPS</a>
636 LDAP over TLS/SSL (LDAPS) RFC 2246</a>  
660 ASIP Remote Admin ASIP 6.3</a> and later
666 Now Contact Server Eudora tech note</a> Violates actual port assignment
687 ASIP Shared UG Port ASIP Tech note</a> ASIP 6.2</a> and later
1080 WebSTAR Admin StarNine FAQ</a> WebSTAR port number plus 1000
1417 Timbuktu Control (pre-5.2) Netopia technote</a> Login is through UDP Port 407
1418 Timbuktu Observe (pre-5.2) Netopia technote</a> Login is through UDP Port 407
1419 Timbuktu Send Files (pre-5.2) Netopia technote</a> Login is through UDP Port 407
1420 Timbuktu Exchange (pre-5.2) Netopia technote</a> Login is through UDP Port 407
1443 WebSTAR/SSL Admin StarNine FAQ</a> WebSTAR port number plus 1000
3031 Program Linking (Apple Events)   Mac OS 9 and later
3659 Apple SASL   Upcoming assignment
4000 Now Public Event Server Eudora tech note</a>  
4199 EIMS Admin EIMS Users Guide</a>  
4347 LANsurveyor Responders Neon tech note</a> Uses UDP also
5003 FileMaker Pro FileMaker tech note</a> Direct access, not through Web; UDP for host list
5190 AOL Instant Messenger AOL tech note</a>  
5498 Hotline Tracker Hotline tech note</a> UDP port 5499 for finding servers
5500 Hotline Server Hotline tech note</a>  
5501 Hotline Server Hotline tech note</a>  
6346 Gnutella Gnutella news item</a>  
6699 Napster/Macster client Apparent usage</a> Used when server is in "firewall mode"
7070 Real Player Real tech note</a> Also UDP ports 6970-7170
7648 CuSeeMe (video) White pine tech note</a> Client connections; UDP for audio/video
7649 CuSeeMe (video) White pine tech note</a> Connection establishment.
8080 Common HTTP alternate RFC 1945</a>  
16080 Web Performance Cache    
19813 4D server ACI US tech note</a> Previously 14566 (6.0 and earlier)

UDP Port Numbers Commonly Used by Macintosh Services

Port Usage Reference Notes
53 DNS   Sometimes uses TCP
68 Dynamic Host Configuration Protocol (DHCP) RFC 2131 Commonly used to obtain a Mac's IP address
69 Trivial File Transfer Protocol (TFTP) RFC 783  
123 Network Time Protocol RFC 1305  
137 Windows Name Service RFC 1001  
138 Windows Datagram Service RFC 1001  
161 Simple Network Management Protocol (SNMP) RFC 1157  
407 Timbuktu Netopia technote Handshaking only, prior to version 5.2
458 QuickTime TV    
497 Retrospect   Finding clients on the network
514 Syslog    
554 Real Time Streaming Protocol (QuickTime) RFC 2326  
2049 Network File System (NFS) RFC 1813  
3283 Apple Remote Desktop (formerly known as Network Assistant) TIL Note  
5003 FileMaker Pro FileMaker tech note For obtaining host list
5353 Zeroconf - Rendezvous Zeroconf Used in Rendezvous
5060 SIP - iChat AV RFC 3261 , RFC 3262 , RFC 3263 , RFC 3264 , RFC 3265 Used in iChat AV
6970 and up QuickTime and RealPlayer TIL Note  
7070 RTSP alternate (RealPlayer) Support Note

Locked Files in MacOSX

When a file is "locked" by OS X, it is applying what *nix calls a "flag" to the file. In this case, the flag is "uchg", which means that no user, even root, can alter the file in any way until the flag is removed. You can use the command chflags to remove the flag.

The following example should unlock every file in your home directory:

sudo chflags -R nouchg ~/
Here's a breakdown of the command:

sudo will run the chflags command as root (you may be prompted for your root password).

-R will cause the command to affect every file in the directory and all of its subdirectories. Yes, capitalization matters.

nouchg is the syntax for removing the uchg flag. Any flag can be removed by putting "no" in front of it.

You can of course substitute the tilde (~) with whatever directory path you want to affect. To change an individual file, leave out the -R and type the file path instead of a directory path. Normal operators apply, such as $ and *.

Apache2 - Mac osx

Apache cofig file is found in the private/etc/apache2
it is a hidden directory under the root. you can access it by Clikcing "Go" under the menu and then click "go to folder" Then type in the directory..
you have to change the ownership of the file in order to modify it. I had to login as an ftp user to changer the file.