Skip to content

Zeroplex 生活隨筆

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

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

標籤: Linux

Set Remote Default Port for SSH Client

Posted on 2013 年 8 月 21 日2021 年 3 月 12 日 By 日落 在〈Set Remote Default Port for SSH Client〉中尚無留言

若 sshd 改成非 port 22,不少 ssh client 操作會變成很麻煩。

但可以在 .ssh/config 設定 host name 和 url、port,之後就可僅用 host name 連線。

vim ~/.ssh/config :

Host hq
HostName server.url
Port 9999
User zero

之後要連線時打「hq」即可:

  • ssh hq
  • git remote add origin hp:/path/to/repository

Reference:
git – Using a remote repository with non-standard port – Stack Overflow

Tags:Linux

Array Iterate in Bash

Posted on 2013 年 8 月 13 日2021 年 3 月 12 日 By 日落 在〈Array Iterate in Bash〉中有 2 則留言

Bash 裡面有個 for-in 可以很輕鬆的對多筆資料做迭代,不過我語法一直弄錯。

文字列表:

LIST="item1 item2 item3"

for ITEM in $LIST; do
   echo $ITEM
done

如果是陣列,語法要換:

LIST=(  
  item1 
  item2 
  item3 
)

for ITEM in ${LIST[@]}; do
  echo $ITEM
done

Reference:
Bash For Loop Array: Iterate Through Array Values

Bash Guide for Beginners – Chapter 10. More on variables

Tags:Bash, Linux

Alias Command Contains Spaces in Bash

Posted on 2013 年 7 月 9 日2021 年 3 月 12 日 By 日落 在〈Alias Command Contains Spaces in Bash〉中尚無留言

.bashrc 下設定 command alias 的方法是:

alias svm='svn'   # 我常常手殘

不過假設要 alias 的指令包含空白,如「svn commit」要 alias 成「svn commit –editor-cmd vim」,就得靠自訂 function 了。

新增一個 function 蓋掉原本的 svn 指令,如果 svn 後接的參數是 commit,便加上 –editor-cmd:

svn(){
   if [[ $@ == commit ]]; then
      command svn commit --editor-cmd vim
   else
      command svn "$@"
   fi
}

不過 svn commit 有時還會有其他參數,像是檔案路徑等,所以這樣寫還是會發生意外。要把參數判斷要改,順便在執行指令的時候把參數也塞回去:

svn(){
   if [[ $@ == commit* ]] || [[ $@ == ci* ]]; then
      command svn "$@" --editor-cmd vim
   else
      command svn "$@"
   fi
}
Tags:Bash, Linux

修改 Ubuntu 12.04 登入畫面背景圖片

Posted on 2013 年 6 月 29 日2021 年 3 月 12 日 By 日落 在〈修改 Ubuntu 12.04 登入畫面背景圖片〉中尚無留言

開啟 /usr/share/glib-2.0/schemas/com.canonical.unity-greeter.gschema.xml,並找到「com.canonical.unity-greeter」,將 key「background」改成新的圖片路徑:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="unity-greeter">
  <schema id="com.canonical.unity-greeter" path="/com/canonical/unity-greeter/">
    <key name="background" type="s">
      <default>'/usr/share/backgrounds/warty-final-ubuntu.png'</default>
      <summary>Background file to use, either an image path or a color (e.g. #772953)</summary>
    </key>

將設定值重新編譯:

cd /usr/share/glib-2.0/schemas/
sudo glib-compile-schemas .
Tags:Linux, Ubuntu

CapsLock 提示 on Ubuntu with Mate Desktop

Posted on 2013 年 6 月 23 日2021 年 3 月 12 日 By 日落 在〈CapsLock 提示 on Ubuntu with Mate Desktop〉中尚無留言
CapsLock 提示 on Ubuntu with Mate Desktop

因為手賤,發現 ThinkPad x230 上並沒有 CapsLock 警示燈,而 Ubuntu 上面預設也不會提示,好在有工具可以用。

Indicator Keylock 能讓大小寫鎖定時,在工具列顯示圖示:

安裝 Indicator Keylock:

sudo add-apt-repository ppa:tsbarnes/indicator-keylock && sudo apt-get update
sudo apt-get install indicator-keylock

安裝完以後執行「indicator-keylock」即可。

Regerence:
Indicator Keylock Displays The Keyboard Lock Keys On Machines Without Keyboard LEDs ~ Web Upd8: Ubuntu / Linux blog
http://www.webupd8.org/2010/07/indicator-keylock-displays-keyboard.html

Tags:Linux, Ubuntu, 生活雜記

文章分頁

上一頁 1 ... 24 25 26 ... 32 下一頁

其他

關於我  (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 國際 授權條款授權.