terminal
  last update:
  2020/12/17
Search :
: 0 results
ディレクトリ
pwd  // カレント表示
ls  // カレントのファイル・ディレクトリ表示
ls [dir]  // 配下のファイル・ディレクトリ表示
ls -a  // 隠しファイル表示
ls -l  // 詳細情報表示
cd /  // ルートへ移動
cd  // ホームへ移動
cd -  // 1つ前へ移動
cd ..  // 上階層へ移動
cd [dir]  // dirへ移動
mkdir [dir]   // 新規ディレクトリ作成
cp -r [dir] [dir]  // ディレクトリをコピー
mv [dir] [dir]   // ディレクトリ名変更
rmdir [dir]   // 空ディレクトリ削除
rm -r [dir]   // ファイルごとディレクトリ削除
ln -s [path] [name]  // エイリアス作成
pushd [dir]  // カレントをスタックに記録し、移動
popd  // 記録した位置へ移動し、スタックはリセット
ファイル
touch [file]  // 空ファイル作成
cp [file] [file]  // ファイルをコピー
rm [file]  // ファイルを削除
mv [file] [file]  // ファイル名変更
mv [file] [dir/file]  // ファイル移動
less [file]  // ファイル内容表示, f 次頁, b 前頁, G 文末 , /[char] 検索, q 終了
diff [file] [file]  // 差分表示
検索,置換
mdfind [string]  // ファイル名で検索
mdfind -onlyin [dir] [string]  // dir内から検索
grep -rn [string] [dir]  // dir内全てのファイルの内容からstringとその行数を検索
grep -l [from] [dir/files] | xargs sed -i -e "s/[from]/[to]/g"
// [dir/files]で指定した複数のファイルに含まれる全ての[from]を[to]に一括置換
// 元ファイルのバックアップが作成される
find . -type f -name '*.*' -print0 | xargs -0 perl -i -pe 's/[from]/[to]/g'
// カレント以下の全ての「*.*」という名のファイルに含まれる全ての[from]を[to]に一括置換
オープン
open [dir]  // Finderオープン
open [img]  // プレビューオープン
圧縮,解凍
zip -r [filename.zip] [dir]  // zip圧縮
unzip [filename.zip]  // zip解凍
履歴
history  // コマンド履歴を表示
![num]  // 指定のコマンドを再実行
!!  // 直前のコマンドを再実行
ローカル
hostname  // ホスト名(コンピュータ名)表示
tty  // 端末名表示
id  // ID表示
uname -a  // システム情報表示
ifconfig  // IPアドレスなどネットワーク環境表示
groups  // 所属グループ表示
du [file]  // ファイル容量表示
du -s [dir]  // ディレクトリ容量表示
df  // ディスク容量表示
set  // 変数と値を表示
printenv  // 諸情報表示
echo $PATH  // 環境変数の値の確認
export PATH=[パス]:[パス]:[パス]  // PATHの値を変更
例) export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
uptime  // Mac起動からの累計時間確認
sw_vers  // MacのOSバージョン表示
last  // Macの使用履歴表示
ac  // ログインしている時間表示
cal  // カレンダー表示
date  // 現在日時表示
リモート
ssh-keygen 公開鍵(id_rsa.pub)と秘密鍵(id_rsa)を生成 
// 公開鍵をサーバ側に設定すると秘密鍵を持つ端末からアクセス可能になる 
// それでもアクセスできない場合は、他端末やwebコンソールでサーバ側の ~/.ssh/authorized_keys に公開鍵が入っているか確認 
ssh-keygen -p パスフレーズ変更 
ssh [user]@[host]  // リモートホストにログイン
// サーバ側で /etc/ssh/sshd_config を編集してパス入力解除
ChallengeResponseAuthentication no
PasswordAuthentication no
who  // ログインしているユーザ表示
whoami  // ログイン名表示
passwd [user]  // ユーザのパスワード変更
last  // ログイン履歴の表示
whois [domain]  // ドメインの所有者表示
dig [domain]  // ドメインのIPアドレスなど表示
プロセス
top   // プロセス一覧
jobs  // ジョブ(バックグラウンドで実行されてるプロセス)表示
kill [PID]   // プロセスやジョブを強制終了
データ転送
curl [URL]  // ファイル内容表示
curl -o[name] [URL]  // ファイル内容保存
curl -I [URL]  // HTTPヘッダ情報表示
クリア
clear  // 端末画面クリア
マニュアル
man [cmd]  // コマンドマニュアル表示
終了
exit  // シェルを終了(リモートホストからログアウト)