0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【コマンド】Terminal

Posted at

コマンド

Teminalのバージョンを確認する

zsh --version

カレントディレクトリを表示する

pwd

カレントディレクトリを移動する

指定したディレクトリに移動する。
directory:移動したいディレクトリ

cd directory

ホームディレクトリに移動する。

cd ~/

1つ上の階層に移動する。

cd ..

カレントディレクトリ内のディレクトリとファイルを表示する

ls

隠しファイルを含めた詳細を表示する。

ls -la

ファイルの中身を表示する

file.txt:表示するファイル名

cat file.txt

行番号をつけて表示する。

cat -n file.txt

ディレクトリを作成する

directory:作成するディレクトリ名

mkdir directory

ディレクトリを削除する

directory:削除するディレクトリ名

rm directory

ディレクトリの中身ごと削除する。

rm -r directory

ファイルを作成する

file.txt:作成するファイル名

touch file.txt

ファイルを削除する

file.txt:削除するファイル名

rm file.txt

ファイルをコピーする

同じディレクトリにファイルをコピーする。
file1.txt:コピー元ファイル名
file2.txt:コピー先ファイル名

cp file1.txt file2.txt

異なるディレクトリにファイルを同名でコピーする
file.txt:コピー元ファイル名
directory:コピー先ディレクトリ名

cp file.txt directory

異なるディレクトリにファイルを別名でコピーする
file1.txt:コピー元ファイル名
/directory/file2.txt:コピー先ファイル名

cp file1.txt /directory/file2.txt

ディレクトリ/ファイルの名称を変更する

file1.txt:変更前の名称
file2.txt:変更後の名称

mv file1.txt file2.txt

Finderで開く

カレントディレクトリをFinderで開く

open .

ホームディレクトリをFinderで開く

open ~/

ディレクトリ/ファイルを移動する

指定したディレクトリに移動する
file.txt:移動するファイル名
directory:移動先のディレクトリ名

mv file.txt directory/.

1つ上の階層に移動する

mv file.txt ../
0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?