コマンドのパスがわからないときはどのようにしていますか?今回はコマンドのパスを表示するwhichコマンドの使い方についてお勉強していきましょう。

今回はLinuxコマンドのwhichコマンドの使い方についてお勉強しよう!
Linuxコマンド一覧はこちらの記事をご覧ください。
あわせて読みたい


Linuxコマンド記事一覧
Linuxコマンドの記事一覧です。ぜひ役立ててください。 Linuxコマンド一覧 Linuxコマンドの一覧です。Linuxコマンドをお勉強しよう! b basenameパスからファイル名を取…
目次
whichコマンドとは
which コマンド
コマンドのパスを表示する
whichコマンドはコマンドのパスを調べるコマンドです。
whichコマンドの形式
whichコマンドの形式は次の通りです。
which [オプション] [コマンド]
whichコマンドを実行するとコマンドのパスを調べることができます。
オプション | 内容 |
---|---|
-a | すべてのパスを表示する。エイリアスがある場合は、エイリアスも表示する。 |
whichコマンドの使用例
bashコマンドとpasswdコマンドのパスをwhichコマンドを使って調べてみよう。
$ which bash
/bin/bash
$ which passwd
/usr/bin/passwd
それぞれのコマンドのパスがフルパスで表示されました。
whichコマンドで見つからなかった場合
whichコマンドで見つからない場合は次のように表示されます。
$ which penchan
which: no penchan in (/usr/bin:/bin:/use/local/shin:/use/shin:/sbin)
whichコマンドの使い方まとめ
今回はLinuxコマンドのwhichコマンドの使い方についてお勉強しました。whichコマンドを使用してコマンドのパスを調べてみましょう。
which コマンド
コマンドのパスを表示する
ぜひ覚えて利用してください。

今回はLinuxコマンドのwhichコマンドの使い方についてお勉強したよ!