LoginSignup
2
0

More than 1 year has passed since last update.

[基礎]Macのターミナルで使用するUnixコマンド

Last updated at Posted at 2022-12-15

ターミナルでよく使用するUnixコマンドをまとめました。


ディレクトリ・・・フォルダのこと。
カレントディレクトリ・・・現在操作中のフォルダのこと。
ホームディレクトリ・・・ターミナルを立ち上げた際に操作するデフォルトのフォルダのこと。

コマンド一覧

ls (list)

カレントディレクトリ内に存在しているファイルを表示する。listの略。

ターミナル
ls     #カレントディレクトリにあるファイルやディレクトリを表示する
ls -l     #ファイルやディレクトリの詳細も同時に表示する
ls -a     #隠しファイルやディレクトリも含めて、全てのファイルやディレクトリを表示する
ls -la     #隠しファイルやディレクトリも含めて、全てのファイルやディレクトリの詳細を表示する

cd (change directory)

カレントディレクトリ内のファイルに移動する。

ターミナル
cd 〇〇     #〇〇というファイル、ディレクトリに移動する
cd ~     #ホームディレクトリに移動する
cd ..     #一つ上の階層のファイルに移動する

pwd (print working directory)

カレントディレクトリのパスを表示する。

ターミナル
pwd     #カレントディレクトリのパスを表示する

touch

中身が空のファイルを作る。

ターミナル
touch test.html     #test.htmlという中身が空のファイルを作る

mkdir (make directory)

新しい空のディレクトリを作る。

ターミナル
touch test     #testという中身が空のディレクトリを作る

mv (move)

ファイルを移動したり、ファイル名を変更したりする。

ターミナル
mv test.html tmp/     #test.htmlというファイルを相対パスでtmp/に移動する
mv test.html test2.html     #test.htmlというファイルをtest2.htmlに名前変更する

cp (copy)

ファイルをコピーする。

ターミナル
cp test.html tmp/     #test.htmlを相対パスでtmp/というディレクトリの中にコピーする
cp test.html test2.html     #test.htmlをtest2.htmlという名前でコピーする
cp −r test /tmp/     #testというディレクトリとその中身を絶対パスで/tmp/にコピーする

rm (remove)

ファイルを削除する。

ターミナル
rm test.html     #test.htmlを削除する
rm -r test     #testというディレクトリとその中身を削除する
rm -f test     #testというディレクトリを警告なしで削除する
rm -rf test     #testというディレクトリとその中身を警告なしで削除する

open

ターミナルからFinderでファイルを開く。

ターミナル
open .     #現在のターミナルのディレクトリFinderで開く
open ~/     #ホームディレトリをFinderで開く

source

ファイルの設定を読み込み有効にする。

ターミナル
source ~/.bash_profile     #ホームディレクトリにある.bash_profileに書き込んだ設定を読み込み有効にする
source .bash_profile     #カレントディレクトリにある.bash_profile設定を読み込み有効にする

history

コマンド履歴を表示する。

ターミナル
history     #実行してきたコマンドの履歴を表示する
history -c     #実行してきたコマンドの履歴を消去する

★参考記事
Macのターミナルコマンド一覧(基本編)

以上です。

2
0
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
0