---
# System prepended metadata

title: HOWTO - Top useful Linux commands you should know
tags: [Linux 101]

---

[toc]

# HOWTO - Top useful Linux commands you should know

:::info
**Objectives**
* Daily hands-on useful commands
* Useful commands by categories or alphabet
* Best practices for top useful commands 
:::

## Commands - (Temporary...)
### Other important
- **curl** -
- **man** -

### Archives and catalogues
- **pwd** - display current directory
- **cd** - transform Work Path
``cd (back to user directory)``
``cd .. (dack to last directory)``
``cd dir_location (to target directory)``
- **ls** - display archive name and content
``ls -l (list files in detail)``
- **cat** - 

### 

## Alphabet

* **cat** - concatenate files and print the single file's contents to the terminal
* **cd** - change directory
* **chmod** - change file mode bits
  * ``chmod 777 aaa.c``
* **chown** - change file owner and group
  * ``chown swae:swae /home/swae``
* **cp** - copy files and directories
  * ``cp /etc/network/interfaces /etc/network/interfaces.bak``
* **find** - search for files in a directory hierarchy
  * ```` 
* **grep** - print lines that match patterns
  * ```` 
* **ls** - list directory contents
  * ``ls -l``
* **mkdir** - make directories
  * ``mkdir /home/swae/workspace``
* **mv** - move (rename) files
  * ````  
* **pwd** - print working directory
* **rm** - remove files or directories
  * ``rm -f /tmp/*`` 
* **touch** - create a file without any content



## Categories

* navagation
    *pwd (目前你所在位置)
    *ls(列出所在資料夾檔案)
    *ls -a列出所在資料夾檔案(包含隱藏檔案)
    *ls -l列出所在資料夾檔案(詳細資訊)
    *ls -la列出所在資料夾檔案(詳細資訊+隱藏檔)
    *man 檢查指令(出現-bash)
    *cd  (進入別的指令)
    *mkdir + 檔案名稱(建立資料夾)
    *cat + 檔案名稱(印出檔案內容)
    *touch 資料夾名稱/檔案名稱(資料夾裡創一個檔案)
    *echo "匯入檔案" > 資料夾名稱/檔案名稱 (匯入檔案，出現-bash)
    *cp 來源檔案 目的檔案(複製檔案)
    *cp -r 來源檔案 目的檔案(複製資料夾)
    *rm 來源檔案(刪除檔案)
    *rm -r來源資料夾 (刪除資料夾)
    *rm -rf來源(強制刪除，跳過確認訊息)
    *mv 原路徑 新路徑(剪下貼上)
    *mv 原檔名 新檔名(重新命名)
    *vim 記事本(出現-bash)**install vim**
    *ctrl +r (往前搜尋指令)
* Package manager
    *sudo apt update
    *sudo apt upgrade
    *sudo apt full-upgrade
    
    *apt search 套件名稱 (查詢套件名稱)
    *sudo apt install 套件名稱(下載套件名稱）
    *sudo apt remove 套件名稱(移除套件但保留設定檔)
    *sudo apt purge 套件名稱(完全移除套件)
    *sudo apt autormove (移除不再需要的套件)
    *dpkg -l(列出所有已安裝的套件,出現-bash)


## References



## Directory Operation
* **pwd** - print working directory
* **mkdir** - make directories
  * ``mkdir /home/swae/workspace``
* **cd** - change directory
* **ls** - list files
    * ``ls -a列出所在資料夾檔案(包含隱藏檔案)``
    * ``ls -l列出所在資料夾檔案(詳細資訊)``
    * ``ls -la列出所在資料夾檔案(詳細資訊+隱藏檔)``
## File Operation
* **touch** - create a file without any content
* **cat** - concatenate files and print the single file's contents to the terminal
* **cp** - copy files and directories
  * ``cp /etc/network/interfaces /etc/network/interfaces.bak``
  * ``*cp -r 來源檔案 目的檔案(複製資料夾)``
* **mv** - move (rename) files
  * ``*mv 原路徑 新路徑(剪下貼上)
    *mv 原檔名 新檔名(重新命名)`` 
* **rm** - remove files or directories
  * ``rm -f /tmp/*`` 
  *  ``rm -r來源資料夾 (刪除資料夾)``
  * ``rm -rf來源(強制刪除，跳過確認訊息)``

## File Permissions
* **chmod** - change file mode bits
  * ``chmod 777 aaa.c``
* **chown** - change file owner and group
  * ``chown swae:swae /home/swae``
## Seach Files
* **find** - search for files in a directory hierarchy
* **grep** - print lines that match patterns
## Package manager
* **步驟**-
``1.sudo apt update && sudo apt upgrade``
 ``2.sudo apt full-upgrade``
``3.*apt search 套件名稱 (查詢套件名稱)``
``4.sudo apt install 套件名稱(下載套件名稱)``
    *sudo apt remove 套件名稱(移除套件但保留設定檔)
    *sudo apt purge 套件名稱(完全移除套件)
    *sudo apt autormove (移除不再需要的套件)
## Bash Conmands
* **man** - 檢查指令(出現-bash)
* **echo** -  "匯入檔案" > 資料夾名稱/檔案名稱 
    * (匯入檔案，出現-bash)
* **vim** - 記事本(出現-bash)
    *ctrl +r (往前搜尋指令)
* **dpkg -l** -列出所有已安裝的套件(出現-bash)

