Last-modified: 2020-07-05 (日) 14:49:40
MacTips/チートシート

はじめに

LinuxTips/チートシートを流用できる事が多々あります。
OS Xはほぼターミナル操作しかしないので、GUI系のtipsは殆ど載りません。

パッケージ(MacPorts)

リスト更新

Everything is expanded.Everything is shortened.
  1
 
sudo port -v sync

更新

Everything is expanded.Everything is shortened.
  1
 
sudo port selfupdate

インストール

Everything is expanded.Everything is shortened.
  1
 
sudo port install <パッケージ名>

パッケージ検索

Everything is expanded.Everything is shortened.
  1
 
port search <パッケージ名>

インストール済みのパッケージ一覧

Everything is expanded.Everything is shortened.
  1
 
port installed

パッケージ(homebrew)

リスト更新

Everything is expanded.Everything is shortened.
  1
 
brew update

更新

Everything is expanded.Everything is shortened.
  1
 
brew upgrade

インストール

Everything is expanded.Everything is shortened.
  1
  2
  3
-
|
!
# デフォルト設定では/usr/local/Cellar以下にインストールされる
# /usr/local/bin or /usr/local/sbinにシンボリックリンクが貼られるので、ここをPATHに含めると操作しやすい
brew install <パッケージ名>

再インストール

Everything is expanded.Everything is shortened.
  1
 
brew reinstall <パッケージ名>

パッケージ検索

Everything is expanded.Everything is shortened.
  1
 
brew search <パッケージ名>

インストール済みのパッケージ一覧

Everything is expanded.Everything is shortened.
  1
 
brew list

アンインストール

Everything is expanded.Everything is shortened.
  1
 
brew uninstall <パッケージ名>

パッケージ詳細

Everything is expanded.Everything is shortened.
  1
 
brew info <パッケージ名>

設定確認

Everything is expanded.Everything is shortened.
  1
 
brew --config

ネットワーク

接続している無線の詳細な状態を確認

メンテナンス

FileVaultの無効化

ディスクアクセスが遅すぎてキレてしまった場合、これで修復(or緩和)できる事があります

ディスクの修復

ディスクアクセスが遅すぎてキレてしまった場合、これで修復(or緩和)できる事があります

アクセス権の修復

ディスクアクセスが遅すぎてキレてしまった場合、これで修復(or緩和)できる事があります

S.M.A.R.T.取得

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
 
 
 
-
!
brew install smartmontools
sudo smartctl -a <デバイス>
 
# 例 デバイスはdfで確認可能
sudo smartctl -a /dev/disk1

ベンチマーク

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 
 
-
|
|
!
 
-
!
 
-
|
|
|
!
 
 
 
 
 
 
 
 
 
 
brew install bonnie++
 
# ファイル作成、読み込み、削除計測に使用するデフォルトテスト値が小さすぎて
# 計測不能となるので[-n]でそれなりの値を設定する必要がある
# rootユーザーが実行する場合は、[-u root]が必要
sudo bonnie++ -d <作業ディレクトリ> -n <回数>:<最大サイズ>:<最小サイズ>:<ディレクトリ階層> -u <ユーザー名>
 
# 例.
sudo bonnie++ -d /tmp -n 256:1024:1024:16 -u root
 
# 結果
# 計測内容
# シーケンシャルライト(3パターン), シーケンシャルリード(2パターン), ランダムアクセス
# シーケンシャルなファイル作成/読み込み/削除, ランダムなファイル作成/読み込み/削除
Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
a-osx.local    300M   601  99 214546  27 240958  20  1438  99 +++++ +++ +++++ +++
Latency             20687us   16232us    7949us   11253us      98us     108us
Version  1.97       ------Sequential Create------ --------Random Create--------
a-osx.local         -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files:max:min        /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
    50:1024:1024/16  3736  57  2382   8 16731  92   609   8   292   1  2383  15
    Latency               544ms    2134ms    1433us   16203ms    2184ms   54901us
    1.97,1.97,a-osx.local,1,1416317394,300M,,601,99,214546,27,240958,20,1438,99,+++++,+++,+++++,+++,50,1024,1024,,16,3736,57,2382,8,16731,92,609,8,292,1,2383,15,20687us,16232us,7949us,11253us,98us,108us,544ms,2134ms,1433us,16203ms,2184ms,54901us

ファイアーウォール

デフォルトで[切]となっており、システム情報から見ると「外部からの接続を全て許可」となっている。
ただし、ポートスキャンをするとopen portはなく、5/6程度がclose, 残りがfilterdになっているので致命的ではない。
[入]にしてステルスオプションをつけると、全てfilterdになる。

ファイルシステム

アンマウント

Everything is expanded.Everything is shortened.
  1
 
diskutil unmount /Volumes/<対象>

パーティション一覧

Everything is expanded.Everything is shortened.
  1
 
diskutil list

ペネトレーション

ポートスキャン

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 
 
-
|
|
|
|
|
|
|
!
-
!
 
-
!
 
-
!
 
-
!
 
-
|
brew install nmap
 
# よく使うオプション
# -p :ポート範囲
# -T4 :スキャンタイミング早め
# -A  :traceroute有効
# -v  :詳細な情報
# -F  :クイックスキャン
# -sS :SYNスキャン
# -O  :OS特定
 
#例 Intense scan
nmap -T4 -A -v 192.168.1.1
 
#例 Intense scan, all TCP ports
nmap -p 1-65535 -T4 -A -v 192.168.1.1
 
#例 Quick scan
nmap -T4 -F 192.168.1.1
 
#例 SYNスキャン, OS特定を192.168.0-255.1-254範囲に実行
nmap -OsS 192.168.0-255.1-254
 
# port
# open(開いている), closed(閉じていることがわかる), filterd(判別不能)

その他

スクリーンショット

コマンド意味
[command (⌘)] + [shift] + [3]画面全体
[command (⌘)] + [shift] + [4]矩形範囲

ddの進捗状況を確認

Everything is expanded.Everything is shortened.
  1
 
while true; do sudo killall -INFO dd; sleep 2; done

メモリ情報の取得

Everything is expanded.Everything is shortened.
  1
 
vm_stat

ブートドライブの選択(USBブートLinuxの起動などで使用)

OS停止状態で、Option長押し+電源ボタン