Mac_Unix_Templates


Navigate to Unix directories  (where are  /bin /dev  /etc /usr /var ... ?)
In finder command_shift_G  and  enter  /var                                                                 # root (unavailable) is in this directory

force-trash
holding down the Option key when emptying the trash to force-trash a locked file

donsauer$  #                                                      # everything after # is ignored
donsauer$  cd                                                     # go home
donsauer$  pwd                                                    # print working dir
donsauer$  ls -a                                                  # see all your files
donsauer$  ps -ax                                                 # see all your running processes
donsauer$  ps aux                                                 # see all your running processes
donsauer$  df                                                     # list mounted devices

donsauer$  date                                                   # prints date and time
donsauer$  cal                                                    # prints this month
donsauer$  cal  2010                                              # prints this year

donsauer$  find . -name  "Sheep*"  -print                         # find names begining with "Sheep"
donsauer$  find . -iname "*sheep*" -print                         # case insensitive find

donsauer$  find . -exec    "this_word*" '{}'\; -print             # find file with "this_word"
donsauer$  find . -exec -q "this_word*" '{}'\; -print             # find file with "this_word"

donsauer$  echo 'first'  >  file.txt                              # writes  'first'  to file.txt
donsauer$  echo 'second' >> file.txt                              # appends 'second' to file.txt
donsauer$  echo "echo '3rd' >> file.txt" >> file.txt              # appends "echo '3rd' >> file.txt"

donsauer$  cat *.log  >  unsorted.txt                             # puts all log files into unsorted.txt
donsauer$  sort unsorted.txt > sorted.txt                         # sorts unsorted.txt into sorted.txt

donsauer$  Whois idea2IC                                          # list web site info
donsauer$  Whois 67.218.116.133                                   # list web site info
donsauer$  Whois -h whois.layer42.net -p 4321 67.218.116.133      # host and port options

donsauer$  Who                                                    # who is on the system
donsauer$  Whereis                                                # locates a program
donsauer$  Which  cat                                             # which program
donsauer$  Whatis cat                                             # describe program

donsauer$  more  file.dat                                         # "Table" — generic tabular data
donsauer$  more  file.csv                                         # "CSV" — comma-separated values
donsauer$  more  file.tsv                                         # "TSV" — tab-separated values

donsauer$  hdiutil eject -force /dev/disk1                        # eject a disk (DVD port)
donsauer$  top                                                    # view memory (q key to stop)
donsauer$  kill -9 number                                         # kill a process
donsauer$  defaults write com.apple.Finder AppleShowAllFiles YES  # view invisible files
donsauer$  defaults write com.apple.Finder AppleShowAllFiles NO   # hide invisible files
donsauer$  diff textfile1  textfile1                              # see if files are the same
donsauer$  login root                                             # login as root



enable the root user
Directory Utility.app   in Application » Utilities

OS X Unix  Environment 
donsauer$ 
echo $SHELL                                     # login Shell is bash (/bin/bash)
donsauer$  more  /etc/bashrc                               # view login shell env resource file
donsauer$  printenv                                        # view all Variables
donsauer$  env                                             # view all Variables
donsauer$  export VISUAL=vi                                # creates/modifies env variable in bash
donsauer$  echo $VISUAL                                    # view new variable (vi)
donsauer$  more  /etc/bashrc                               # view login shell env resource file
donsauer$  more  ~/.profile                                # view paths
donsauer$  vi ~/.profile                                   # vi edit paths file
donsauer$  PATH=$PATH\:/Developer/Tools                    # to add a path (temp)
donsauer$ 
PATH=${PATH}:/Developer/Simulator/GTKwave/bin   # Add GTKwave path
donsauer$  more  alias                                     # view alias
donsauer$  alias lf='ls -F'                                # creates an alias in bash
donsauer$  alias r="perl Write2File3.pl"                   # Type r to run program
donsauer$  unalias r                                       # remove alias
                                                          
# compile/run alias using 2 lines in quotes
donsauer$  alias rrr="g++ -v strarray.cpp -o strarray
                     ./strarray "                                              






HOME           Full path of home directory.
               (/Users/donsauer)
SHELL          Full path of log-in shell.
               (/bin/bash )
USER           User name
               (donsauer)
PATH           List of directories containing commands.
               (/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin)
PWD            Full path of present working directory.
               (/)

vi
            editor
h, j, k, l     Left, down, up, right one char
i,             Insert   esc
x              Delete character
u              Undo last edit
:              Invoke ex from vi editor
:q             Quit
:q!            Quit, discarding any changes
:wq            Save ("write") file and quit
:w             Save file


ADD SHORTCUT
Open Keyboard & Mouse preference pane in your System Preferences
click on the Keyboard Shortcuts tab.
Click the little plus (+) sign,
choose application 
enter exact name of menu bar

Then just pick your keyboard shortcut, click Add, and voilà—you've successfully
added a new shortcut to your Mac. When you open
the app, you'll notice that shortcut is even visible next
to the item so it'll be easy to remember.

Mac Intel
during startup
Press C                   Start up from a bootable CD or DVD
Press D                   Start up in Apple Hardware Test (AHT), if Install DVD 1  in the computer.
Press Option-Command-P-R  until you hear two beeps. Reset NVRAM
Press Option              Starts into Startup Manager, can select Mac OS X volume.
Press Eject, F12,         Ejects any removable media, such as an optical disc.
Press N                   Attempt to start up from a compatible network server (NetBoot).
Press T                   Start up in FireWire Target Disk mode.
Press Shift               Start up in Safe Boot mode and temporarily disable login items.
Press Command-V           Start up in Verbose mode.
Press Command-S           Start up in Single-User mode.
Press Option-N            Start from a NetBoot server using the default boot image.



Force Quit      (Option-Command-Escape)
Restart         (Control-Command-Power)
Force Shut Down (press the power button for 10 seconds)