Bash - MAC


cmd:brew command
http://mxcl.github.com/homebrew/
the Homebrew, a packages manager.
>update: update the meta data
>install: install app
>uninstall: uninstall app
>search: search app
>list: list installed app


cmd:port command
www.macports.org
>selfupdate: update self and the ports tree
>search app_name: search application
>install app_name: install application
>uninstall app_name: uninstall application
>outdated: show outdated applications
>upgrade outdated: update outdated applica
tions >installed: show installed applications


cmd:launchctl command
launchctl man page
the interface of launchd.
Mac has three ways to start up a application when boot/login:
1. System Preferences >  Accounts > Login Items
2. /Library/StartupItems & /System/Library/StartupItems
3.
/Library/LaunchAgents
/Library/LaunchDaemons
/System/Library/LaunchAgents
/System/Library/LaunchDaemons
~/Library/LaunchAgents
/var/db/launchd.db/: store overrides.plist

The /Library: for administrator to store 3rd part applications across the OS
The /System/Library: to store Apple's applications
The ~/Library: for user to store 3rd part applications

LaunchAgents: store applications that will start up after log in
LaunchDaemons: store applications that will start up even haven't logged in

Please copy the plist file to one of the above folder if want it to start automatically.

>load -wF plist file:  load the specified config file. -w, overrides the Disabled key and sets it to false. -F, ignore the Disabled key and force the loading the plist.
>unload -w plist file:  stop the job and unload the specified config file. -w, overrides the Disabled key and sets it to true.
>list: list job status


cmd:netstat -na
view current used tcp/udp ports


cmd:ulimit -n
change max open files
> echo "limit maxfiles 1000000 1000000" > /etc/launchd.conf
> echo "ulimit -n 1000000" > ~/.bash_profile


cmd:ls -l
list directory files

color displaying: add this to .bash_profile
export CLICOLOR=1
export LSCOLORS=1212121212121212121212
each "12" stands for the forground and background color of the following items in order
1.  directory
2.  symbolic link
3.  socket
4.  pipe
5.  executable
6.  block special
7.  character special
8.  executable with setuid bit set (setuid=Set User ID)
9.  executable without setgid bit set
10. directory writable to others, with sticky bit
11. directory writable to others, without sticky bit
each "1" or "2" can be one of the following value
a  black
b  red
c  green
d  brown
e  blue
f  magenta
g  cyan
h  light grey
A  bold black, usually shows up as dark grey
B  bold red
C  bold green
D  bold brown, usually shows up as yellow
E  bold blue
F  bold magenta
G  bold cyan
H  bold light grey; looks like bright white
x  default foreground or background
example
export LSCOLORS=bxfxhxhxgxhxhxgxgxbxbx