2
6

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 3 years have passed since last update.

Homebrew 基本コマンドまとめ

Last updated at Posted at 2019-05-04

Homebrew ユーザーなのでよく利用する基本的なものをまとめてみました。
Homebrew とは Mac(or Linux)向けのパッケージ管理ソフトのこと。
パスを通してるならすぐ使えます。

基本的な利用方法

パッケージのインストール

$ brew install パッケージ名

アンインストール

$ brew uninstall パッケージ名

Homebrewを最新版にする

$ brew update

インストール済みのパッケージを更新

$ brew upgrade

パッケージの古いバージョンを削除

$ brew clearnup

インストールしたパッケージの確認

$ brew list

パッケージの探し方

$ brew search パッケージ名

Homebrewユーザーの留意点

インストールしたパッケージをupgradeしても実は旧バージョンのパッケージは削除されないんです。
なのでHomebrewユーザーは定期的に旧パッケージの削除をしないとだんだん容量が圧迫されていきます。

  1. Homebrewの更新
  2. パッケージの更新
  3. 旧版パッケージの削除をする (古いバージョン、新しいバージョンを使い分ける必要があるならやらない用が良さげ。)

を以下のように定期的に行うとよいでしょう。

$ brew update
$ brew upgrade
$ brew cleanup ## 古いバージョン、新しいバージョンを使い分ける必要があるならやらない用が良さげ。

cacheやダウンロード時のzipフォルダを消したい。

/Users/xxx/Library/Caches/Homebrew 以下にある。

cacheとダウンロードフォルダを削除

brew cleanup -s

formulae、casks関連のモノは残ったままなので、それごと消したい場合は以下のコマンドだけでOK

rm -rf "$(brew --cache)

自動起動の設定

例えば、brew でインストールした PostgreSQL がOS起動時に立ち上がるように設定してみます。

$ brew services start postgresql
==> Successfully started 'postgresql' (label: homebrew.mxcl.postgresql)

以下のコマンドでstartedと表示されたアプリが自動で起動しています。

$ brew services list
Name       Status  User   Plist
mysql      stopped
postgresql started /Users/xxx/Library/LaunchAgents/homebrew.mxcl.mysql.plist

*自動起動を停止、再起動する場合は以下のコマンド

$ brew services stop パッケージ名
$ brew services restart パッケージ名
2
6
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
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?