# 聯合部課 - Linux
## Installation
### WSL
https://hackmd.io/@Kailyn/BkMi80IeF
https://hackmd.io/@Kailyn/H1N5OPKlF
1. 以系統管理員身份打開PowerShell輸入
```powershell
wsl --install
```
2. 重新開機
3. 以系統管理員身份打開PowerShell輸入
```powershell
wsl --install -d Ubuntu
```
4. 設定使用者帳號密碼
5. 測試: 在「開始」開啟ubuntu或wsl
### VSCode
install: https://code.visualstudio.com/
#### Using WSL in VSCode



## Basic Commands
### File & Directory Related
#### Listing Files/Directories (**ls**)
- ```ls```
- Files are denoted in white color
- Directories are denoted in blue color

- to show all hidden information, use ```ls -al```

#### Create a Directory (**mkdir**)
- ```mkdir {directory name}```

#### Go To Another Directory (**cd**)
- ```cd {directory name}```

- ```cd ..``` 會回到上一層directory
- ```cd ~``` 會回到home directory
#### Show Current Directory (**pwd**)
- ```pwd```

#### Create a File (**touch**)
- ```touch {file name}```

#### Edit Content of a File (**vim**)
- ```vim {file name}```

- press `i` to insert new context, and press `esc` when finishing inserting
- use ```:wq!``` to save new change and quit

#### View Content of a File (**cat**)
- ```cat {file name}```

- you can add `grep` command to search the word in the file

#### Remove a File/Directory (**rm**)
- ```rm {file name}```

- to remove a directory which is not empty, add ```-r``` tag

#### Copy File/Directory (**cp**)
- ```cp {source} {target}```

- if you want to copy a directory, add ```-r``` tag

#### Move the File/Directory (**mv**)
- ```mv {source} {target}```

- ```mv``` can also be used to rename file

### User Related
#### Give Administrative Access to Another User (**su**)
- ```su {user name}```

#### Grant Administrative Access (**sudo**)
- ```sudo {command}```
- if you encounter some permission issue, try to add ```sudo``` before the original command

- to check how much sudo access you have, run ```sudo -l```

#### Create/Change Password (**passwd**)
- ```passwd {user name}```

#### Update Package Information to System (**apt-get update**)
- ```sudo apt-get update```

#### Update Packages to Latest Version (**apt-get upgrade**)
- ```sudo apt-get upgrade```
- run ```sudo apt-get update``` first

#### Install New Dependencies (**apt install**)
- ```sudo apt install {dependency name}```

### Compression/Packaging Related
#### Zip a Folder (**zip**)
- ```zip {zip name} {folder}```

#### Unzip a Folder (**unzip**)
- ```unzip {zip name}```

- to unzip to another directory, add ```-d``` flag

#### Other File Format
ref : http://note.drx.tw/2008/04/command.html
### Networking Related
#### Check NIC(網卡) & IP Address (**ip**)
- ```ip a```

- to check ipv4 address, use ```ip -4 a```. Similarly, to chack ipv6 address, use ```ip -6 a```

- to show information of a single NIC, use ```ip a show {NIC name}```

#### Check the Connectivity of Two Nodes (**ping**)
- ```ping {destination}```

#### Check Domain Name or IP address of a Node (**host**)
- ```host {domain name} or {IP address}```

#### Create Remote Connection through ssh Protocol (**ssh**)
- ```ssh {user name}@{host(IP/domain name)}```
- if you want to specify which port to connect, add ```-p``` tag
### Other Important Commands
#### Clear terminal (**clear**)
- ```clear```
#### Show the Disk Space Used (**df**)
- ```df```

#### Show Unmounted Disk (**lsblk**)
- ```lsblk```
