1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux][command] ファイル操作_ls, cp, mv, mkdir, rm, rmdir, touch, file

Last updated at Posted at 2025-02-28

cpコマンド

$ cp [オプション] コピー元 コピー先
オプション 由来 説明
default copy - 指定したファイルをコピーする
-r recursive - ディレクトリを再帰的にコピーする
-a archive - コピー元のファイルの属性(パーミッション、リンク、タイムスタンプなど)を保持したままコピーする
-i interactive - 既存のファイルを上書きする際に確認を求める
-u update - コピー先のファイルが古い場合のみコピーする
-v verbose - コピーの詳細を表示する
-f force - 書き込み権限がない場合でも強制的にコピーする
-l link - ファイルをコピーせず、ハードリンクを作成する
-t target-directory - コピー先のディレクトリを指定する
-n no-clobber - コピー先に同名のファイルがある場合、上書きしない

touchコマンド

$ touch [オプション] ファイル名
オプション 由来 説明
default なし - 指定したファイルのタイムスタンプ(アクセス日時、変更日時)を現在の日時に更新する
-c no-create - 指定したファイルが存在しない場合、新規作成を行わない
-t timestamp - 明示的に指定したタイムスタンプに変更する(例:touch -t 202301010101 file.txt
-a access time - アクセス日時のみを変更する(変更日時は変更しない)
-m modify time - 変更日時のみを変更する(アクセス日時は変更しない)

fileコマンド

$ file [オプション] ファイル名
オプション 由来 説明
default なし - 指定されたファイルの種類(テキストファイル、バイナリファイルなど)を判別し、出力する
-i mime-type - MIMEタイプ(ファイルの種類)を表示する
-b brief - ファイルタイプの出力を簡潔に表示(ファイル名を除く)
-f file list - 指定したファイルリストから、複数のファイルのタイプを調べて出力する
-z compressed - 圧縮されたファイルも展開してタイプを表示する
-m magic file - 特定のマジックファイルを使用してファイルタイプを判定する

Ping-t

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?