Mac OS Commands

Here's a cheatsheet of some commonly used Mac OS commands. There are too many to list all of them, these just scratch the surface.

#MD5 HASH:
md5 -s "my string value"

#BG PROCESS:
your-command > dump.out 2>&1 &

#SYMBOLIC LINK:
ln -s /path/to/source target

#CURL:
curl -I http://google.com  
curl -L -v http://google.com > dump.out 2>&1  
curl -x www-proxy.us.abc.com:80 http://google.com

#ZIP and TAR:
zip -r archive.zip folder1 folder2  
unzip -l archive.zip  
tar -zcvf archive.tar.gz folder1 folder2  
tar -ztvf archive.tar.gz  
tar -zxvf archive.tar.gz

#REFACTOR:
find . -type f -name "*Controller.php" -print0 xargs -0 sed -i 's/string1/string2/g'

#GREP:
grep -r -i --exclude='*\.svn*'  "string1" .

#FIND:
find . -type f -name '.DS_Store' -delete  
rm -rf `find . -type d -name .git`  
find . -type d -name .svn -exec rm -rf {} \;

#LINUX MEM:
top (shift m)  
cat /proc/meminfo  
free -m

#set JAVA_HOME to 1.7 or 1.8
#     run these commands to see results:
#    /usr/libexec/java_home -v 1.7
#     /usr/libexec/java_home -v 1.8
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

#PHOTO RESIZE:
sips -Z 800 *.jpg  
sips --resampleWidth 800 *.jpg

#MOVIE CONVERSION:
brew install ffmpeg  
ffmpeg formats  
ffmpeg -i file.mov file.mp4  
ffmpeg -i file.mov -vf scale=-2:1080 file.mp4  
ffmpeg -i input.mov -qscale 0 -r 30 -y output.mov

#HOMEBREW
brew update  
brew doctor  
brew outdated  
brew upgrade  
brew cleanup  
brew ls -l  
brew ls --versions  
brew search spark  
brew tap  
brew tap homebrew/php  
brew untap homebrew/php  
brew tap caskroom/cask  
brew cask list  
brew install Caskroom/cask/xquartz

#HOMEBREW RESET
sudo chown -R whoami /usr/local  
cd /usr/local  
git fetch origin  
git reset --hard origin/master  

Baldeep Hira

bay area programmer working on mobile/tablet/web apps and enterprise cloud apps; ui/ux, html5 and everything else for a prettier web and world

  • San Francisco Bay Area
comments powered by Disqus