BryanHsu
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Week 14 - Book mode https://hackmd.io/@ncnu-opensource/By4H6JLNW ### sshfs 把遠端家目錄掛到當前目錄中 ncnu 目錄下 ``` sshfs xxx@ip:sources ./ncnu/ ``` ### ftp 查看檔案伺服器狀態 ``` sudo service proftpd status ``` ftp 連接檔案伺服器 ``` ftp x.x.x.x(ip) ``` 連線後 login 會變為: `ftp>` ``` ls:列出檔案伺服器目錄底下的東西 !ls:查看當地目錄的東西 (加!就是本地) ``` 下載檔案 ``` get 檔案 mget 檔案 //multiple get ``` 上傳檔案 ``` put 檔案 mput 檔案 //multiple put ``` 在瀏覽器網址輸入: ``` ftp://ip ``` 會有較直觀UI ### filezilla filezilla: ``` sudo apt install filezilla ``` 可以有介面執行ftp上傳與下載 ### proftpd /etc/proftpd/proftpd.conf 打開匿名使用者存取權 ``` anonymous 匿名使用者 匿名使用者的存取權限管控 ``` 查看ftp的使用紀錄及用戶 ``` ftpwho ``` 查看ftp的用戶數量 ``` ftpcount ``` config檔案架構 ````` # 關於主機相關的設定 設定項目一 參數內容 設定參數二 參數內容   # 關於某些目錄的權限設定 <Directory "完整目錄名稱"> ... ... ... </Directory>   # 關於 Anonymous 的目錄與權限設定 <Anonymous "匿名登入時候的匿名者根目錄"> ... ...  <Limit 一些動作>  ...  ...  </Limit> </Anonymous> ````` ### .ftpaccess http://manpages.ubuntu.com/manpages/bionic/zh_TW/man5/ftpaccess.5.html ### sftp 基本上跟ftp一樣,但一定要有帳號密碼才能存取(不允許匿名使用者) ``` sftp ``` ### load balance 不同 worker(apache + lightpd + nginx ) 一起工作分工分擔龐大的網路工作 :::danger 記得 default 先備份一個 ::: cd /etc/nginx/sites-avaliable/default ``` upstream backend { server 127.0.0.1:8080; server 127.0.0.1:8081; } server { listen 80; location / { proxy_pass http://backend; } } ``` ### 環境架設 ``` nginx 80 port apache 8081 port lighttpd 8080 port ``` ### 改apache port cd /etc/apache2/ sudo vim port.conf ![](https://i.imgur.com/t6C5Pd7.png) 重啟server ``` sudo service apacge2 restart sudo service lighttpd restart ``` `ls /var/www/html` 底下有三個 index ``` index.html index.lighttpd.html index.nginx-debian.html ``` ### change Nginx load balance algo: http://nginx.org/en/docs/http/load_balancing.html ### raspberry 開啟設定畫面 ``` sudo raspi-config ``` 連線到網路 > network options 電腦跟 raspberry 連同網路 > ssh 進raspberry ``` ifconfig eth0 ``` 在pi中建立mail.py檔案,程式碼如下: ```python= #!/usr/bin/python import subprocess import smtplib import socket from email.mime.text import MIMEText import datetime # Which email address want to send to = 'XXX'#(自己的gmail信箱) # Using specific gmail account gmail_user = 'XXX'#gmail帳號 gmail_password = 'XXX'#gmail密碼 # SMTP command smtpserver = smtplib.SMTP('smtp.gmail.com', 587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo() smtpserver.login(gmail_user, gmail_password) today = datetime.date.today() # Linux Specific shell command arg='ip route list' p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE) data = p.communicate() split_data = data[0].split() ipaddr = split_data[split_data.index('src')+1] my_ip = 'Your ip is %s' % ipaddr msg = MIMEText(my_ip) msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y') msg['From'] = gmail_user msg['To'] = to smtpserver.sendmail(gmail_user, [to], msg.as_string()) smtpserver.quit() ``` ### gmail 開啟低安全性應用程式 https://myaccount.google.com/lesssecureapps 用途是寄送在樹莓派開機時,寄送郵件來發出樹莓派ip 到gmail設定低安全應用程式存取權 > 開啟 ``` chmod +x mail.py ./mail.py ``` 如果遇到編碼問題無法寄信,程式碼前面加上 ``` #coding=utf-8 ``` ### :::danger 要記得去目標信箱收信,嘗試太多次可能是 ip 被 gmail ban 掉, 換一個 ip 試試看。 ::: 開機時會執行的程式 ### ``` sudo vim /etc/rc.local ``` # hw 自行 繼電器 & gpio 期末專題規劃(組名!!!極重要!!!) [繼電器的簡單 demo](https://hackmd.io/@minecola/HJVurQD0H)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully