0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux] bashの設定ファイルについて

Posted at

この記事について

Linuxの設定ファイルについて混乱したのでまとめる。

設定ファイルの役割

シェルを起動するたびに、環境変数/エイリアス/シェル関数を定義するのは手間がかかる。bashの起動時に読み込まれる設定ファイルにそれらを定義することで、恒久的に設定が反映される。

  • /etcディレクトリの設定ファイル
    全ユーザに反映される
  • ホームディレクトリの設定ファイル
    各ユーザごとに反映される
設定ファイル 役割
/etc/profile 全ユーザを対象に、環境変数/エイリアス等を定義する
~/.bash_profile 各ログインユーザを対象に、環境変数を定義したり、ログイン時に実行したいコマンドを設定する。さらに、~/.bashrcを呼び出す役割もある。
~/.bash_login 各ログインユーザを対象に、環境変数を定義したり、ログイン時に実行したいコマンドを設定する。~/.bash_profile及び~/.profileが存在しない場合のみ実行される。
~/.profile 各ログインユーザを対象に、環境変数を定義したり、ログイン時に実行したいコマンドを設定する。~/.bash_profile及び~/.bash_loginが存在しない場合のみ実行される。
~/.bashrc 各ログインユーザを対象に、環境変数以外の変数の定義/エイリアス・シェル関数定義等を行う。
~/.bash_logout シェルが終了し、ユーザがログアウトする際に実行したいコマンドを定義する。

設定ファイルの実行フロー

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?