粘贴板命令

  1. mac: pbcopy-------pbpaste
  2. windows: clip
  3. linux: xsel

连接Ubuntu桌面

  1. sudo apt-get install x11vnc
  2. #配置vnc密码
  3. x11vnc -storepasswd
  4. #启动vnc服务
  5. x11vnc -forever -shared -rfbauth ~/.vnc/passwd
  6. Mac打开Finder,Cmd+K(连接服务器),输入:
  7. vnc://172.26.1.139:5900
  8. 然后输入密码即可!
  9. 端口默认是5900

命令行安装Java

  1. #!/bin/bash
  2. hdiutil attach jdk-8u201-macosx-x64.dmg
  3. cd /Volumes/JDK\ 8\ Update\ 201
  4. sudo installer -pkg JDK\ 8\ Update\ 201.pkg -target /
  5. #卸载镜像
  6. hdiutil detach /Volumes/JDK\ 8\ Update\ 201
  7. #卸载jdk
  8. sudo rm -rf /Library/Java/JavaVirtualMachines
  9. shell=$SHELL
  10. #zsh
  11. if [ "$shell" == "/bin/zsh" ]
  12. then
  13. echo "zsh"
  14. if [ ! -f "$HOME/.zshrc" ]; then
  15. echo "not exist"
  16. touch $HOME/.zshrc
  17. else
  18. echo "exist"
  19. sed -i "" '/JAVA_HOME/d' $HOME/.zshrc
  20. fi
  21. echo 'export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home' >> $HOME/.zshrc
  22. echo 'export PATH=$JAVA_HOME/bin:$PATH' >> $HOME/.zshrc
  23. echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> $HOME/.zshrc
  24. source $HOME/.zshrc
  25. #bash
  26. elif [ "$shell" == "/bin/bash" ]; then
  27. echo "bash"
  28. #不存在bash_profile文件
  29. if [ ! -f "$HOME/.bash_profile" ]; then
  30. echo "bash_profile not exist,create it..."
  31. touch $HOME/.bash_profile
  32. else
  33. #存在bash_profile
  34. #删除JAVA_HOME
  35. sed -i "" '/JAVA_HOME/d' $HOME/.bash_profile
  36. fi
  37. #重新追加JAVA_HOME
  38. echo 'export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home' >> $HOME/.bash_profile
  39. echo 'export PATH=$JAVA_HOME/bin:$PATH' >> $HOME/.bash_profile
  40. echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> $HOME/.bash_profile
  41. #刷新
  42. source $HOME/.bash_profile
  43. fi
  44. java -version

脚本卸载Java

  1. #!/bin/bash
  2. shell=$SHELL
  3. #zsh
  4. if [ "$shell" == "/bin/zsh" ]
  5. then
  6. echo "zsh"
  7. #文件不存在时
  8. if [ ! -f "$HOME/.zshrc" ]; then
  9. echo "not exist"
  10. else
  11. echo "exist"
  12. #mac下比较特殊,需加一个空的字符串表示备份文件
  13. sed -i "" '/JAVA_HOME/d' $HOME/.zshrc
  14. fi
  15. source $HOME/.zshrc
  16. #bash
  17. elif [ "$shell" == "/bin/bash" ]; then
  18. echo "bash"
  19. #不存在bash_profile文件
  20. if [ ! -f "$HOME/.bash_profile" ]; then
  21. echo "bash_profile not exist,..."
  22. else
  23. #存在bash_profile
  24. #删除JAVA_HOME
  25. sed -i "" '/JAVA_HOME/d' $HOME/.bash_profile
  26. fi
  27. #刷新
  28. source $HOME/.bash_profile
  29. fi
  30. sudo rm -rf /Library/Java/JavaVirtualMachines