1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Linux ディレクトリをまるごと削除(完全削除)

Posted at

ディレクトリを中のファイルもまるごと削除する

Linuxでファイルが入っているディレクトリをファイルまるごと削除する場合のコマンド。

ディレクトリを再帰的にまるごと削除するので、削除対象に気を付けて!

$ rm -rf directoryname

オプション

オプション 説明
-r, -R ディレクトリ内を再帰的に削除する
-f 警告メッセージを表示しない

エラーが出た時はこちらを参照

rmで-rオプションを付けていない場合

$ rm directoryname
rm: cannot remove 'directoryname': Is a directory

rmdirでディレクトリ内にファイルが入っている場合

$ rmdir directoryname
mdir: failed to remove 'directoryname': Directory not empty
1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?