2015年10月22日 星期四

Linux command tips

Logout all users: pkill -u username

SSH port forwards: ssh -L port:127.0.0.1:port -lAccount -N RemoteIP

add text at the end of each line in unix : awk '$0=$0" | --recursive"'

2015年10月4日 星期日

Mac command line


  • Check mac version: sw_vers -productVersion 
  • Change HostName: sudo scutil --set HostName nameyouwant
  • Change hostname: sudo hostname mbpr
  • To start an application from command line, TeamViewer for example:
       > open -g -a /Applications/TeamViewer.app
  • To gracefully quit instead of kill-ing:
      > osascript -e 'quit app "TeamViewer.app"'

  • Open multiple VLC
    /Applications/VLC.app/Contents/MacOS/VLC
  • Restart from terminal: 
    • sudo shutdown -r now 
    • sudo shutdown -h +5 

With details on hiding given by: https://support.apple.com/en-au/ht203998
pwpolicy can both disable and enable users, without losing their password
To disable the user
pwpolicy -u username disableuser
To enable the user
pwpolicy -u username enableuser
Use dscl to hide the user so they don't show on login:
sudo dscl . create /Users/username IsHidden 1 
To show a hidden user
sudo dscl . create /Users/username IsHidden 0 

2015年10月2日 星期五

Brew tip

Official site: http://brew.sh/

Brew Installation:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Java:
brew tap caskroom/cask
brew install brew-cask
brew cask install java

Install wget:
brew install wget

Install unrar:
brew install unrar

Install Ruby:

Install php mcrypt:
brew install homebrew/php/php56-mcrypt

Search php module:
brew search php | grep mcrypt

Install Pillow:
brew install libtiff libjpeg webp little-cms2

pip install Pillow