Mac Linux Unix指令 === ## Terminal 指令 - 更改使用者密碼(change password) ```shell! passwd ``` - 列出現在目錄磁碟用量 ```shell! du -sh * ``` - 顯示當前工作目錄 (print working directory) ``` pwd ``` - 更改工作目錄 (change directory) ``` cd path/ ``` - 回上一個目錄 ``` cd .. ``` - 列出目前路徑底下有哪些檔案 (list) ``` ls ``` - 建立新資料夾 (make directory) ``` mkdir folder ``` - 刪除檔案 (remove) ``` rm filename ``` - 刪除資料夾 ``` rm -rf folder ``` - 建立文字檔 (使用vim或nano都可以) ``` vim temp.txt ``` - 複製檔案 ```bash! cp path/to/copy path/to/send cp Desktop/CODE/paper/README.md Desktop ``` - 複製資料夾 (Recursively clone file -r) ```bash! cp folder/to/copy folder/to/send cp Desktop/CODE/paper Desktop ``` ## SSH Key 建立local端的SSH key ```ssh ssh-keygen -t ed25519 -C "your_email@example.com" // -t ed25519:指定金鑰類型為 ed25519,這是目前推薦的演算法(比 RSA 更安全且更快)。 // -C:提供一個註解,通常是你的 email,用於辨識該金鑰。 ``` 金鑰會存在`.ssh`資料夾中: - 私鑰: `~/.ssh/id_ed25519` - 公鑰: `~/.ssh/id_ed25519.pub` 將公鑰加入到遠端伺服器或GitHub 你可以用以下指令查看公鑰內容,並複製 ```shell cat ~/.ssh/id_ed25519.pub ``` 然後將內容貼到: - 遠端伺服器的 `~/.ssh/authorized_keys`(需 SSH 登入或其他方式) - GitHub ➜ Settings ➜ SSH and GPG keys ➜ New SSH key ## Connect Remote Server - 建立遠端連線 ```ssh! ssh username@hostname ``` - 建立遠端連線 (with specific port) ```ssh! ssh -p port username@hostname ``` - 建立遠端連線 (如果有事先設定~/.ssh/config) ```ssh! ssh config_host ``` - 複製檔案(Remote To Local) > use -P with specific port (default 22) > use -r if copy folder ```shell! scp -P port username@hostname:remote/file/to/copy local/path/to/put ``` ```shell! scp -P 1002 littlfish@140.xxx.xxx.xxx:~/Desktop/temp.txt ~/Desktop/CODE ``` - 複製檔案(Local To Remote) > use -P with specific port (default 22) > use -r if copy folder ```shell! scp -P port local/file/to/copy username@hostname:remote/path/to/put ``` ```shell! scp -P 1002 ~/Desktop/CODE/temp.txt littlfish@140.xxx.xxx.xxx:~/Desktop ``` - JupyterHub ```ssh! ssh -L 8000:localhost:8000 netai_[username] ``` ## Compile C++ 相關指令 - 先創立檔案 ``` vim test.cpp ```  * 編輯模式:`a, o, i`即可開始編輯(左下角會呈現Insert) - 範例程式碼: ``` c= #include<iostream> using namespace std; int main(){ cout<<"Hello World!\n"; return 0; } ```  * 推出編輯模式:`esc` * 存檔/離開:(注意左下角) * 存檔:`:w` * 離開:`:q` * 存檔+離開:`:wq`  - 編譯C++檔案 ``` g++ test.cpp ``` 你會看到路徑底下會產生出一個新檔案`a.out`  - 執行檔案 ``` ./a.out ```  - 自定義編譯完檔案的名稱 ``` g++ test.cpp -o filename ```  ###### tags: `Toolkit`
×
Sign in
Email
Password
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