Bash

提供: Wikinote
2009年1月24日 (土) 13:06時点におけるHagio (トーク | 投稿記録)による版

移動: 案内検索

bash を制するものが、Linux を制す —— hagio

  • export は、その変数を子プロセスに引き継ぐ場合に用いる。
  • Meta キーは ESC キーで代用可。(Poderosa では有用)

シェルスクリプト

コマンド

  • 行末までキル:C-k
  • 行頭までキル:C-u
  • 前単語をキル:C-w
  • ヤンク:C-y
  • 直前のコマンドの最後の引き数を挿入:M-. (これは便利)
  • キャンセル:C-g
  • 後方検索:C-r (これらは使い方が難しい)
  • 前方検索:C-s
  • 最終行へ:M-> (Poderosa では打ちにくい…)

.bashrc

カスタマイズしたものに慣れてしまうと、素の状態にすぐに適応できなくなってしまうので良くないが、 それでも背に腹は代えられないモノたち。

alias ..='cd ..'
alias la='ls -a'
alias ll='ls -l' # Red Hat では標準
alias lla='ls -la'
alias llh='ls -lh'
alias s='screen'
alias grep='grep -i --color=auto'

# 自動 ls
function cd { builtin cd $@; ls }
# Ctrl-s でのストップ機能を止める
stty stop undef


起動時の設定ファイルの読み込み順序

  • ログインシェルの場合 (ログイン時、su - user 時など)
    1. /etc/profile
    2. /etc/profile.d/*.sh
    3. ~/.bash_profile
    4. ~/.bashrc
    5. /etc/bashrc
  • ログインシェルでない場合 (bash 実行時、su user 時など)
    1. ~/.bashrc
    2. /etc/bashrc
    3. /etc/profile.d/*.sh

以下のコマンドで確認できる。

# strace -f -e trace=open -o su-bash.strace su - hagio