Skip to content

Zeroplex 生活隨筆

軟體開發、伺服器和生活瑣事

小 縮小字型大小。 中 重設字型大小。 大 放大字型大小。

標籤: Ubuntu

為 ufw 建立應用程式的 rule set

Posted on 2017 年 5 月 5 日2021 年 3 月 12 日 By 日落 在〈為 ufw 建立應用程式的 rule set〉中尚無留言

以往在 ufw 加入防火牆規則時,都是一條一條新增上去:

ufw allow 80
ufw allow 443
ufw allow 8080
.....

這種方式雖然簡單,但是之後要維護會有點困難:到底哪個 port 是為了哪一個應用程式開的?

ufw 其實還有其他特別功能,叫做 app list:

zero@zero-x230:~$ sudo ufw app list
Available applications:
  Apache
  Apache Full
  Apache Secure
  CUPS
  Samba

會自動增測,並有預設的設定檔來幫你新增 rule set。來看一下「Apache Full」設定檔到底寫了什麼,打開「/etc/ufw/applications.d/」:

[Apache]
title=Web Server
description=Apache v2 is the next generation of the omnipresent Apache web server.
ports=80/tcp

[Apache Secure]
title=Web Server (HTTPS)
description=Apache v2 is the next generation of the omnipresent Apache web server.
ports=443/tcp

[Apache Full]
title=Web Server (HTTP,HTTPS)
description=Apache v2 is the next generation of the omnipresent Apache web server.
ports=80,443/tcp

預設有三個 rule sets,一個是 port 80,另一個是 HTTPS 的 port 443,亦或二者都開啟。

我們可以依樣畫葫蘆,建立自己的 app rule sets,像是我幫 Resilio Sync 湊出來的 rule set。

你也可以參考 Ubuntu forum 上面的教學,建立自己需要的 rule set。

Tags:Linux, Ubuntu, 資訊安全

修改 grub 開機選單等待時間 (timeout)

Posted on 2017 年 1 月 18 日2021 年 3 月 12 日 By 日落 在〈修改 grub 開機選單等待時間 (timeout)〉中尚無留言

查了很多資料,大多都說是去修改 /boot/grub/grub.cnf 的設定,但新版的 grub.cnf 事實上是電腦自動產生的,不管怎麼改參數,數值都會被覆蓋掉。

正確解法應該是直接修改 /etc/default/grub:

GRUB_TIMEOUT=10  # wait for 10 secs

修改完畢後記得更新設定:

sudo update-grub2

詳細的解說,可以參考 Grub2 – Ubuntu community wiki 上的說明。

Tags:Linux, Ubuntu

在 gnome-teminal 使用 Ctrl + arrow 切換 GNU screen 視窗

Posted on 2016 年 6 月 26 日2021 年 3 月 12 日 By 日落 在〈在 gnome-teminal 使用 Ctrl + arrow 切換 GNU screen 視窗〉中有 2 則留言

這邊標題應該下的不是很好,其實問題和 gnome-teminal 應該是沒什麼關係的。

在 windows 透過 pietty (快換 putty 吧) 連上 server 時,都是直接用 Ctrl + 左/右 來切換 windows, .screenrc 設定方式如下:

bindkey 33[C next
bindkey 33[D prev

不過當 client 是 Ubuntu 時,在 gnome-terminal 操作時,Ctrl + arraow 卻完全沒有效果。後來友人提示在 screen 底下可以先 ctrl + V,再按下 key binding,screen 會把收到的 key code 顯示出來,方便 debug。嘗試了不少種組合都沒有成功。

當 Google 第一頁搜尋結果無法找到方法時,只好往第二頁找屍體。慢慢看到有人提到需要修改 /etc/inputrc 的設定:

# allow the use of the Home/End keys
"e[1~": beginning-of-line
"e[4~": end-of-line

# allow the use of the Delete/Insert keys
"e[3~": delete-char
"e[2~": quoted-insert

....

# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"e[1;5C": forward-word
"e[1;5D": backward-word
"e[5C": forward-word
"e[5D": backward-word
"ee[C": forward-word
"ee[D": backward-word

設定檔中間可以看到 Ctrl + arrow 已經被轉成 forward-word 等操作,把那幾行註解掉即可。

ps. 除了 ssh client 這邊的 inputrc 需要修改外,server side 若有 inputrc 也需要一起修改,不然 client 送過去的 key binding 還是會被 server 改掉。

Tags:Linux, Ubuntu, 資訊學習

aptitude update 找不到 GPG key 的處理

Posted on 2016 年 3 月 24 日2021 年 3 月 12 日 By 日落 在〈aptitude update 找不到 GPG key 的處理〉中尚無留言

執行的 aptitude update 以後,出現錯誤訊息:

W: GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 00A6F0A3C300EE8C
W: GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C

可以透過下列指令去 import keys:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com {KEY}

例如上面的錯誤,可以這樣 import key:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 00A6F0A3C300EE8C
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4F4EA0AAE5267A6C

reference: How do I fix the GPG error “NO_PUBKEY”?

Tags:Ubuntu

Ubuntu PPA for new version of Git

Posted on 2016 年 3 月 17 日2023 年 1 月 8 日 By 日落 在〈Ubuntu PPA for new version of Git〉中尚無留言

舊版本的 git 有安全性漏洞,需要升級到 2.7.1 以上版本
server and client side remote code execution through a buffer overflow in all git versions before 2.7.1 (unpublished ᴄᴠᴇ-2016-2324 and ᴄᴠᴇ‑2016‑2315)

Ubuntu 14.04 的 git 還在 1.x,只好靠 PPA 抓新版本:

sudo add-apt-repository ppa:git-core/ppa
sudo aptitude update && sudo aptitude upgrade
Tags:Git, Ubuntu

文章分頁

上一頁 1 ... 4 5 6 ... 10 下一頁

其他

關於我  (About me)

小額贊助

  文章 RSS Feed

  留言 RSS Feed

Apache AWS Bash C/C++ Docker FreeBSD GCP Git Google Java JavaScript Laravel Linux Microsoft MSSQL MySQL Nginx PHP PHPUnit PostgreSQL Python Qt Ubuntu Unix Vim Web Windows WordPress XD 作業系統 分享 好站推薦 專題 攝影 新奇搞笑 新聞 旅遊 生活雜記 程式設計 網路架站 網頁設計 資訊學習 資訊安全 遊戲 音樂


創用 CC 授權條款
本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權.