1. 程式人生 > >第三十七課預習任務

第三十七課預習任務

1.程式碼管理平臺介紹

2.安裝svn

2.1使用yum 安裝

2.2 啟動svn服務

3.客戶端上使用svn(linux)

3.1安裝svn

3.2 客戶端連線svn伺服器

3.3使用svn

4.客戶端上使用svn(windows)

5.單機上使用git

5.1安裝git

 5.2建立git資料檔案,並初始化

5.3 使用git

5.4 git相關操作

6.建立遠端倉庫

6.1 建立gitlab賬號

6.2 將本地倉庫推送到遠端倉庫

7.克隆遠端倉庫

7.1首先我們在遠端github伺服器上建立一個test程式碼檔案

7.2在本地linux伺服器上克隆遠端伺服器程式碼

7.3 本地新增檔案推送到伺服器上

8.分支管理

9.遠端分支管理

10.標籤管理

11.git別名

12.搭建git伺服器

12.1 建立git使用者並建立.ssh檔案

12.2 在伺服器上建立倉庫目錄並初始化

12.3在客戶機上克隆遠端伺服器程式碼

13.安裝gitlab

13.1 安裝依賴包

13.2 安裝 gitlab-ce 社群版 (yum方式,ee是企業版,收費)

13.3、配置並開啟 gitlab

14.使用gitlab

15.gitlab備份和恢復


1.程式碼管理平臺介紹

版本控制,記錄若干檔案內容變化,以便將來查閱特定版本修訂情況  版本管理工具發展簡史,cvs svn  git  參考http://luckypoem14.github.io/test/2012/04/24/scm-history/  

svn全稱subversion,是一個開源版本控制系統,始於2000年  git是linux創始人linus發起的,2005年釋出,最初目的是更好管理linux核心程式碼  git和svn不同在於git不需要依賴服務端就可以工作,即git是分散式的  關於git和svn的比較大家參考http://blog.lishiming.net/?p=305  github是基於git的線上web頁面程式碼託管平臺,可以選擇付費服務  gitlab可以認為是一個開源的github,兩者沒有直接關係。

2.安裝svn

2.1使用yum 安裝

[[email protected] ~]# yum install -y subversion
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                     | 5.9 kB  00:00:00     
 * base: ftp.cuhk.edu.hk
 * epel: epel.mirror.angkasa.id
 * extras: ftp.cuhk.edu.hk
 * updates: ftp.cuhk.edu.hk
..........................................................................................

建立版本庫 
[[email protected] ~]# mkdir -p /data/svnroot/myproject
[[email protected] ~]# svnadmin create /data/svnroot/myproject
//編輯auth配置
[[email protected] conf]# vim authz

[groups]
//加入以下檔案
admins = user1,user2
[/]
@admins = rw
*= r
[myproject:/]
user1 = rw

//編輯passwd配置
[[email protected] conf]# vim passwd
//為剛剛建立的使用者設定密碼
[users]
user1 = user1_^^^123
user2 = user2-***123

//編輯svnserve.conf
[[email protected] conf]# vim svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = /data/svnroot/myproject

2.2 啟動svn服務

[[email protected] conf]# svnserve -d -r /data/svnroot
[[email protected] conf]# ps aux |grep svn
root       1233  0.0  0.0 180716   808 ?        Ss   21:38   0:00 svnserve -d -r /data/svnroot
root       1235  0.0  0.0 112704   960 pts/0    R+   21:38   0:00 grep --color=auto svn

3.客戶端上使用svn(linux)

3.1安裝svn

[[email protected] ~]# yum install -y  subversion
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                     | 5.9 kB  00:00:00     
 * base: mirror.vpshosting.com.hk
 * epel: sg.fedora.ipserverone.com
 * extras: mirror.vpshosting.com.hk
 * updates: mirror.vpshosting.com.hk
.....................................................................................


3.2 客戶端連線svn伺服器

[[email protected] ~]# svn checkout svn://192.168.139.135/myproject --username=user1
Authentication realm: <svn://192.168.139.135:3690> /data/svnroot/myproject
Password for 'user1': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://192.168.139.135:3690> /data/svnroot/myproject

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
Checked out revision 0.
[[email protected] ~]# cd myproject 
[[email protected] myproject]# ls -la
total 0
drwxr-xr-x  3 root root  18 Nov 22 21:27 .
dr-xr-x---. 5 root root 200 Nov 22 21:27 ..
drwxr-xr-x  4 root root  75 Nov 22 21:27 .svn

3.3使用svn

//新建一個檔案
[[email protected] myproject]# vim 1.txt
//上傳到伺服器上
[[email protected] myproject]# svn add 1.txt
A         1.txt
[[email protected] myproject]# svn commit -m “1.txt”
Adding         1.txt
Transmitting file data .
Committed revision 1.



[[email protected] myproject]# svn log
------------------------------------------------------------------------
r2 | user1 | 2018-11-22 21:47:56 +0800 (Thu, 22 Nov 2018) | 1 line

“1.txt”
------------------------------------------------------------------------
r1 | user1 | 2018-11-22 21:47:17 +0800 (Thu, 22 Nov 2018) | 1 line

“1.txt”
------------------------------------------------------------------------

4.客戶端上使用svn(windows)

  • 官網 https://tortoisesvn.net/index.zh.html  
  • 下載TortoiseSVN 並安裝  
  • 簡明教程 http://www.jianshu.com/p/6b3b7b915332

5.單機上使用git

5.1安裝git

[[email protected] conf]# yum install -y git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.cuhk.edu.hk
 * epel: epel.mirror.angkasa.id
 * extras: ftp.cuhk.edu.hk
 * updates: ftp.cuhk.edu.hk
Resolving Dependencies
........................................................................

 5.2建立git資料檔案,並初始化

[[email protected] ~]# mkdir /data/gitroot
[[email protected] ~]# cd /d
data/ dev/  
[[email protected] ~]# cd /data/gitroot/
[[email protected] gitroot]# git init
Initialized empty Git repository in /data/gitroot/.git/
[[email protected] gitroot]# vim 2.txt

5.3 使用git

//把2.txt新增到倉庫
[[email protected] gitroot]# git add 2.txt
//add完了必須要commit才算真正把檔案提交到git倉庫裡
[[email protected] gitroot]# git commit -m "add new file 2.txt"
[master (root-commit) 01b6c8a] add new file 2.txt
 Committer: root <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 3 insertions(+)
 create mode 100644 2.txt



[[email protected] gitroot]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   2.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
[[email protected] gitroot]# git diff 2.txt
diff --git a/2.txt b/2.txt
index 5ee294b..b4b7152 100644
--- a/2.txt
+++ b/2.txt
@@ -1,3 +1,3 @@
 kjxxxxxxxxxxxxx..........
 2988888888888
-
+477438477777777

5.4 git相關操作

  • 版本回退
  •  多更改幾次2.txt,然後add,commit
  •  git log//檢視所有提交記錄
  •  git log --pretty=oneline//一行顯示
  •  git reset --hard f7c8e9//回退版本,其中後面跟的字串是簡寫
  •  撤銷修改
  •  rm -f 2.txt//不小心刪除了2.txt
  •  git checkout -- 2.txt//恢復2.txt
  •  如果2.txt檔案修改,add後但沒有commit,再想回退到上一次提交的狀態,可以使用git reset HEAD 1.txt,再執行git checkout -- 2.txt
  •  git reflog //檢視所有歷史版本
  • 刪除檔案  echo -e "11111111111\n2222222222" > 2.txt  
  • git rm 2.txt  
  • git commit -m "rm 2.txt"

6.建立遠端倉庫

6.1 建立gitlab賬號

首先到 https://github.com 註冊一個賬號,建立自己的git,點repositories 再點new  名字自定義,比如叫studygit  選擇public  點 create repository  新增key:右上角點自己頭像,選擇settings,左側選擇SSH and GPG keys  左側點New SSH key,把linux機器上的~/.ssh/id_rsa.pub內容貼上到這裡

6.2 將本地倉庫推送到遠端倉庫


//這一步是在遠端建立一個新的倉庫studygit,名字儘量和本地的一致
[[email protected] gitroot]# git remote add origin [email protected]:knightlai/gitroot.git

//然後把本地的studygit倉庫推送到遠端的studygit下一次再推送,就可以直接 git push
[[email protected] gitroot]# git push -u origin master
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Counting objects: 3, done.
Writing objects: 100% (3/3), 225 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/knightlai/gitroot/pull/new/master
remote: 
To [email protected]:knightlai/gitroot.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.



[[email protected] gitroot]# ls
2.txt

 在網站上的github上面也可以看到我們推送上去的本地倉庫的內容

7.克隆遠端倉庫

7.1首先我們在遠端github伺服器上建立一個test程式碼檔案

7.2在本地linux伺服器上克隆遠端伺服器程式碼

[[email protected] ~]# git clone  [email protected]:knightlai/test.git
Cloning into 'test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
[[email protected] ~]# ls
anaconda-ks.cfg  test
[[email protected] ~]# cd test
[[email protected] test]# ls
test

7.3 本地新增檔案推送到伺服器上

//編輯一下程式碼檔案
[[email protected] test]# vim test 
//上傳到遠端伺服器上
[[email protected] test]# git add test
[[email protected] test]# git commit -m "test"
[master 3dc3f3c] test
 Committer: root <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)
[[email protected] test]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 271 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To [email protected]:knightlai/test.git
   cf3ea15..3dc3f3c  master -> master

8.分支管理

  • git branch //檢視分支  
  • git branch aming  //建立分支  
  • git checkout  test//切換到了test分支下  再用git branch檢視,會看到有兩個分支master和test,當前使用的分支前面會有一個*在aming分支下 ,編輯2.txt,並提交到新分支  echo "askdfjlksadjflk" >  2.txt  git add 2.txt  git commit -m "laksjdflksjdklfj"  切換回master分支  
  • git checkout master //此時cat 2.txt發現並沒有更改內容

 git checkout master //合併分支之前,先切換到目標分支  git merge test   //把test分支合併到了master  如果master分支和test分支都對2.txt進行了編輯,當合並時會提示衝突,需要先解決衝突才可以繼續合併。  解決衝突的方法是在master分支下,編輯2.txt,改為aming分支裡面2.txt的內容。 然後提交2.txt,再合併aming分支。  但是這樣有一個問題,萬一master分支更改的內容是我們想要的呢? 可以編輯2.txt內容,改為想要的,然後提交。切換到test分支,然後合併master分支到test分支即可(倒著合併)。合併分支有一個原則,那就是要把最新的分支合併到舊的分支。也就是說merge後面跟的分支名字一定是最新的分支。  git  branch -d test //刪除分支  

如果分支沒有合併,刪除之前會提示,那就不合並,強制刪除  git branch -D test

  • 對於分支的應用,建議大家以這樣的原則來:  master分支是非常重要的,線上釋出程式碼用這個分支,平時我們開發程式碼不要在這個分支上。  
  • 建立一個dev分支,專門用作開發,只有當釋出到線上之前,才會把dev分支合併到master  
  • 開發人員應該在dev的基礎上再分支成個人分支,個人分支(在自己pc上)裡面開發程式碼,然後合併到dev分支

9.遠端分支管理

  • 本地新建的分支如果不推送到遠端,對其他人就是不可見的  
  • 檢視遠端分支  git ls-remote origin,可以看到所有分支  對於git push分支分兩種情況  
  • 當本地分支和遠端分支一致時  git push會把所有本地分支的變更一同推送到遠端,如果想只推送一個分支,使用git push origin branch-name  
  • 當本地分支比遠端分支多,預設git push 只推送本地和遠端一致的分支,想要把多出來的本地分支推送到遠端時,使用git push origin branch-name  如果推送失敗,先用git pull抓取遠端的新提交  
  • git clone的時候預設只把master分支克隆下來,如果想把所有分支都克隆下來,需要手動建立,在本地建立和遠端分支對應的分支,使用git checkout -b branch-name origin/branch-name,本地和遠端分支的名稱要一致

10.標籤管理

標籤類似於快照功能,可以給版本庫打一個標籤,記錄某個時刻庫的狀態。也可以隨時恢復到該狀態。  

  • git checkout master 先切到master分支上  
  • git tag v1.0  給master打一個標籤v1.0  
  • git show v1.0 檢視標籤資訊  
  • git tag 可以檢視所有的標籤  tag是針對commit來打標籤的,所以可以針對歷史的commit來打tag  
  • git log --pretty=oneline --abbrev-commit  //先檢視歷史的commit  
  • git tag v0.9 46d3c1a  //針對歷史commit打標籤
  •  git tag -a v0.8 -m "tag just v1.1 and so on" 5aacaf4  //可以對標籤進行描述  
  • git tag -d v0.8  //刪除標籤  
  • git push origin v1.0   //推送指定標籤到遠端  
  • git push --tag origin   //推送所有標籤  
  • 如果本地刪除了一個標籤,遠端也想要刪除需要這樣操作:  
  • git tag v1.0 -d    //刪除本地標籤  
  • git push origin :refs/tags/v1.0   //刪除遠端標籤

11.git別名

  • git commit 這個命令是不是有點長? 用別名可以提高我們的工作效率  
  • git config --global alias.ci commit  
  • git config --global alias.co  checkout
  •  git config --global alias.br  branch  
  • 檢視git別名使用命令  
  • git config --list |grep alias  
  • 查詢log小技巧:  git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"  
  • 取消別名  git config --global --unset alias.br

12.搭建git伺服器

12.1 建立git使用者並建立.ssh檔案

[[email protected] test]# useradd -s /usr/bin/git-shell git
[[email protected] test]# cd /home/git
[[email protected] git]# mkdir .ssh
[[email protected] git]# touch .ssh/authorized_keys
[[email protected] git]# chown -R git.git .ssh
[[email protected] git]# chmod 600 .ssh/authorized_keys

12.2 在伺服器上建立倉庫目錄並初始化

定好儲存git倉庫的目錄,比如 /data/gitroot
[[email protected] git]# cd /data/gitroot/
//會建立一個裸倉庫,裸倉庫沒有工作區,因為伺服器上的Git倉庫純粹是為了共享,所以不讓使用者直接登入到伺服器上去改工作區,並且伺服器上的Git倉庫通常都以.git結尾
[[email protected] gitroot]# git init --bare sample.git
Initialized empty Git repository in /data/gitroot/sample.git/
//以上操作是在git伺服器上做的,平時git伺服器是不需要開發人員登入修改程式碼的,它僅僅是充當著一個伺服器的角色,就像github一樣,平時操作都是在我們自己的pc上做的
[[email protected] gitroot]# chown -R git.git sample.git

12.3在客戶機上克隆遠端伺服器程式碼

[[email protected] ~]# git clone [email protected]:/data/gitroot/sample.git
Cloning into 'sample'...
The authenticity of host '192.168.139.135 (192.168.139.135)' can't be established.
ECDSA key fingerprint is SHA256:oWZvsZbwSgQLmlEi0WFIF+R3I7UIQ0bYV1Yr6+gKNiw.
ECDSA key fingerprint is MD5:74:91:0c:c2:cc:71:31:0a:8a:cc:07:c1:7b:4b:44:0d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.139.135' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.

//在客戶端上可以看到從伺服器上拉取下來的程式碼
[[email protected] ~]# ls
anaconda-ks.cfg  myproject  sample
[[email protected] ~]# cd sample/
[[email protected] sample]# ls
[[email protected] sample]# cd myproject
-bash: cd: myproject: No such file or directory
[[email protected] sample]# cd ..
[[email protected] ~]# cd myproject/
[[email protected] myproject]# ls
1.txt  fstab

13.安裝gitlab

13.1 安裝依賴包

yum install curl policycoreutils openssh-server openssh-clients

systemctl enable sshd  &&  systemctl start sshd

yum install postfix

systemctl enable postfix  &&  systemctl start postfix

firewall-cmd --permanent --add-service=http    //永久設定http服務開放

systemctl reload firewalld

13.2 安裝 gitlab-ce 社群版 (yum方式,ee是企業版,收費)

[[email protected] ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh |sudo bash
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
....................................................................................

[[email protected] ~]# yum install gitlab-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.cuhk.edu.hk
 * epel: epel.mirror.angkasa.id
 * extras: ftp.cuhk.edu.hk
 * updates: ftp.cuhk.edu.hk
Resolving Dependencies
--> Running transaction check
.......................................................................................

2、安裝 gitlab-ce 社群版(rpm包安裝方式)

wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-XXX.rpm/download

rpm -i gitlab-ce-XXX.rpm

 

13.3、配置並開啟 gitlab

gitlab-ctl reconfigure   //此時會輸入如下很多資訊,並啟動好多服務

gitlab-ctl stop/restart/start/status  啟動服務/重啟服務/停止服務

[[email protected] ~]# gitlab-ctl start
ok: run: alertmanager: (pid 3323) 869s
ok: run: gitaly: (pid 2944) 1206s
ok: run: gitlab-monitor: (pid 3028) 1157s
ok: run: gitlab-workhorse: (pid 2903) 1225s
ok: run: logrotate: (pid 2925) 1218s
ok: run: nginx: (pid 2910) 1225s
ok: run: node-exporter: (pid 3006) 1179s
ok: run: postgres-exporter: (pid 3428) 755s
ok: run: postgresql: (pid 2640) 1306s
ok: run: prometheus: (pid 3148) 1077s
ok: run: redis: (pid 2565) 1313s
ok: run: redis-exporter: (pid 3124) 1114s
ok: run: sidekiq: (pid 2885) 1233s
ok: run: unicorn: (pid 2843) 1239s
[[email protected] ~]# ps aux|grep gitlab
root       1688  1.1  1.3 833180 13280 pts/0    Sl   00:51   0:15 /opt/gitlab/embedded/bin/ruby /opt/gitlab/embedded/bin/chef-client -z -c /opt/gitlab/embedded/cookbooks/solo.rb -j /opt/gitla/embedded/cookbooks/dna.json
root       2543  0.0  0.0   4380    28 ?        Ss   00:51   0:00 runsvdir -P /opt/gitlab/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................

4、測試訪問

首次登陸會跳出設定密碼的介面,設定完後自動跳轉到登入介面,預設使用者名稱root。

登陸進去後,可以更改使用者名稱、密碼等。

初始登入時,總報502,也沒有防火牆,經檢查是記憶體不足,我是1G。

5、說明

缺點:這種方式雖然說簡單方便,但是定製型很差,預設只能使用postgre和nginx

主配置檔案:/etc/gitlab/gitlab.rb   //可以自定義一些郵件服務等

日誌地址:/var/log/gitlab/    // 對應各服務

服務地址:/var/opt/gitlab/   // 對應各服務的主目錄

倉庫地址:/var/opt/gitlab/git-data //記錄專案倉庫等提交資訊

重置配置:gitlab-ctl reconfigure    //不要亂用,會重置為最原始的配置的

重啟服務:gitlab-ctl  stop/start/restart  //啟動命令

預設安裝:postgres、nginx、redis、unicorn ......

6、配置(就是點點點,熟悉熟悉這個應用)

a、建立一個專案組groups,生成路徑/var/opt/gitlab/git-data/repositories/;

b、建立一個倉庫,可用三種方式連結,新的倉庫、已存在的資料夾、已存在的倉庫;

建立時可匯入 github、gitlab、googlecode 等其他地方的倉庫,需要對方token

14.使用gitlab

  • gitlab官網 https://about.gitlab.com/gitlab-com/  
  • 官方安裝文件 https://about.gitlab.com/installation/?version=ce#centos-7 (ce/ee)  要求伺服器記憶體不少於2g  
  • vim /etc/yum.repos.d/gitlab.repo//加入如下內容
  • [gitlab-ce] name=Gitlab CE Repository
  • baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0
  • enabled=1  
  • yum install -y gitlab-ce  gitlab-ctl reconfigure

15.gitlab備份和恢復

  • gitlab備份  gitlab-rake gitlab:backup:create  備份目錄在/var/opt/gitlab/backups  
  • gitlab 恢復  先停服務 gitlab-ctl stop unicorn ; gitlab-ctl stop sidekiq  gitlab-rake gitlab:backup:restore BACKUP=xxxxx (這裡是一個編號,即備份檔案的字首)  
  • 再啟動服務 gitlab-ctl start 

注意:我用git add file新增檔案時出現這樣錯誤:

fatal: Not a git repository (or any of the parent directories): .git

提示說沒有.git這樣一個目錄,解決辦法如下:

git init就可以了!

 

參考文章:https://www.linuxidc.com/Linux/2017-04/142665.htm