1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EC2の.bash_profileを上書きした際にほとんどのコマンドが使えなくなった場合の対処法

Last updated at Posted at 2019-08-24

ec2とかの環境変数をいじっていて、誤って元の環境変数のパスを上書きしてしまいlsやvimなどといったほとんどのコマンドが使えなくなってしまった場合以下のようにすれば解決できる。
但し、環境によりPathが必ずしも一致するとは限らないので、そこは調べながら試してみるしかなさそう。。

環境は以下
Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type

【エラーの例】

[ec2-user@ip-○○-○-○-○○ /]$ ls
-bash: ls: コマンドが見つかりません

【解決方法】

まず以下を打ち込む!

[ec2-user@ip-○○-○-○-○○ /]$ /bin/vi ~/.bash_profile

そして、vimで.bash_profileに以下を記述します。

PATH=$PATH:$HOME/.local/bin:$HOME/bin

その後一度ログアウトして、再度EC2内にログインすれば元のコマンドが使える状態に戻っているはずです!

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?