Mac

From rbachwiki
Revision as of 17:09, 24 January 2022 by Bacchas (talk | contribs)
Jump to navigation Jump to search

Mac Troubleshooting

Recover Broken Drive

Run the following command in Terminal.app, 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/ARDAgent.app/Contents/Resources/kickstart -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

resetpassword

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 com.apple.finder 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
screencapture
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 com.apple.finder AppleShowAllFiles -bool TRUE
Show . files in finder
defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE
Display Unix path in Finder Windows
defaults write com.apple.screencapture type PNG
Modify Screen caputre type formats are PNG, BMP, GIF, JPED, PICT, PSD, SGI, TGA, TIFF
defaults write com.apple.screencaputre 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

username.conf

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

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

http://php-osx.liip.ch/

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

/usr/local/php5/lib/php.ini

/usr/local/php5/php.d

99-liip-developer.ini

Install MYSql

http://dev.mysql.com/downloads/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:

Enter

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

/.com.apple.timemachine.supported - 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 http://www.ietf.org/rfc/rfc959.txt RFC 959 Only used as a source port
21 FTP Control http://www.ietf.org/rfc/rfc959.txt RFC 959</a>  
22 SSH (secure shell remote login) http://www.free.lp.se/fish/rfc.txt SSH RFC</a>  
23 Telnet http://www.ietf.org/rfc/rfc854.txt RFC 854</a> Common port for attacks
25 SMTP (email) http://www.ietf.org/rfc/rfc821.txt RFC 821, 822</a>  
53 DNS http://www.ietf.org/rfc/rfc1034.txt RFC 1034, 1035</a> Mainly uses UDP, not TCP
70 Gopher http://www.ietf.org/rfc/rfc1436.txt RFC 1436</a>  
79 Finger http://www.ietf.org/rfc/rfc1288.txt RFC 1288</a>  
80 HTTP (Web) http://www.ietf.org/rfc/rfc1945.txt RFC 1945</a>  
88 Kerberos http://www.ietf.org/rfc/rfc1510.txt RFC 1510</a>  
105 PH (directory)    
106 Poppass (change password) http://www.con.wesleyan.edu/%7Etriemer/network/poppassd/poppassd_tcp.html Wesleyan tech note</a>  
110 POP3 (email) http://www.ietf.org/rfc/rfc1081.txt RFC 1081, 1082</a>  
111 Remote Procedure Call (RPC) http://www.ietf.org/rfc/rfc1057.txt RFC 1057</a> Used for many Unix applications
113 AUTH http://www.ietf.org/rfc/rfc931.txt RFC 931</a>  
115 SFTP http://www.ietf.org/rfc/rfc913.txt RFC 913</a>  
119 NNTP (News) http://www.ietf.org/rfc/rfc977.txt RFC 977</a>  
139 NETBIOS Session http://www.ietf.org/rfc/rfc1001.txt RFCs 1001, 1002</a>
143 IMAP (new email) http://www.ietf.org/rfc/rfc2060.txt RFC 2060</a>  
384 ARNS (tunneling) http://www.cs.mu.oz.au/appletalk/doc/MacUAR.userDoc.html#OTARNS Univ. of Melbourne</a>  
387 AURP (tunneling) http://www.ietf.org/rfc/rfc1504.txt RFC 1504</a>  
389 LDAP (directory) http://www.ietf.org/rfc/rfc1777.txt RFC 1777, 1778</a>  
407 Timbuktu 5.2 or later http://www.netopia.com/support/technotes/software/tb2mac/TPM_031.html Netopia technote</a> Previous versions use other ports
427 SLP (service location) http://www.ietf.org/rfc/rfc2165.txt RFC 2165</a> Only uses TCP for large responses
443 HTTP over SSL (HTTPS) http://home.netscape.com/eng/ssl3/ssl-toc.html Draft RFC</a>  
445 MS Directory Service    
465 SMTP over SSL (SSMTP)    
497 Retrospect   UDP for finding clients
510 FirstClass server http://www.softarc.com/ SoftArc.com</a>  
515 LPR (printing) http://www.ietf.org/rfc/rfc1179.txt RFC 1179</a>  
548 AFP (AppleShare) http://developer.apple.com/techpubs/macos8/NetworkCommSvcs/AppleShare/appleshare.html AFP 2.2 spec</a>  
554 RTSP (QuickTime server) http://til.info.apple.com/techinfo.nsf/artnum/n60148/ Apple tech note</a> Also uses UDP 6970+
591 FileMaker Pro Web http://192.35.50.21/ti/FMPro?-db=ti.fp5&-format=detail.html&-lay=list&product=FileMaker&artnmbr=106123&-max=10&-recid=35670&-find= 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 http://www.apple.com/appleshareip/ ASIP 6</a>
631 IPP (Internet Printing Protocol) http://www.pwg.org/ipp/ RFCs 2565-2569</a> Available in Mac OS X 10.2 through http://www.cups.org/ CUPS</a>
636 LDAP over TLS/SSL (LDAPS) http://www.faqs.org/rfcs/rfc2246.html RFC 2246</a>  
660 ASIP Remote Admin   http://www.apple.com/appleshareip/ ASIP 6.3</a> and later
666 Now Contact Server http://www.eudora.com/techsupport/kb/184hq.html Eudora tech note</a> Violates actual port assignment
687 ASIP Shared UG Port http://til.info.apple.com/techinfo.nsf/artnum/n31042 ASIP Tech note</a> http://www.apple.com/appleshareip/ ASIP 6.2</a> and later
1080 WebSTAR Admin http://www.webstar.com/products/webstar/docs/ws4manual.27.html StarNine FAQ</a> WebSTAR port number plus 1000
1417 Timbuktu Control (pre-5.2) http://www.netopia.com/support/technotes/software/tb2mac/TPM_031.html Netopia technote</a> Login is through UDP Port 407
1418 Timbuktu Observe (pre-5.2) http://www.netopia.com/support/technotes/software/tb2mac/TPM_031.html Netopia technote</a> Login is through UDP Port 407
1419 Timbuktu Send Files (pre-5.2) http://www.netopia.com/support/technotes/software/tb2mac/TPM_031.html Netopia technote</a> Login is through UDP Port 407
1420 Timbuktu Exchange (pre-5.2) http://www.netopia.com/support/technotes/software/tb2mac/TPM_031.html Netopia technote</a> Login is through UDP Port 407
1443 WebSTAR/SSL Admin http://www.webstar.com/products/webstar/docs/ws4manual.27.html 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 http://www.eudora.com/techsupport/kb/184hq.html Eudora tech note</a>  
4199 EIMS Admin http://eudora.qualcomm.com/eims/ EIMS Users Guide</a>  
4347 LANsurveyor Responders http://www.neon.com/LANsurveyor/ls_appnote2.html Neon tech note</a> Uses UDP also
5003 FileMaker Pro http://www.filemaker.com/ti/104289.html FileMaker tech note</a> Direct access, not through Web; UDP for host list
5190 AOL Instant Messenger http://www.aol.com/aim/help.html AOL tech note</a>  
5498 Hotline Tracker http://www.hotlinesw.com/support/faq/firewalls.shtml Hotline tech note</a> UDP port 5499 for finding servers
5500 Hotline Server http://www.hotlinesw.com/support/faq/firewalls.shtml Hotline tech note</a>  
5501 Hotline Server http://www.hotlinesw.com/support/faq/firewalls.shtml Hotline tech note</a>  
6346 Gnutella http://www.gnutellanews.com/information/firewalls.shtml Gnutella news item</a>  
6699 Napster/Macster client http://www.napster.com/ Apparent usage</a> Used when server is in "firewall mode"
7070 Real Player http://service.real.com/firewall/adminfw.html Real tech note</a> Also UDP ports 6970-7170
7648 CuSeeMe (video) http://support.cuseeme.com/cu3win/faq/cufaq010.htm White pine tech note</a> Client connections; UDP for audio/video
7649 CuSeeMe (video) http://support.cuseeme.com/cu3win/faq/cufaq010.htm White pine tech note</a> Connection establishment.
8080 Common HTTP alternate http://www.ietf.org/rfc/rfc1945.txt RFC 1945</a>  
16080 Web Performance Cache    
19813 4D server http://www.acius.com/support/tips99%2D25.html 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) http://www.ietf.org/rfc/rfc2131.txt RFC 2131 Commonly used to obtain a Mac's IP address
69 Trivial File Transfer Protocol (TFTP) http://www.ietf.org/rfc/rfc783.txt RFC 783  
123 Network Time Protocol http://www.ietf.org/rfc/rfc1305.txt RFC 1305  
137 Windows Name Service http://www.ietf.org/rfc/rfc1001.txt RFC 1001  
138 Windows Datagram Service http://www.ietf.org/rfc/rfc1001.txt RFC 1001  
161 Simple Network Management Protocol (SNMP) http://www.ietf.org/rfc/rfc1157.txt RFC 1157  
407 Timbuktu http://www.netopia.com/support/technotes/software/tb2mac/TPM_031.html 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) http://www.ietf.org/rfc/rfc2326.txt RFC 2326  
2049 Network File System (NFS) http://www.ietf.org/rfc/rfc1813.txt RFC 1813  
3283 Apple Remote Desktop (formerly known as Network Assistant) http://til.info.apple.com/techinfo.nsf/artnum/n30217 TIL Note  
5003 FileMaker Pro http://www.filemaker.com/ti/104289.html FileMaker tech note For obtaining host list
5353 Zeroconf - Rendezvous http://www.zeroconf.org/ Zeroconf Used in Rendezvous
5060 SIP - iChat AV http://www.faqs.org/rfcs/rfc3261.html RFC 3261 ,http://www.faqs.org/rfcs/rfc3262.html RFC 3262 ,http://www.faqs.org/rfcs/rfc3263.html RFC 3263 ,http://www.faqs.org/rfcs/rfc3264.html RFC 3264 ,http://www.faqs.org/rfcs/rfc3265.html RFC 3265 Used in iChat AV
6970 and up QuickTime and RealPlayer http://til.info.apple.com/techinfo.nsf/artnum/n60148 TIL Note  
7070 RTSP alternate (RealPlayer) http://service.real.com/firewall/adminfw.html 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.