柴犬
    • 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
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • 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
    • Versions and GitHub Sync
    • Note settings
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync 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
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
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
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# NTUOSC Linux 社課共筆 ## 講者:柴犬 --- ## Linux 簡介 * Open Source * 廣泛用於伺服器 * 學習指令操作 * 權限管理 --- ### 作業系統 * Windows系:Windows XP、Windows 7、Windows 10 * 類UNIX系:Linux、MacOS、FreeBSD * UNIX --- ### Linux的分類 * Debian系:Ubuntu、Debian、LinuxMint * RedHat系:CentOS、OpenSUSE、RedHat、Fedora * 其他知名版本:ArchLinux、Gentoo、Android、ChromeOS --- ### Linux的檔案系統 ![](https://i.imgur.com/ndSXRMp.png) ![](https://i.imgur.com/5tXZxHj.png) 根目錄:最頂層的目錄 家目錄:放置使用者帳戶各種檔案的目錄 `/home`:放置一般使用者的家目錄 `/root`:放置super user的家目錄 `/etc`:主要放置系統檔案 `/usr`:放置系統相關軟體、服務 `/bin`:放置指令執行檔 `/sbin`:放置系統的指令執行檔 `/proc`:放置系統相關的資料 --- ### Linux的權限 ![](https://i.imgur.com/9ym8fs3.png) #### SuperUser權限 * Linux裡的SuperUser是root * Windows裡的則是Administrator Android手機的root,就是指取得手機最高權限 #### rwx * `r`: 讀取4 (read) * `w`: 寫入2 (write) * `x`: 執行1 (execute) 在指令上常用「加總」的方式來修改權限,例如'rwx'為7,'r-x'為5 #### 檔案的權限 ![](https://i.imgur.com/CIhYMRg.png) `d`:表示檔案的類型,`d`代表此檔案為資料夾,`-`代表此檔案為檔案 `rwxr-xr-x`:表示檔案rwx的權限,'-'代表無該權限,三個一組,九個共三組,由前到後分別代表「擁有者的權限」、「同群組使用者權限」、「其他使用者權限」 `2`:檔案連結數 `shiba shiba`:由前到後表示檔案的「擁有者」、「所屬群組」 `4096`:檔案的大小,單位為Byte `10月 10 22:57`:檔案的修改日期 `桌面`:檔名 所以根據這張圖,我們可以得知「桌面」這個檔案的資訊,它是資料夾,大小為4096Bytes,屬於shiba群組,為shiba所有,檔案擁有者「shiba」可以做「讀取寫入執行」,「shiba群組的人」及「其他人」只能做「讀取執行」,修改日期在10月10日22:57 --- ## 基本視窗操作、鍵盤快捷鍵 `Ctrl + Alt + T`:開啟終端機 `Ctrl + Alt + F3~F6`:開啟純文字介面 `Win + D`:顯示桌面 `Win + left`:分割視窗到左邊 `Win + right`:分割視窗到右邊 `Alt + Tab`:切換視窗 `Alt + F4`:關閉視窗 --- ## 基本終端機快捷鍵 `Ctrl + Alt + T`:開啟終端機 `Ctrl + Shift + T`:開啟終端機新分頁 `Ctrl + left/right`:游標一次移動一組字 `Ctrl + A/E`:游標移到最前面/後面 `Ctrl + C`:中斷當前指令 `Ctrl + L`:清除終端機畫面 `Tab`:自動補全指令 --- ## 基本指令 `sudo`:以root權限操作 (superuser do) `su`:登入root權限(superuser) 範例:`sudo su` `man`:可察看指令的用法、參數 範例:`man ls` `info`:可察看指令的用法、參數 範例:`info ls` 指令通常可以挾帶參數,以進行特定的操作`--help`就是個參數 `--help`:可察看指令的用法、參數 範例:`ls --help` `man`、`info`和`--help`都可以用來查詢指令,建議一定要先學會 安裝好Linux,建議先打`sudo apt update -y && sudo apt upgrade -y`(下面會解釋) ### 檔案系統操作 #### 檔案操作基礎知識 相對路徑及絕對路徑: ![](https://i.imgur.com/3ASSsLk.png) 相對路徑:參考當前路徑(例如終端機當前路徑、檔案本身的路徑),操作該路徑底下的檔案或資料夾 例如: `當前路徑為/cats`---`../dogs/哈士奇/哈哈.jpg`、`喵電感應.jpg`、`美國短毛貓/喵星人.jpg` `當前路徑為/dogs/哈士奇`---`../../Doge/fireDoge.jpg`、`../柴犬/黃柴.jpg` 絕對路徑:直接從「根目錄」開始,取得檔案或資料夾 例如: `/dogs/柴犬/黑柴.png`、`/Doge/fireDoge.png`、`/cats/喵電感應.jpg` `/`:根目錄 `~`:家目錄 `.`:當前目錄 `..`:上層目錄 #### 指令 `cd`:移動當前資料夾 (change directory) 範例:`cd /dogs/柴犬` `ls`:查看當前資料夾內容 (list),參數:`-a 列出隱藏檔案`,`-l 列出檔案詳細資料` 範例:`ls -al`、`ls -al /dogs/哈士奇`、`ls /dogs/柴犬 *.jpg` `pwd`:查看當前路徑 (print work directory) 範例:`pwd` `mkdir`:建立新資料夾 (make directory) 範例:`mkdir 晚餐` `cp`:複製檔案 (copy) 範例:`cp /cats/喵電感應.jpg /Doge` `mv`:移動、重新命名檔案 (move) 移動範例:`mv /cats/喵電感應.jpg /Doge` 重新命名範例:`mv /cats/喵電感應.jpg /cats/喵喵喵.jpg` `rm`:刪除檔案 (remove),參數:`-r ,遞迴刪除,刪除資料夾及其底下檔案`、`-f force,忽略不存在的檔案,不會出現警告訊息` 範例:`rm /cats/喵電感應.jpg`、`rm -rf /cat` `find`:尋找檔案,參數:`-name 以檔案名稱找尋`、`-size 以檔案大小找尋`、`-type 指定查找的檔案類型` 範例: `find /cats/ -name '*喵*'`、`find /dogs/ -name '*.jpg'`、`find /cats/ -type f -name '*貓*'` `cat`:將檔案印在終端機上 (concatenate) 範例:`cat /cats/喵電感應.jpg`、`cat /proc/cpuinfo` `nano`:編輯檔案 (nano) 範例:`nano /cats/喵電感應.jpg` `vim`:編輯檔案 (vim) 範例:`vim /cats/喵電感應.jpg` ### 檔案權限操作 `chmod`:改變檔案的權限 (change mode),參數:`-R 連資料夾底下的檔案一起改變` 範例:`sudo chmod 775 /cats/喵電感應.jpg`、`chmod -R 740 /dogs` `chown`:改變檔案擁有者 (change owner),參數:`-R 連資料夾底下的檔案一起改變` 範例:`sudo chown shiba /cats/喵電感應.jpg` `chgrp`:改變所屬群組 (change group),參數:`-R 連資料夾底下的檔案一起改變` 範例:`sudo chgrp shiba /cats/喵電感應.jpg` ### 安裝套件相關 #### apt apt:進階打包工具 (advanced packaging tools),是Debian系作業系統的套件管理器 #### 指令 `apt install`:安裝套件,參數:`-y 任何詢問皆肯定的回答` 範例: `sudo apt install nginx -y` `apt remove`:移除套件,參數:`-y 任何詢問皆肯定的回答`,`--purge 連設定檔也移除` 範例: `sudo apt remove nginx -y --purge` `apt update`:根據/etc/apt/sources.list中設定,去APT Server更新軟體資料庫,參數:`-y 任何詢問皆肯定的回答` 範例: `sudo apt update nginx -y` `apt upgrade`:自動找出有新版的軟體套件,並逐一升級,參數:`-y 任何詢問皆肯定的回答` 範例: `sudo apt upgrade -y` ### 系統相關 `shutdown`:關機,參數:`-r 重新開機(reboot)`,`-c 取消先前的關機指令` 範例:`shutdown now`、`shutdown -r 21:30`、`shutdown -c` `reboot`:重新開機 範例: `reboot` `systemctl start`:啟動某服務 範例: `systemctl start nginx.service` `systemctl stop`:停止某服務 範例: `systemctl stop nginx.service` `systemctl status`:查看服務當前狀態 範例: `systemctl status nginx.service` ### 網路相關 `hostname`:顯示主機名稱 範例: `hostname` `ping`:測試網址的網路狀態 範例: `ping ntuosc.org` `ip`:查看與修改網路介面的相關參數 範例:`ip addr` `ifconfig`:查看與修改網路介面的相關參數 範例:`ifconfig` `netstat`:查詢本機網路和外網的連線狀況,參數:`-a 顯示所有活動中的TCP連線` 範例:`netstat -a` `route`:查看網路通訊包路由情況 範例:`route` `telnet`:利用telnet連線 範例:`telnet ptt.cc` `ssh`:利用ssh連線 範例:`ssh bbsu@ptt.cc` --- ## 資料導向及管線指令 `>>`:Output,標準輸出至檔案,該檔案被「累加」或建立 範例:`ls >> list1.txt` `>`:Output,標準輸出至檔案,該檔案被「覆蓋」或建立 範例:`ls > list2.txt` `<`:Input,從檔案讀取文字 範例:`./add < data.txt`、`./sayHello < name.txt > saying.txt` `|`:管線命令,可將前一個指令的Output作為後一個指令的Input 範例:`ls -al | grep bash`、`ls -al | awk '{print $5}'` ## 常用軟體 * Libreoffice:辦公室軟體 * FileZilla:免費開源的FTP軟體 * VLC Media Player:影片播放軟體 * Wine:可以讓你在Linux上跑Windows的軟體 --- ## 常見用語 GUI:圖形使用者介面 (Graphical User Interface) --- ## 參考資料 [簡報連結](https://drive.google.com/open?id=1AutxE71jsoWWHpqWeAjT05tXvzqPf8Rt) [鳥哥的Linux私房菜](http://linux.vbird.org/) [UbuTW wiki](https://sites.google.com/a/ubuntu-tw.org/gwiki/) [Linux Command 命令列指令與基本操作入門教學](https://blog.techbridge.cc/2017/12/23/linux-commnd-line-tutorial/)

Import from clipboard

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 is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom 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

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

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
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare with
    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

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

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

      Syncing

      Push failed

      Push successfully