[Ubuntu] 使用 Certbot 自動更新 Let’s Encrypt 憑證

SSL For Free  是一個可以申請免費 SSL 憑證的網站,只需要準備自己的網域名稱就可以申請為期三個月的免費 SSL 憑證,小小的缺點是憑證過期後需要重新申請憑證,並且更換伺服器的舊憑證。而 Certbot  是一個可以簡化申請流程,又可以在憑證過期之前自動更新憑證的超方便工具。

Read more “[Ubuntu] 使用 Certbot 自動更新 Let’s Encrypt 憑證”

[Ubuntu] 使用 hostnamectl 修改主機名稱

早期 Ubuntu 修改主機名稱需要透過修改 /etc/hostname + 使用 hostname 指令才能完成,在某些情況下甚至需要重新啟動系統。而在 Ubuntu 13 以後的版本可以透過 hostnamectl 一個指令完成這件事情,且不需要重新啟動系統。

 

hostnamectl [OPTIONS...] COMMAND ...

Query or change system hostname.

  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname

Commands:
  status                 Show current hostname settings
  set-hostname NAME      Set system hostname
  set-icon-name NAME     Set icon name for host
  set-chassis NAME       Set chassis type for host
  set-deployment NAME    Set deployment environment for host
  set-location NAME      Set location for host

Read more “[Ubuntu] 使用 hostnamectl 修改主機名稱”

[Ubuntu] Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

如題,在使用 APT 安裝套件時,如果當下有其它的 APT process 執行中,便會出現下列錯誤訊息:

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it? 

Read more “[Ubuntu] Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?”

[Python] Django – “no module named django.core.management”

利用 django-admin.py 建立一個新專案後,準備要在專案目錄底下用 manage.py 開始做事情時,出現了詭異的錯誤訊息:

$ python manage.py
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

 

錯誤訊息中的大意是找不到 django.core.management 這個 module,利用下面的指令檢查一下 module source:

$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/usr/lib/python2.7/site-packages

Read more “[Python] Django – “no module named django.core.management””

[MariaDB/MySQL] 建立連線帳號與指派權限

建立帳號,其中「myaccount」是帳號,「mypassword」是密碼,主機為 localhost。

CREATE USER 'myaccount'@'localhost' IDENTIFIED BY 'mypassword';

 

權限設定的指令結構如下(MariaDB 10.2):

GRANT
    priv_type [(column_list)]
      [, priv_type [(column_list)]] ...
    ON [object_type] priv_level
    TO user  [IDENTIFIED [BY [PASSWORD] 'password']
        |{VIA|WITH} plugin_name 
           [{USING|AS} 'plugin_option']]
        [, user [IDENTIFIED [BY [PASSWORD] 'password']
        |{VIA|WITH} plugin_name] 
           [{USING|AS} 'plugin_option']]
    user_options...

GRANT PROXY ON user_specification
    TO user_specification [, user_specification] ...
    [WITH GRANT OPTION]

user_options:
    [REQUIRE {NONE | tls_option [[AND] tls_option] ...}]
    [WITH with_option [with_option] ...]

object_type:
    TABLE
  | FUNCTION
  | PROCEDURE

priv_level:
    *
  | *.*
  | db_name.*
  | db_name.tbl_name
  | tbl_name
  | db_name.routine_name

with_option:
    GRANT OPTION
  | MAX_QUERIES_PER_HOUR count
  | MAX_UPDATES_PER_HOUR count
  | MAX_CONNECTIONS_PER_HOUR count
  | MAX_USER_CONNECTIONS count
  | MAX_STATEMENT_TIME time

tls_option:
    SSL
  | X509
  | CIPHER 'cipher'
  | ISSUER 'issuer'
  | SUBJECT 'subject'

Read more “[MariaDB/MySQL] 建立連線帳號與指派權限”