LoginSignup
3
3

MacターミナルとWindowsコマンドプロンプトのコマンド一覧(対応表)

Posted at

よく使用するMacターミナルとWindowsコマンドプロンプトのコマンドを一覧化しました。
ぜひシェアしてください👍

ファイル操作関連

ディレクトリの内容をリスト表示

ls(Mac)

lsは、「list」の略。
以下の例は、~/Documentsディレクトリの内容をリスト表示します。

ls -l ~/Documents

dir(Windows)

dirは、「directory」の略。
以下の例は、C:\Usersディレクトリの内容をリスト表示します。

dir C:\Users

カレントディレクトリの変更

cd(共通)

cdは、「change directory」の略。
以下の例は、カレントディレクトリをDesktopフォルダに変更します。(Mac)

cd ~/Desktop

以下の例は、カレントディレクトリをJohnDoeのDocumentsフォルダに変更します。(Windows)

cd C:\Users\JohnDoe\Documents

現在のディレクトリのフルパスを表示

pwd(Mac)

pwdは、「print working directory」の略。

pwd

cd(Windows)

実際にはecho %cd%で現在のディレクトリのフルパスを表示。

echo %cd%

ファイルの作成

touch(Mac)

以下の例は、filename.txtというファイルを作成します。

touch filename.txt

type or copy(Windows)

以下の例は、filename.txtというファイルを作成します。

type nul > filename.txt
copy con filename.txt

ファイルやディレクトリのコピー

cp(Mac)

cpは、「copy」の略。
以下の例は、source.txtdestination.txtとしてコピーします。

cp source.txt destination.txt

copy(Windows)

以下の例は、source.txtdestination.txtとしてコピーします。

copy source.txt destination.txt

ファイルやディレクトリの移動

mv(Mac)

mvは、「move」の略。
以下の例は、oldname.txtnewname.txtにリネームまたは移動します。

mv oldname.txt newname.txt

move(Windows)

以下の例は、oldname.txtnewname.txtにリネームまたは移動します。

move oldname.txt newname.txt

ファイルやディレクトリの削除

rm(Mac)

rmは、「remove」の略。
以下の例は、unwantedfile.txtを削除します。

rm unwantedfile.txt

del(Windows)

以下の例は、unwantedfile.txtを削除します。

del unwantedfile.txt

新しいディレクトリの作成

mkdir(共通)

mkdirは、「make directory」の略。
以下の例は、NewFolderという新しいディレクトリを作成します。

mkdir NewFolder

空のディレクトリの削除

rmdir(共通)

rmdirは、「remove directory」の略。
以下の例は、EmptyFolderというディレクトリを削除します。

rmdir EmptyFolder

ファイルやディレクトリのパーミッションを変更

chmod(Mac)

chmodは、「change mode」の略。
以下の例は、filename.tsxに対して所有者に読み書きの権限を、グループとその他のユーザーに読み取りのみの権限を設定します。

chmod 644 filename.txt

icacls(Windows)

以下の例は、上記のchmodコマンドと同じ操作。
%username%の部分は、ご自身のユーザー名に変更してください。

icacls filename.txt /grant %username%:RW
icacls filename.txt /grant Everyone:R

テキスト操作関連

ファイルの内容を表示

cat(Mac)

catは、「concatenate and display」の略。
以下の例は、myfile.txtの内容を表示します。

cat myfile.txt

type(Windows)

以下の例は、myfile.txtの内容を表示します。

type myfile.txt

ファイルの内容をページ単位で表示

less(Mac)

以下の例は、longfile.txtの内容をページ単位で表示します。

less longfile.txt

more(Windows)

以下の例は、longfile.txtの内容をページ単位で表示します。

more longfile.txt

テキストの検索

grep(Mac)

grepは、「global regular expression print」の略。
以下の例は、myfile.txtで"searchterm"を検索します。

grep "searchterm" myfile.txt

find(Windows)

以下の例は、myfile.txtで"searchterm"を検索します。

find "searchterm" myfile.txt

ターミナル上でテキストを編集

nano or vi(Mac)

nanoviはテキストエディタの名称。
以下の例は、notes.txtをnanoエディタで開きます。

nano notes.txt

以下の例は、notes.txtをviエディタで開きます。

vi notes.txt

notepad(Windows)

以下の例は、notes.txtをNotepadで開きます。

notepad notes.txt

システムとプロセス関連

実行中のプロセスを表示

top(Mac)

topは、「table of processes」の略。

top

tasklist(Windows)

tasklist

プロセスを終了

kill(Mac)

以下の例は、プロセスID 12345のプロセスを終了します。

kill 12345

taskkill(Windows)

以下の例は、Notepadプロセスを終了します。

taskkill /IM notepad.exe

コマンドのマニュアルを表示

man(Mac)

manは、「manual」の略。
以下の例は、lsコマンドのマニュアルページを表示します。

man ls

help(Windows)

以下の例は、copyコマンドのヘルプ情報を表示します。

help copy

ネットワーク関連

ネットワークホストへの応答を確認

ping(共通)

pingは、「Packet Internet Groper」の略。
以下の例は、google.comへの応答を確認します。

ping google.com

ネットワークインターフェースの設定を表示

ifconfig(Mac)

ifconfigは、「interface configuration」の略

ifconfig

ipconfig(Windows)

ipconfig

URLからデータを取得または送信

curl(共通)

curlは、「Client for URLs」の略。
以下の例は、example.comからデータを取得します。

curl https://www.example.com

リモートサーバーに安全に接続

ssh(共通)

sshは、「secure shell」の略。
以下の例は、remotehost.comにSSHで接続します。

ssh username@remotehost.com

システム情報

システム情報を表示

uname(Mac)

unameは、「unix name」の略。
以下の例は、システムの詳細情報を表示します。

uname -a

ver or systeminfo(Windows)

ver
systeminfo

ディスクの空き容量を表示

df(Mac)

dfは、「disk free」の略。
以下の例は、ディスクの空き容量を表示します。

df -h

fsutil volume diskfree c:(Windows)

fsutil volume diskfree c:

ディレクトリやファイルのディスク使用量を表示

du(Macのみ)

duは、「disk usage」の略。
以下の例は、~/Documentsディレクトリのディスク使用量を表示します。

du -sh ~/Documents

その他

テキストや変数を表示

echo(共通)

以下の例は、"Hello, World!"というメッセージを表示します。

echo "Hello, World!"

コマンドのフルパスを表示

which(Mac)

以下の例は、node実行ファイルの場所を検索します。

which node

where(Windows)

以下の例は、notepadの実行ファイルの場所を検索します。

where notepad

実行されたコマンドの履歴を表示

history(Macのみ)

history

他にもよく使うコマンドがありましたら、随時追加していきたいと思います。

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