大部份的 Unix people 編輯文件或程式會使用 vi 或 vim 編輯器,
這個生出的 Alpine Linux 已經安裝了 vim 編輯器;
但是初學 Unix/Linux 的使用者一開始不習慣 vi 或 vim 編輯器,
有個比較簡單類似Windows上的notepad記事本的 nano 編輯器。
但是,這個 Alpine Linux 預設並沒有安裝 nano 編輯器,要用需自己安裝。
上面我們打 apk --help | head
其中 | head 意思是把結果 "pipe" 給 head 這命令, 因沒給 head 參數, 會只秀出前面 10 列
可以打 head --help 查看 head 的用途和用法 !
關於安裝(Install)工具或套件
前面說了,各種 Linux 版本的套件管理工具不同,
例如剛說了 Alpine Linux 用 apk 命令。
又如 Red Hat (小紅帽) Linux 以及其相關如 CentOS 和 Fedora 等
則用 rpm (代表Red hat Package Manager) 或 yum 。
注意 Ubuntu 上安裝套件使用命令是 apt install
當然可以打 apt --help 看看如何用 apt 這命令?
因為需要 root (super user)才可以做安裝動作,
如果不是 root 通常使用 sudo apt install
有權限使用 sudo 的使用者稱為 sudoer(s);
這時需要先安裝 sudo 套件並設定可以 sudo 的使用者(user)。
關於設定 sudoer 通常有兩種方法:
(1)用 usermod 把 user 加入 sudo 的 group
usermod -aG sudo tsaiwn # now tsaiwn is an sudoer
(2)用 visudo 修改 /etc/sudoers 或在 /etc/sudoers.d/ 目錄下的任何檔案。
例如在 /etc/sudoers.d/hahaha 這檔案內放以下這列: tsaiwn 免密碼就可 sudo
tsaiwn ALL=(ALL) NOPASSWD : ALL
o How To Create a Sudo User on Ubuntu(簡單)
o How To Edit the Sudoers File(What is visudo?)(詳細)
馬上來體驗使用這 PWD 的 Linux . . .
Alpine Linux ..
(1)點 +ADD NEW INSTANCE 生出一個跑 Alpine Linux 的機器
(Linux / Unix 雖然版本眾多, 但其命令約有 98% 是相同的 !)
(2)在中間黑色終端機命令窗中依序輸入以下 Unix / Linux 命令:
cat /etc/os-release # 看看這是啥系統?
pwd # 看看我在哪個目錄 Print Working Directory
touch you # 生出 you 這檔案
you # 看看電腦是否認識 you 這命令; 現在顯然不認識 :-)
./you # 在 Unix 習慣上目前目錄(.) 不在命令路徑path內, ./you 表示執行目前目錄下的 you
### 但 you 必須是可執行的檔案, 當然內容也要有命令腳本或程式機器碼
echo $PATH # 查看命令路徑, 注意 PATH 大寫; Windows 的 CMD 打 path 命令即可看
### 可用 nano 或 vim 編輯器修改 you 內容
### nano 最簡單, 只要知道 CTRL_S 存檔, CTRL_X 離開; vi 和 vim 則是 Unix people 的最愛:-)
### 也可用畫面上命令窗上方的 EDITOR (只可以編輯 /root 之下的檔案 (含子目錄) )
## 點 EDITOR, 彈出一個編輯窗, 可看到 /root 之下有 you 這檔案(剛才 touch you 生出的)
## 點 you 就會開啟 you 讓你編輯, 輸入 echo I love you 你你你
## 記得點左方的 Save 存檔; 必要時點 Reload 看看(若沒存檔就按 Reload 就白打了喔!)
### 接著回中間終端機命令窗繼續測試 Unix / Linux 命令
source you # 執行腳本 you
. you # same as above line
chmod +x you # 讓 you 變成可執行檔 (eXecutable)
./you # 執行目前目錄的 you ;; 注意打 you 仍不行是因 Unix 預設命令路徑不含 . 目前目錄
###$$$ Windows 則是永遠把 . 目前目錄當作命令路徑的第一個!!!
### Unix/Linux people 則建議永遠不要把 . 放入命令路徑!因為很危險!!
o 一個Program可以同時執行多次產生多個Process行程。
o 一個Process可以有多個Thread(執行緒)。
同一個Process內的Thread使用相同的Memory Space,但這些Thread各自擁有其Stack(堆疊)。
各Thread透過reference可存取到相同的object,但各Thread 的局部變數(Local variable)各自獨立。
..
pwd # show current working directory; should be / means root directory
## 注意 / 是 root directory; 但 /root 是 root 的家 home directory 喔
cat -n w2.py # 印出時每列編號
head -23 w2.py # 看前面 23 列
cat -n w2.py | tail -23 # show last 23 lines
file w2.py ## 不 要 一 次 全 部 貼上 不然來不及看喔
python3 w2.py # 其實 ONLY need this line
docker --help # list docker commands and what they do
docker image --help # help message about docker image
docker run --help # help message about docker run
docker run -it tsaiwn/tsaiwn:16 # pull (download) and run the image from docker hub
# 這樣你就立即有 Ubuntu 16.04 可用, 且包括 Python3 和 ssh 工具
docker run --name ggg -itp 80:5566 tsaiwn/tsaiwn:16
#這樣你跑起來後打 python3 w2.py 才有一個簡單網站可以用(port 80:5566)
docker run -it tsaiwn/tsaiwn:18 # pull (download) and run the image from docker hub
# 這樣你就立即有 Ubuntu 18.04 可用, 且包括 Python3 和 ssh 工具
# 可以打 type ssh 看看是否認識 ssh 命令 (這是 client 端)
# 也可打 service ssh status 查看 ssh daemon 狀況 (這是 server 端)
docker run -itp 8080:5566 tsaiwn/tsaiwn:18 # 也是 pull (download) and run Ubuntu 18.04
# 這樣你就立即有 Ubuntu 18.04 可用, 且可以打 python3 w2.py 讓 port 8080 有網頁, 但是..
# 但是, 我故意沒pip install flask 所以它會說找不到 Flask 模組
# 這時你只要先 pip install flask 然後再次執行 python3 w2.py 就可以有網頁啦!
## 複製/貼上 in PWD Play with Docker Window : (很重要所以說三次:-)
## use mouse to mark ==> CTRL_Insert to copy ==> CTRL_SHIFT_V to Paste
## use mouse to mark ==> CTRL_Insert to copy ==> CTRL_SHIFT_V to Paste
## use mouse to mark ==> CTRL_Insert to copy ==> CTRL_SHIFT_V to Paste
docker image ls # List images on my machine
docker images # List images on my machine; same as above command.
docker run -dt -p 80:5000 myapp # myapp 在 docker 內的 port 5000 對應到外部本機的 port 80
docker run -dt -p 8080:5678 tsaiwn/haha # test tsaiwn/haha port 5678 (注意故意用 5678)
docker run -dt -p 7788:5000 tsaiwn/dashboard # test tsaiwn/dashboard port 5000
docker run -dt -p 8088:5566 tsaiwn/haha0 # test tsaiwn/haha0 port 5566 (注意 haha0 故意用 5566)
##
docker pull ubuntu:16.04 # pull the image
docker tag ubuntu:16.04 ggyy # give the image ubuntu with Tag 16.04 an alias name ggyy
docker run -it ubuntu:16.04 # Run the image ubuntu with Tag 16.04, open interactive terminal
docker run -it ggyy # Same as above command if you had TAG it as ggyy
docker run -itd ggyy # Same as above command BUT run as daemon (在背景執行)
## -itd means interactive terminal daemon; will show container ID and then detach it,
## .. and you can attach it back to your terminal soon later
docker ps -a # see containers status and their ID (包括已經結束的 container)
docker attach 388 # attach a background container which ID begins with 388
docker search tsaiwn # search Repository
docker images
docker container ls # LiSt all running containers (docker ps -a 才能看到結束 exited 的)
docker search tsaiwn # 很重要所以多打幾次 :-)
docker run --name ggyy -itp 8088:5566 tsaiwn/tsaiwn:16 # run the image tsaiwn/tsaiwn:16
cat /etc/od-release # Unix command to see OS information
# 這時在 Ubuntu 16.04 內,敲 CTRL+P CTRL+Q 可暫時離開這 container 回到 Alpine Linux,
# 之後可用 docker attach ggyy 返回 container (因為剛有 --name ggyy 所以不用 cid)
# 還有, 因剛剛有 -p 8088:5566 把內部 port 5566 對應到外部 8088, 所以..
## 所以, 你可以打 python3 w2.py 就有前面我們說的簡單網站了!
alias dk='docker' # Unix command, so that you can use dk instead of docker
alias dks='docker image ls' # Unix command, dks == docker images
alias dkps='docker ps -a' # Unix command, dkps == docker ps -a
alias dkss='docker container ls' # Unix command, dks == docker container ls
alias dkss='docker ps -a' # this is enough for use to see containers status
## In a Docker container, Press CTRL_P then CTRL_Q will leave (detach) current docker
docker container ls # see running container(s), see their container ID
docker ps -a # see ALL containers, including "exited" containers
docker commit 3388 heyha # commit the container with ID begins with 3388 to image heyha
docker tag heyha tsaiwn/mytest3 # tag heyha as tsaiwn/mytest3
docker login # before push, you should login (my username is tsaiwn on docker hub)
docker push tsaiwn/mytest3 # push my new image to docker hub so that can be used later
docker attach 3388 # attach a background container which ID begins with 3388
# 另一種生出 Docker image 的方法是使用 docker build 從 Dockerfile 內的描述做出 image
docker build -t tsaiwnNew . --no-cache # . 表示 Dockerfile 在目前目錄
## 對啦,就是前面已經舉例做出類似 tsaiwn/haha0 的方法。
# 以下兩列 Unix/Linux 命令和 docker 無關 :-)
apt install -y iputils-ping # Unix command to install ping utility 安裝 ping 工具
cat /etc/os-release # Unix command to show OS name and version ... 查看 OS 版本資訊
Linux is an operating system which is developed by Linus Torvalds in 1991.
(當時 Linus 是芬蘭赫爾辛基大學計算機科學系大三學生。其實在他大二修 Operating Systems 課程時曾在網路新聞論壇(Newsgroup; 就是全世界互通的討論群組)貼文說他想自己寫一個作業系統,說當然不是像 GNU 那麼偉大的作業系統,但至少要像 MINIX 那樣完整)。
1991年9月,Linux Torvalds公開了Linux內核源碼0.01版,程式碼大約一萬行(10239 Lines)。程式碼被大學FTP server管理員Ari Lemmke發佈在網際網路上,網路上很多人給Linux Torvalds"按讚"鼓勵或給他意見,1991年10月又公開了0.02版。1991年12月發佈0.11版,1992年2月釋出0.12版本,並且把授權條款改為GNU 的 GPL 授權條款。1994年3月14日發布了1.0版本Linux,1996年Linus Torvalds碩士畢業,
他的學位論文是《Linux: A Portable Operating System》。
Ubuntu vs. Linux
Linux 是指作業系統的核心(Kernel),Ubuntu 是 Linux 發行版(distribution; 散播版)的一種。
Ubuntu is a Linux based Operating System and belongs to the Debian family of Linux.
其他知名的 Linux 發行版有 Red Hat (小紅帽)、Fedora(Red Hat的社群版)、CentOS、Alpine Linux等。
Anaconda 號稱是第一厲害的資料科學(Data Science)工具平台。
Anaconda 主要支援 Python 和 R 語言的安裝與套件管理。
Anaconda is a distribution of the Python and R programming languages for scientific computing.
Anaconda is primarily developed to support data science and machine learning tasks.
Anaconda提供了很多應用程序,包括好用的交互型簡易IDE Jutyter Notebook以及應用版本的JupyterLab,python的Qt控制台,數據科學開發必備的利器Spyder,輕量級的代碼編輯器VSCode,重量級的IDE Pycharm,機器學習的雲端開發環境datalore和IBM Watson studio cloud,以及資料探勘神器Orange 3等工具(VSCode 和 Pycharm 這些並不是預設安裝,但可以直接在界面中點擊安裝)。
=>
Jupyter Notebook vs PyCharm。
=>
12 BEST Python IDE & Code Editors For Mac & Windows In 2022。
* * Note that Python 3.9.x cannot be used on Windows 7 or earlier.
Ubuntu is derived from Debian.
It means that Ubuntu uses the same APT packaging system as Debian and shares a huge number of packages and libraries from Debian repositories.
It utilizes the Debian infrastructure as base.
There are hundreds of Linux distributions, only a handful of them are independent ones,
created from scratch. Debian, Arch, Red Hat are some of the biggest distributions that
do not derive from any other distribution.
繼續在PWD 網頁點 +ADD NEW INSTANCE 開啟 Linux 終端機練 來 練習使用 Unix 命令
* Unix 常用命令(讓你跟著打入練習)
PWD(Play with Docker)的 Docker 是跑帶有 Docker 引擎的 Alpine Linux系統。
所以在 PWD 點 +ADD NEW INSTANCE 後你就建立一台安裝Alpine Linux系統的機器(最多可建立五台),
然後在網頁中的 終端機視窗打:
cat /etc/os-release # 可看到目前 OS 的版本資訊
cat --help # 查看 cat 用途和用法;任何命令都可打 --help 查看
pwd # 看看目前在哪個目錄 (Print Working Directory)
type pwd # 看看 pwd 是啥命令 ( pwd 是 shell 內建的 builtin 命令 )
type type # type 也是 shell builtin 命令
type --help # 查看 type 用途和用法
type cat # 注意 type 在 Windows 的 CMD 類似 Unix 的 cat 是印出檔案內容
# 如果你習慣用 type filename 看檔案內容, 可如下 alias
alias type=cat # 這樣以後打 type fileName 就等於打 cat fileName
type /etc/os-release # 善用 TAB 鍵, 打到 /et/os 就敲 TAB鍵自動完成(auto completition)
type type # 會說找不到 type 這檔案
\type type # 用反斜線開頭表示不要查看 alias 對照表;所以這時 \type 就是原來的 type 命令
\type cat # 問 cat 是哪類命令 ?
which cat # 結果類似 \type cat
which python
which python3
which ping
whoami # show user name
ls -al / # see file/dir in root directory /
ll # unknown command now
alias ll='ls -l' # so that you can use ll as ls -l
ll / # same as ls -l / # option -a means also see hidden file ( begins with . dot)
ping -c3 mit.edu # 看看連去 mit.edu 來回要多久 ; Alpine Linux 已經安裝 ping 工具
ping -c3 ibm.com # 看看連去 ibm.com 來回要多久
man bash-builtins # 查看 有哪些 shell 內建命令以及用途用法 (系統要有安裝 manual !)
# Alpine Linux 預設沒有 manual pages !
現在來跑 Ubuntu Linux
docker run -it ubuntu # pull ubuntu:latest image and run; 這樣就變成最新版本的 Ubuntu Linux
cat /etc/os-release # 查看 OS 版本 ; 發現也是 Ubuntu 16.04
whoami # who is the user login now
man bash-builtins # 這次有 manual pages 了
man intro
man 2 intro # 看 chapter 2 簡介, system calls
man 3 intro # library functions
man 8 intro # chapter 8 for super users
man hier # 查看 Unix /Linux 檔案結構,各目錄的用途 ...
man 5 proc # process information pseudo-filesystem
ping -c3 ibm.com # 有 ping ㄟ
ping -c3 140.113.1.254 # 看看連去 NCTU (NYCU) 來回要多久
which python # 有喔!
type python3 # 也有 !!
python -V # 看 python 版本
pwd
type nano # 有
type vim # 有
ls -al /etc # see file/dir in root directory /etc
type ll # 查看 ll (小寫的 LL)
## Ubuntu 預設已經偷偷 alias ll 了!! 不必再自己 alias
ll /etc | more # 把 ll 結果 pipe 給 more, 可以按空白看下一頁或按 ENTER 往下一列
cd /tmp # jump into the dir /tmp ## 這 /tmp 任何人都可以讀取和寫入
ll
mkdir haha # 造一個子目錄 haha
cd haha # cd 跳進去該目錄
touch gg # 產生檔案 gg (若原先已經存在則會更新檔案更改日期時間)
touch yyy # 可以打 touch --help 查看
touch gps
echo "123" >> gg
echo "456" >> gg
cat gg
date >> yyy
echo "---" >> yyy
date >> yyy
echo "=== ===" >> yyy
cat yyy
cat gg
cat yyy >> gg
cat gg
cd ..
ll
cp -p haha/g* .
ll
mv gg test.txt
ll
cat gg
cat test.txt
type test.txt # 會說不認識 test.txt (不是不認識 type 喔! 因 type 是內建密令 )
alias type='cat' # 從此 type 和 cat 一樣 (Windowd CMD 用 type 印出檔案內容)
type test.txt # print out content of test.txt
## 那我要用原先內建的 type 查看命令怎辦?
\type pwd # 左邊把 \ 反斜線表示不理會 alias
\type type
unalias type # 取消 alias type
type type # 又恢復成 builtin 的 type
## 來測試可執行的檔案 eXecutable file
echo "echo 'I Love U'" >>gps # 在 gps 檔案內增加 echo 'I Love U'
cat gps # 查看 gps 內容
source gps # run this file as script file
. gps # same as above; 注意 . 點後面至少空一格 ! 對啦, 此時 . 等於 source
./gps # error, 'cause not eXecutable
chmod +x gps # make it eXecutable
./gps # run again, now OK
gps # 不認識這命令, 因為 . 不在 $PATH 命令路徑內 !
###
## 為何 Unix people 說不要把 . 放入命令路徑內?因為很危險!
# Unix / Linux 強烈建議不要把 . 放入 $PATH 命令路徑內 !
Unix/Linux 的 /tmp 任何人可以讀寫 (Unix 通常很多人連線進去 共用!)
很多人喜歡這樣:
cd /tmp
ls -l # 查看 /tmp 下有哪些檔案
## 有些人常說害人為快樂之本 ...
以前有人故意在 /tmp 內寫了一個 script 命名 ls 且內容如下一列:
\rm -R -f ~/
並且用 chmod +x ls # 把 ls 檔案設定為可以 eXecutable 可執行的!
## \rm 的 \ 反斜線表示即使你有 alias rm 也不使用 alias 的!! 確保執行 rm 命令 !
## -R 表示 recursive 也砍子目錄子子孫孫 ! -f 表示不要問, 砍就對了 !
然後, 跑去 /tmp 做 ls 或 ls -l 的就哪個那個慘叫囉 !!
從此以後, 很多人發誓再也不把 . 放到 $PATH 命令路徑內 !!!
所以你常會看到 Unix people 在寫程式時常這樣:
g++ myprog.cpp # 編譯 myprog.cpp 並 Link 成執行檔
./a.out # 因為生出的執行檔預設是 a.out
## 但 Windows 系統預設一定先找目前目錄當做命令路徑的第一個目錄!!
type test.txt # same as cat
echo "3gy388 test " >> test.txt
echo "5566 haha" >> test.txt
echo "5678gy haha" >> test.txt
type test.txt
grep "38" test.txt # filter, show only those lines contains "38"
grep "3" test.txt
grep 3 test.txt
grep "[3|8]gy" test.txt # filter, contains "3gy" or "8gy"
grep "3.*gy" test.txt # filter, 3...gy where ... can be any 0 to many char
clear
ps -aux # see process list
kill pid # kill the process which process ID is pid
kill -9 pid # force kill the process which process ID is pid
ll
cls
alias cls='clear'
cls
nano test.txt # try the simple editor nano
apt update
apt install -y nano vim # install nano, vim
nano test.txt # edit the test.txt; CTRL_S to save, CTRL_X to exit
cat test.txt
df
df .
gcc --version
apt update
## gcc/g++ ...
apt install -y gcc
gcc --version
python3 -V
apt update
apt install -y python3
python3 -V
cd /usr/local/bin # jump into /usr/local/bin
# 注意現在是在 /usr/local/bin 必須有 super user 權限才能寫入; 或左邊加 sudo (須是sudoer)
ln -s /usr/bin/python3 python # /usr/local/bin/python points to /usr/bin/python3
pip3
apt update
apt install pip3
# can NOT find pip3
apt install python3-pip # 這樣才是 安裝 pip3
cd /usr/local/bin # make sure we are in /usr/locak/bin
ln -s /usr/bin/pip3 pip # /usr/local/bin/pip points to /usr/bin/pip3
cd /
sudo --help # 如果不認識 sudo 要如下安裝
apt update # update syustem before any apt install
apt install -y sudo # 安裝 sudo 套件
sudo --help # 可以了
apt --help | head # 只要看前面 10 列
adduser tsaiwn # add a user
usermod -aG sudo tsaiwn # 讓 tsaiwn 可以用 sudo (變 sudoer )
ssh # 如果不認識 ssh 要安裝 openssh-server :
apt update
apt install -y openssh-server # allow ssh remote Login
service ssh status
service ssh start ## so that you can remote Login
## systemctl enable ssh ## seems not work in Docker
## /etc/rc.local NOT run in Docker
cd /root # jump into /root directory
ls -al
vim .bashrc # /root/.bashrc is run when root login
# 打入 :3 # in vim, jump to Line 3
# 打小寫 o # lowercase letter o to open a new line (Enter Insert mode)
service ssh start #add this line
cat /etc/os-release #add this line too
echo "My IP is `hostname -i` " # 注意 ` ` 不是單引號,是 ESC 下方的重音符號
## 重音 (反向單引號)夾著的命令會立即執行然後被結果取代 !!
# PRESS Escape # to leave insert mode
# 打入 :w # write to file (先確定寫入; 不建議用 :wq 建議分兩次)
# 打入 :q # quit vim (離開 vim )
## OR
### Do the following ...
cd /root
cat >> .bashrc <<GGYYY
service ssh start #add this line
cat /etc/os-release #add this line too
echo "My IP is `hostname -i` "
GGYYY
### 前面的 <<GGYYY 表示看到 GGYYY 開頭就結束
##改好之後可以打 bash 測試看看
bash
## 或打 su 測試看看
su
exit ### leave the shell (command interpreter) :: will terminate the container !
o 關於 Linux kernel 的 Opensource 可到 Github 抓 o Git 也是Linux作者Linus Torvalds寫的, 這是 Git 的 Opensource(Mirror) o 微軟在2018年6月以75億美元收購GitHub.com(Github 2008年2月上線) o Python 官方網站:https://www.python.org/Python Source Releases o 與Python相關, 17 Popular Python Opensource Projects on GitHub o Perl: https://www.perl.org/Perl DownloadCPAN -- Perl Archive
1.)Open VirtualBox and select New . A new window will come out.
2.)Choose your guest OS and architecture (選 64 bit, select Ubuntu)
3.)Set your Base Memory (RAM) 建議至少 2GB
4.)Click next until it show the vm storage size. 建議設定 10GB 應該就夠用!
Put how much space you need depending on your hardisk and finish the wizard
by clicking the create button.
5.)On VirtualBox main window, select START and pick your MEDIA SOURCE.
For example, select the .iso on your desktop.
6.)Finish the installation as normal install.
7.)Remove your installation .iso from the virtual optical disk drive before restarting the VM.
Fail2ban works with iptables by default.
However, installing fail2ban on CentOS 8 also installs fail2ban-firewalld
(which changes that default) .
The basic idea behind fail2ban is to monitor the logs of common services
to spot patterns in authentication failures.
Fail2ban works by dynamically altering the firewall rules to ban addresses
that have unsuccessfully attempted to log in a certain number of times.
When using the default iptables target for SSH traffic,
fail2ban creates a new chain when the service is started.
It adds a new rule to the INPUT chain that sends all TCP traffic directed
at port 22 to the new chain. In the new chain,
it inserts a single rule that returns to the INPUT chain.
IPtables and UFW both are Linux system firewalls,
the difference between them is UFW is built upon IPtables,
IPtables a very flexible tool but it's more complex as compared to UFW,
other difference is that IPtables requires a deeper understanding of TCP/IP,
which might not be the case with every Linux user.
o UFW Essentials: Common Firewall Rules and Commands
Most users think IPBan is a great alternative to Fail2ban.
CrowdSec is more than just a Fail2Ban replacement though,
and makes it a bit confusing.
See https://danielmiessler.com/study/crowdsec/
關於 MySql 與其安全設定 (如果使用 sqlite 則這部份不用看:-)
How To Install MySQL on Ubuntu 16.04
mysql security setting (mysql 安全設定)
Ubuntu 安裝完Mysql的時候預設是沒有root密碼以及相關設定的,
這時候就需要先用mysql_secure_installation這個指令來對MySQL進行初始化設定。
mysql_secure_installation
若問密碼, 按 ENTER 鍵即可
然後,原則上全部回答 y 就對了:-)
如果啟動 mysql 有啥 PID 錯誤, 就 :
sudo rm -rf /usr/local/var/mysql/*.err
sudo service mysql restart
按ESC退出insert mode
存檔並結束修改
:wq
然後重啟mysql以更新設定,
接著登入 mysql(以root使用者登入),
打 status 再次查看 characterset status
sudo service mysql restart
mysql -u root -p
status
TOPToC
在 MySql 建立 (create) new user for your application
# 登進mysql新增 MySQL 內的 user,允許連線 IP,與資料庫( db_name ),以及權限 :
CREATE USER 'user_name'@'%' IDENTIFIED BY 'user_password';
# 設定new user的user_name(e.g dashboard),允許連線的IP( % 代表允許任一IP連線)和user_password
注意, password 千萬不要含有 @ 阿不然有大麻煩 !!!
這裡的 user_name 是指 mysql 內的 user, 與 Linux user name 無關,
也不必要叫做 dashboard, 但這是要用來放在 FarmDashboard 的 config.py
內設定 DB_CONFIG = ' ... ' 用的,大約在 config.py 的 LINE 10 ~ LINE 13處。
# 看看已經有哪些 user
SELECT * FROM mysql.user;
# 給予使用者權限 privileges for new user
GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'%';
flush privileges;
說明:
ALL PRIVILEGES: allow the user to read, edit, execute and perform all tasks
across all the databases and tables.
*.*:The asterisks in this command refer to the database and table that they can access.
(* represents that all databases and tables are available)
@'%': allow the user from any IP
flush privileges; #:刷新權限以更新權限設定
詳細 mysql 的 user 與 權限 (Permissions)請參考這:
https://www.strongdm.com/blog/mysql-create-user-manage-access-privileges-how-to
建立給Application使用的database,
設定db_name (e.g dashboard)
create database db_name;
例如:
create database dashboard;
TOPToC
與 mysql 有關的一些常用 Linux 命令
# Start the MySQL service normally.
sudo service mysql start
# 或 sudo systemctl start mysql
#If you are receiving the following error message:
MySQL services are masked
# Do the below commands
sudo systemctl unmask mysql.service
sudo service mysql start
# Stop MySQL
sudo service mysql stop
# To restart MySQL service
sudo systemctl restart mysql
# 或這樣
sudo service mysql restart
# To verify if the MySQL service is started or not
sudo systemctl status mysql
# 或這樣
sudo service mysql status
# To check the MySQL version
mysql --version
# To enable MySQL to start automatically on every reboot
sudo systemctl enable mysql
# Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
# reset mysql root password
sudo mysqladmin -u root password
# Set MySQL root user password and policy, RUN mysql_secure_installation script
sudo mysql_secure_installation
# (原則上都回答 y 就是了:-)
# Start MySQL manually, without permission checks or networking.
#(通常是因忘了密碼用來進入 mysql 內修改 root 或 user 的密碼用, 正常不建議!)
sudo mysqld_safe --skip-grant-tables --skip-networking &
# 執行上句子後, 可以不用輸入密碼直接連入 mysql
mysql -u root
######
##### 如果前述 start MySQL 有錯誤, 可以做以下兩步驟後重來:
# Make MySQL service directory.
sudo mkdir /var/run/mysqld
# Give MySQL user permission to write to the service directory.
sudo chown -R mysql:mysql /var/run/mysqld
常用的 SQL commands:
# Log in without a password.
mysql -uroot mysql
*** Note that MySQL command is not case sensitive.
But also note that database name/table name/column name ARE Case sensitive.
create database [database_name];
show databases
use [database_name];
show tables
SELECT * FROM [table_name];
drop table [table_name];
drop database [database_name];
用註解寫範例句子讓使用者參考,使用者 copy 註解掉的去用即可
# DB_CONFIG =
'<database>[+<orm_lib>]://[<user>[:<password>]]<host>[:<port>]/[db_name][?charset=utf8]'
# ex: DB_CONFIG = 'mysql+pymysql://user:pass@localhost:3306/dashboard?charset=utf8'
# ex: DB_CONFIG = 'sqlite+pysqlite:///db.sqlite3'
DB_CONFIG = ' see above 2 lines'
#注意用 mysql 時 user:pass 就是你在MySQL的帳號:密碼 請不要用引號夾住!!!
如果使用 MySql 需要安裝並設定 mysql,
如果使用 SQLite 則 SQLite 已經內建在 Python3 內!
SQLite is a self-contained, file-based SQL database.
SQLite comes bundled with Python and can be used in any of
your Python applications without having to install any additional software.
See How To Use the sqlite3 Module in Python 3
### ### 關於FarmDashboard for IoTtalk 的安裝與設定請點這參考
多語系(i18n)使用說明 .. (from FarmDashboard README.md)
文字準備
## python
# use gettext('') to the needing change words.
from flask_babel import gettext
msg = gettext('Babel is good.')
# or if you want to use constant strings somewhere in
# your application and define them outside of a request,
# you can use a lazy strings lazy_gettext('').
from flask_babel import lazy_gettext
msg = lazy_gettext('Babel is good.')
## Javascript
# use {{ _('') }} to the needing change words. for example:
Q&A Q&A Q&A
Q1:如果 docker pull 或 docker run 出現如下的錯誤訊息,只要 docker login 就可以了。
docker: Error response from daemon: toomanyrequests: You have reached your pull rate limit.
You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit.
See 'docker run --help'.
A1: 只要 docker login 登入你 hub.docker.com 的帳號就可以了。
docker login
Q2:Docker 終端機內如何 Copy/Paste ?
A2:用滑鼠可 mark 終端機內一段文字,然後敲 CTRL+Insert 複製(Copy),
CTRL+Shift+V 可以貼上 (Paste)
Q3:Docker 的終端機螢幕可否變大? 字型太小可否變大?
A3: ALT+ENTER 可切換終端機變全螢幕或變回瀏覽器視窗內。
CTRL+= 字型變大
CTRL+- 字型變小
** 請注意字型變大後如果使用 nano 或 vim 等編輯器時可能位置會不準確。
Q4:我要 docker push 怎都出現 Error 不讓我 push 上去?
A4: 規定要先 tag 成 username/image:tag 形式才能 push; 例如:
docker tag tsaiwn/ubuntu ggyy # 先把原先的 tag 成 ggyy 才能移除 tsaiwn/ubuntu
docker rmi tsaiwn/ubuntu # 這時其實只是 untag 因它與 ggyy 的 iid 相同
docker tag oknew tsaiwn/ubuntu # 新版本 oknew 要 tag 成 username/image[:tag]
docker login # 必須 Login 到 docker hub 後才可以 push 上去
docker push tsaiwn/ubuntu # 沒 tag 就用是 :latest 當 tag
Q5:我可以 docker run 一個 FreeBSD 的 image 嗎?
A5: 不行啦!因為 PWD 的 docker 是基於 Linux 系統。
如果你要跑 FreeBSD 的 docker image 那必須在 FreeBSD 系統上,
在 Windows 上可以先安裝 VirtualBox 虛擬機器然後安裝 FreeBSD 外來系統。
Q6:如果出現如上圖的錯誤訊息,表示找不到虛擬隔離環境。
A6: 建立虛擬隔離環境 venv
這是因為 startup.sh 腳本內要使用 project 根目錄下 venv 的虛擬隔離環境。
o 在 project 根目錄下建立虛擬隔離環境 venv
python3 -m venv venv
o 激活虛擬環境:
source venv/bin/activate
o 重新安裝requirements.txt 內的套件
因為進入venv後等同於進入一個新環境,故須重新安裝相關檔案。
pip install -r requirements.txt
重啟 your application
倘若還是無法正常連線,請重啟VM試試
o 重開機
sudo reboot
Q7:怎知道 缺ping 要 apt install iputils-ping 呢?
A7: 問 google 大神 或用 apt-file search 如下:
apt-file search -x "/bin/ping$"
## -x 表示用 regular expression; ping$ 表示結尾 是 ping
## 不過 apt-file 需要另外安裝
## 然後要做apt-file update 這時會抓很多資料回來且空間佔用很大喔!
## (大約 600MB; 而最新版的 ubuntu docker image 也才 72MB)
## (當然搜尋也很花時間,到 google 查別人答案可能比較快:-)
References
o 關於 IoTtalk DFM (Device Feature Management)設備功能的管理
o 關於 IoTtalk DMM (Devie Model Management) 設備模型(類別)的管理
o Build your own IoT Dashboard ( using FarmDashboard)
IoTtalk Dashboard 結合影像應用於遠端環境監控系統(1)
Part 2 IoTtalk Dashboard 結合影像應用於遠端環境監控系統(2)
(1)建立 user 帳號與其相關資料
adduser tsaiwn # 建立 tsaiwn 這帳號以及相關目錄檔案等
# 也參考 useradd (只建立帳號) -- 不建議使用
(2)化名 alias 用來簡化命令的輸入(少打幾個字:-)
alias ll='\ls -al' # 讓 ll 等同 ls -al
alias dk=docker # 這樣打 dk 等於打 docker
alias # 列出目前有哪些 alias commands
(3)套件安裝管理
apt install -y vim # install vim and -y means don't ask
# Alpine Linux 用 apk
# RedHat/CentOS/Fedora 用 rpm (Redhat Package Manager) 或 yum
(4)cat # 查看檔案內容 (Windows 用 type filename)
cat ggyy # show content of file ggyy
cat /etc/os-release # show OS information
cat -n /etc/passwd
cat aaa bfile cfile > myNewFile # 把三個檔案串接後存入 myNewFile 內
wc aaa bfile cfile myNewFile # word /line count
tail /etc/passwd | cat -n # 先 tail 取後 10 列再交給 cat 編號
cat -n /etc/passwd | tail # 先編號再交給 tail 取後面10列
(5)cd ## Change Directory
cd haha # 進入 haha 子目錄
cd .. # 回上一層目錄
cd /home/tsaiwn # 進到該目錄
cd ~tsaiwn # 到 tsaiwn 的 Home directory, 通常就是 /home/tsaiwn
# 相關指令有 pwd, pudhd, popd, mkdir, rmdir, chmod -x directory, chmod +x directory
pwd # see where am I ; print working directory
pushd . # 記住目前的目錄 (在 stack) 其實不必 pushd .
pushd /etc # 記住目前目錄並且 cd 到 /etc
pwd # see where am I; should be /etc
popd # 恢復到前面做 pushd 時的目錄
pwd
(6)chmod ## CHange MODe of file or directory
chmod +x ggyy # make ggyy Runnable
# +x means eXecutable fpr file
# and +x means can cd into it if it is a directory
(7)chown ## CHange OWNer of file/directory
chown tsaiwn theFile # change theFile owner to tsaiwn
chown -R tsaiwn thatDir # change owner of thatDir recursively
## also see chgrp for change group
(8)cp # CoPy file and/or directory
cp gg yyy # copy gg to yyy
cp -p gg yyy # copy gg to yyy BUT preserve file property, for example, creation datetime
cp -p -R ggd yyd # copy recursively
(9)curl # 文字版瀏覽器, 可以模仿溜覽器, see also wget
curl https://www.nthu.edu.tw
# curl --help
# 參考 wget 命令
(10)df # 查看 how many free space on disk
df # disk free space
(11)diff # compare two files
diff filea fileb # difference between 2 files
(12)deluser # 砍掉 user 帳號以及它的檔案
deluser # delete user interactively
# see also userdel, useradd, adduser
(13)du directory # 查看 disk usage
du . # (disk usage)show how much disk used in . current directory
(14)echo message # print message
echo "message" # print message
(15)exit 離開或結束
exit # leave current shell (若是最後一個 shell 會 Logout)
(16)查看檔案類型
file myfile.txt # 查看這 myfile.txt 是哪種檔案; 注意與附檔名無關 !!
# Windows 上的檔案通常用 .xxx 附檔名判斷;但 Unix / Linux 不是!
(17)fg # foreground
fg # for ground # 把最近被踢到 background 的 job 叫回來(attach)
# 執行程式時如果最後打 & 表示在 background 執行, 立即讓出終端機
# 敲 CTRL+Z 可以把目前的 job 踢到 background, 讓出終端機
# 如果 telnet/ssh 遠端連入, 要先打 ~符號再敲 CTRL+Z 把連線暫時踢到 background
(18)find # 找尋符合條件的檔案
find /usr -name "*ggyy*" # find file name *ggyy* in /usr/*...
(19)git 須要用 apt install -y git
git clone https://github.com/... # 也可抓回 .zip 再解壓縮
(20)grep ## 過濾出含有某些字串的列
grep "ggyy" * # find file that contains ggyy
(21)groups username -- show group of username
groups root
groups tsaiwn
cat /etc/group | grep tsaiwn
(22)壓縮與解壓縮
gzip / gunzip /zip / unzip # zip/unzip files
(23)查看前幾列
head -12 myfile # show first 12 lines
(24) 查看以前打過哪些命令
history # show command history
# !38 重複執行編號 38 的命令
# 可以用 !38:p 列出編號 38 的命令且變成最近打過的命令但不執行
# 這樣可以接著按往上鍵然後修改其中某些字; 這時 CTRL_A 到最左, CTRL_E 到最右)
(25)查 IP 和 domain name
hostname -i # show IP address of current machine
hostname -I # 可能不只一個 IP address
hostname # 秀出 hostname
(26)ifconfig 須安裝 net-tools: apt install net-tools
ifconfig # show interface config information
#apt update
#apt install -y net-tools
(27)ip replace the old command ifconfig # 注意以下 apt install
ip
ip --help
#apt update
#apt install -y iproute2
#apt-file search --regexp 'bin/ip$'
### iproute2: /bin/ip
### iproute2: /sbin/ip
(28)
jobs # show running jobs
kill %2 # 殺死用 jobs 看到編號 2 的 process (注意 2 不是 PID)
# 正在執行程式時可以敲 CTRL_Z 把它踢到背景(background); 此時打 jobs 看看
# 然後再跑另外一個程式, 再敲 CTRL_Z 踢它到背景;然後再次打 jobs 看看
# 這時應該看到兩支被踢到背景的; 打 fg %1 可以叫回 (attach) 第一個 process
# 打 fg %2 當然是叫回用 jobs 看到編號 2 的 process (注意不是 PID)
(29) kill pid # 殺死 process ID 為 pid 的 process (跑起來的程式稱 process 行程; 進程)
kill 3388 # kill process whitch pid is 3388
kill -9 3388 # 如果前面那句莎不掉, 加個 -9 用力殺 :-)
(30) less file # 慢慢看 file 內容,類似 more 但可以往回捲動
# 可以打 less --help; 通常 less 須要另外安裝
# 這 less 其實是根據 more 改寫的; 打 more --help 看看
# 號稱 less is much better than more
# apt update
# apt install less
(31)
locate ggyy # lsearch filename contains ggyy
(32)查看檔案, 類似 Windows CMD 的 dir
ls
ls -al
ls -alF
ls -l
(33)程式設計師常用 make 來 build 出執行檔和做 install 動作(要寫 makefile)
make # do commands in makefile; see man make
make clear # clear 是在 makerfile 內的一個 標記(Label) clear:
make install # install 是在 makerfile 內的一個 標記(Label) install:
# 當然通常該標記下方通常是做安裝的一些命命 (copy file to system folder)
# 例如, 建立一個檔案 makefile 放入以下內容
clear:
echo not clear
install:
echo I love you!
# 然後打 make install 看看會怎樣
## 注意 makefile 檔案中各命命的左邊是敲 TAB 不是打 8 個空格!
# 使用 IDE 的則用 project file 取代 makefile
(34)查看手冊
man intro # manual introduction to chapter 1 commands
man 2 intro # manual introduction to chapter 2 system calls
man 3 intro # manual introduction to chapter 3 functions
man 6 intro # manual introduction to chapter 6 games
man 8 intro # manual introduction to chapter 8 privileged commands (for super user)
man hier # 查看 Unix /Linux 檔案結構,各目錄的用途 ...
man 5 proc # process information pseudo-filesystem
man bash
man man # manual
(35)建立目錄 (directory)
mkdir ggyy # create directory ggyy
mkdir -p /etc/abc/ggyy # -p 表示如果 parent directory 不存在就一併產生
(36)more file # 讓 user 慢慢看 file 內容; 按空白鍵顯示下一頁;按 ENTER 鍵往下一列
## 另外有 less 號稱比較好用; 因為可以往回捲 !
(37) Rename 或 移動檔案
mv fa fok # rename fa to fok
mv /tmp/gg myfile # 把 /tmp 的 gg 移動到目前目錄下並改名 myfile
(38)Octal dump 用八進位方式傾印檔案內容
od test # dump file test in octal format (印成八進位)
(39)改密碼
passwd # change my password
sudo passwd tsaiwn # change password of tsaiwn
(40)查看某機器是否活著且網路有通
ping mit.edu # 收到請回答 # need to do: apt install iputils-ping
ping 140.113.1.254 # ping NCTU/NYCU
#apt update
#apt install apt-file
#apt-file update
#apt-file search --regexp 'bin/ping$' # where is the ping command
### netutils-ping: /bin/ping
### iputils-ping: /bin/ping # we use this iputile-ping
(41)切換目錄相關
popd # cd 到之前做 pushd 時的工作目錄(從堆疊內 pop 出來給 cd 用)
# 相關命令 cd, pushd, pwd, mkdir
(42) 也是切換目錄相關, 把目前目錄推入堆疊並做 cd 到新目錄
pushd /etc # 先記住目前的目錄(推入 stack)並 cd 到 /etc
# 相關命令 cd, popd, pwd, mkdir
# 如果用 cd - (減號) 回到剛才目錄則堆疊內仍有記住並沒 pop 出來!
(43)查看目前目錄(current directory)名稱路徑
pwd # shere am I now; Print Working Directory
# 相關命令 cd, pushd, popd, mkdir
(44)查看 process
ps # show running process
ps -aux
(45)砍掉檔案或目錄 (ReMove file or directory)
rm # rmove file -- 危險 ! 殺了就不見了! 最好用 rm -i file(s)
rm -i ggyy # remove ggyy but will ask you to commit
rm -i g*.py # 互動問答砍掉 g 開頭所有 .py 檔案
alias rm='\rm -i' # 這樣比較不會不小心砍了不該砍的檔案
alias del='\rm -i' # del 檔案 -- -i 這樣比較不會不小心砍了不該砍的檔案
rmdir abcd # remove the directory abcd (must be empty)
(46)Secure (remote) CoPy
scp haha.png tsaiwn@iottalk.vip:/tmp # copy haha.pnt to /tmp on iottalk.vip via user tsaiwn
scp tsaiwn@iottalk.vip:/tmp/abc.png . # copy remote file to current directory
(47)執行腳本檔案(Script file)
source myfile # run script file myfile
source venv/bin/activate # run the script activate (to activate a python venv)
(48)secure telnet to remote machine; 須要 apt install -y openssh-server
ssh tsaiwn@iottalk.vip
# 儘量不要用 telnet 遠端連線, 改用 ssh (BBS 很多用 telnet)
# apt update
# apt install -y openssh-server
# 若要讓別人遠端連入此機器, 安裝後還須 service ssh start
# 因 Docker 開機不會走 init 程序, service ssh start 可能要放 .bashrc 內才可自動啟動 sshd 服務
# How Is SSH Different From Telnet?
(49)
su tsaiwn # become the user tsaiwn (need password if you are not super user)
sudo su tsaiwn # NOT need tsaiwn's password
whoami
su # try to become root
exit # leave current shell (若是最後一個 shell 會 Logout)
(50)
sudo # 用 super user (root)身分執行; 要先安裝 sudo 且設定 sudoers
(51)查看檔案後面幾列
tail -18 myfile # show last 18 lines
tail /etc/passwd | cat -n # 先 tail 取後 10 列再交給 cat 編號
cat -n /etc/passwd | tail # 先編號再交給 tail 取後面10列
# tail --help 看看 tail 用途用法
# Also 參考 head 命令
(52)備份(archive)與還原 (eXtract)
tar cvf mytar . # archive
tar tvf mytar # list files in tar
tar xvf mytar # eXtract files in mytar
(53)
top # show running status ...
# 參考 ps -aux
(54)建立空檔案或改變檔案最後修改的日期時間
touch ggyy.c # create file or modify file creation datetime
make # do commands in makefile
# 這裡的情境是讓 make 發現 ggyy.c 比其 object 檔案新, 強迫做編譯 (compile)
# 因 touch ggyy.c 會把 ggyy.c 的修改日期時間 改為現在
(55)
uname # print os kernel name (Linux)
# 參考 cat /etc/os-release
(56)壓縮解壓縮
unzip / zip / gzip /gunzip # zip/unzip files
(57)類似 adduser 但不建議用這 useradd
useradd test # create user account test
# 若是建立給人用的帳號, 建議用 adduser
# 因為用 useradd 只建立帳號, 沒做相關準備事項, 沒建立該 user 的 home directory
(58)類似 deluser 但不建議用這 userdel
userdel test # delete user account test(only the account)
# 建議用 deluser, 因 userdel 只砍掉帳號
(59)usermod :: modify user account data
usermod -aG sudo tsaiwn # so that tsaiwn is an sudoer -- can use sudo
# apt update
# apt install sudo # install sudo utility
# adduser tsaiwn
usermod -aG sudo tsaiwn # add tsaiwn into sudo group so that tsaiwn can use sudo
groups tsaiwn # show user tsaiwn's group(s)
cat /etc/group | grep tsaiwn # group information is in /etc/group
# Press here to see How To Create a Sudo User on Ubuntu?
# More about sudo and /etc/sudoers and /etc/sudoers.d/
(60)wc -- Word Count -- Count char/word/Line in file
wc testFile # how many chars/words/Lines in file testFile
cat aaa bfile cfile > myNewFile # 把三個檔案串接後存入 myNewFile 內
wc aaa bfile cfile myNewFile # word /line count
wc /etc/passwd
(61)秀出目前 user 的 username
whoami # show user name
cd
pwd
(62)抓取某網址的檔案或網頁
wget 網址 # 從網址抓回檔案 # 或用 curl 也可以
# 參考 curl
(63)壓縮解壓縮
zip / gzip / unzip /gunzip # zip/unzip files
前面說過Unix/Linux有些命令是內建(builtin)在 shell 命令解譯程式的,例如 bash 或 tcsh 等。
(註: csh 和 tcsh 的語法類似 C 語言;當然是指寫 Scrip 時用到 if/for/while 時)
bash 的內建命令有哪些可以打 man bash-builtins 查看。(要有安裝 Manual pages)
最基本的外部命令通常 一開始就被放在 /bin 和 /usr/bin 目錄內,
ls -l /bin | more # "pipe" 給 more 慢慢看 /bin 底下有哪些東東 !
which ls
which alias # alias 是 shell 內建命令
man bash-builtins # 查看 bash 的內建命令有哪些
which rm # 殺檔案建議用 rm -i 檔案
alias rm='\rm -i' # 這樣以後 rm filename 會先問你確定嗎???
但有些命令須要另外安裝,若遇到系統說不認識該命令,就:
sudo apt update # super user 或 root 不必打 sudo
sudo apt install 該命令 # 不過有時可能不是這樣直接,例如 ping 要 apt install iputils-ping
## 善用 google 搜尋 :-)
通常系統管理者安裝的程式會被放到 /usr/local/bin 裡面。
o
如果是程式庫(Library),系統預置的當然放 /lib 和 /usr/lib 裡面,
系統管理者安裝的會被到 /usr/local/lib 這目錄裡面。
Ubuntu is derived from Debian.
It means that Ubuntu uses the same APT packaging system as Debian and shares a huge number of packages and libraries from Debian repositories.
It utilizes the Debian infrastructure as base.
There are hundreds of Linux distributions, only a handful of them are independent ones,
created from scratch. Debian, Arch, Red Hat are some of the biggest distributions that
do not derive from any other distribution.
Unix File System structure
/ -- This is the root directory.
/root -- This is the home directory for the root user (optional).
其他 user 的 home directory 放在 /home/username
/etc/ 裡面有很多重要系統檔案,例如 passwd 等。
/etc/passwd # 記錄 user 相關資料包括其 home directory 以及 Login 用的 shell
/etc/group # 記錄 group 相關資料包括其 gid 以及哪些 user 屬於該 group
/etc/shadow # user 密碼 (有加密) # 可能被系統管理者改為別的名稱
/etc/hosts # maps hostnames/alias to IP addresses
/etc/host.conf # name resolver; specifies how host names on a network are resolved (see man bind)
/bin/ 裡面是最常用命令的程式檔案
/usr/bin/ 裡面放第二常用命令的程式檔案
/usr/local/bin/ 通常是各系統管理者安裝進去的
/sbin/ 和 /usr/sbin/ 和 /usr/local/sbin/ 當然就是給 super user 用的命令
在 Unix/Linux 的終端機 可打 man hier 查看說明(要系統有安裝 manual)。
或 點這查看網頁版 的 hier (7) (7) 表示第七章。
o 看 Linux manual pages 網頁版(建議先看各章節介紹)
man 1 introman 2 introman 3 introman 4 introman 5 introman 6 introman 7 introman 8 intro
Ubuntu is derived from Debian.
It means that Ubuntu uses the same APT packaging system as Debian and shares a huge number of packages and libraries from Debian repositories.
It utilizes the Debian infrastructure as base.
There are hundreds of Linux distributions, only a handful of them are independent ones,
created from scratch. Debian, Arch, Red Hat are some of the biggest distributions that
do not derive from any other distribution.