如何在 Ubuntu 16.04 上啟用或安裝 Byobu 用於終端管理
在本文中,我們將瞭解 Ubuntu 16.04 上的 Byobu。Byobu 是一款終端多路複用器,易於使用。Byobu 用於擁有多個視窗、控制檯和視窗內的拆分窗格,還將在終端上顯示狀態徽章和通知。
要完成本教程,我們需要安裝 Ubuntu 16.04 和具有 sudo 許可權的 Linux 使用者。
安裝或檢查 Byobu
作為 Ubuntu 16.04 的預設功能,Byobu 已安裝。但是,作為一種實踐,我們將檢查安裝和版本,如果未安裝,我們將安裝 Byobu。
要檢查 Byobu 是否已安裝,以及找出版本,我們將使用以下命令
$ byobu --version byobu version 5.106 tmux 2.1
如果我們無法看到當前版本或顯示“命令未找到”錯誤 -
$ byobu –version -bash: /usr/bin/byobu: No such file or directory
由於我們的機器上未安裝 Byobu,因此要安裝 Byobu,我們需要執行以下命令 -
$ sudo apt-get install byobu. Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'byobu-extras' for regex 'byobu.' Note, selecting 'byobu' instead of 'byobu-extras' Suggested packages: ccze gnome-terminal po-debconf ttf-ubuntu-font-family wireless-tools The following NEW packages will be installed: byobu 0 upgraded, 1 newly installed, 0 to remove and 81 not upgraded. Need to get 105 kB of archives. After this operation, 654 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 byobu all 5.106-0ubuntu1 [105 kB] Fetched 105 kB in 1s (83.6 kB/s) Preconfiguring packages ... Selecting previously unselected package byobu. (Reading database ... 89994 files and directories currently installed.) Preparing to unpack .../byobu_5.106-0ubuntu1_all.deb ... Unpacking byobu (5.106-0ubuntu1) ... Setting up byobu (5.106-0ubuntu1) ... Now the Byobu is installed on the Ubuntu
在登入時啟動和啟用 Byobu
Byobu 在安裝後預設情況下處於停用狀態,我們需要啟用 Byobu,並且我們有兩種方法可以啟用 Byobu。一種是我們可以在每次需要時啟動 Byobu,或者我們可以在登入或啟動時啟動 Byobu。
要啟動 Byobu,我們只需使用以下命令,環境將自動更改。
$ byobu
如果我們想將 byobu 啟動到我們的登入配置檔案中,我們需要使用以下命令啟用它
$ byobu–enable
Byobu 視窗管理器將在每次文字登入時自動啟動。
要稍後停用此行為,只需執行
$ byobu-disable
如果我們想停止使用 byobu,我們只需使用 byobu-disable 命令停止使用 Byobu。
啟用或設定後端多路複用器
預設情況下,Byobu 將使用 tmux 作為後端多路複用器,如果我們想將多路複用器更改為 screen,我們可以使用以下命令 -
$ byobu-select-backend Select the byobu backend:
- tmux
- screen
預設情況下啟用 tmux,如果我們想更改多路複用器,我們可以選擇 screen
啟用彩色提示
Byobu 包含一個很好的功能,即彩色提示,其中還包括上次執行命令的返回程式碼。我們可以使用以下命令啟用此功能 -
$ byobu-enable-prompt . ~/.bashrc root@ubuntu-16:~# . ~/.bashrc
請參閱下圖以瞭解 shell 中的變化
我們已配置 Byobu 以準備使用。
使用 Byobu 進行會話
由於 Byobu 使用從 F1 到 F12 的預設鍵繫結,因此預設情況下為鍵盤功能鍵。
Byobu 具有許多功能,例如會話、窗格和視窗。
我們啟動會話,以便我們可以擁有自己的視窗大小,並與具有不同螢幕尺寸的多個裝置連線。我們可以使用 Ctrl+Shift+F2 啟動新會話,並且可以使用 Alt+UP 和 Alt+Down 在開啟的會話之間向前和向後移動。
Ctrl+ D -> to exit from Byobu and close all the session we connected. F6 - > Will logout the current session and log you out of the SSH connection. Shift+F6 - > This will be used to detach the session, but the SSH connection will remain connected.
在 Byobu 上使用視窗
Byobu 能夠在單個會話內的視窗之間切換,這將使我們能夠輕鬆地透過單個連線執行多工。
- F2 → 用於開啟一個帶有新命令提示符的新視窗,可用於執行多項任務。
- F3 和 F4 分別用於向上和向下滾動視窗。
- F8 → 為當前視窗新增名稱。Ctrl+Shift+
- F3 或 F4 → 分別在列表中將當前視窗向左或向右移動。
- F7 → 回滾歷史記錄。
在 Byobu 上使用窗格
Byobu 還提供了將視窗拆分為多個窗格的能力,這兩個方向都是垂直和水平拆分。
Shift+F2 -> To split the current windows into horizontal splits. Ctrl+F2 - > To split the panes into vertical. Shift+F11 - > To Zoom the windows and back again. Alt+F11 -> To split a pane in a new window.
使用 Byobu 狀態通知
我們必須按 F9 鍵啟用狀態通知。當我們按下 F9 鍵時,將顯示 Byobu 配置選單,我們需要選擇切換狀態通知,然後按 Enter 鍵,我們可以在螢幕上看到可用選項列表,我們可以透過選擇選項來啟用它們。
選擇可用選項後,然後選擇應用並退出選單,按 F5 重新整理狀態列,因為通知對於檢視有關係統的資訊很有用。
以下是 Byobu 中提供的一些狀態通知選項
arch -> shows notification in the system architecture. battery -> shows notification for the current battery level for laptops. date -> shows notification of the current system date. disk -> shows the notification for current disk space usage. hostname -> shows the notification for a current system hostname. ip_address -> notification for shows the current system IP address. load_average -> shows the notification for current system load average. memory -> shows the notification for current memory usage. network -> shows the notification for current network usage, sending and receiving. reboot_required -> shows notification for an indicator when a system reboot is required. release -> shows the notification for current distribution version (e.g. 14.04). time -> shows the notification for current system time. updates_available -> shows notification for an indicator when there are updates available. uptime -> shows the notification for current system uptime. whoami -> shows the notification for currently logged in user.
在以上文章中,我們可以看到各種功能,並且我們已經介紹了 Byobu 中提供的一些功能,我們可以使用適合我們環境的功能,輕鬆快速地完成工作。
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP