GNU/Linux >> Linux の 問題 >  >> Linux

Linux でファイルとディレクトリのサイズを確認するにはどうすればよいですか?

ls を使用 ファイルのコマンドと du ディレクトリのコマンド。

ファイル サイズの確認

ls -l filename   #Displays Size of the specified file
ls -l *          #Displays Size of All the files in the current directory
ls -al *         #Displays Size of All the files including hidden files in the current directory
ls -al dir/      #Displays Size of All the files including hidden files in the 'dir' directory

ls コマンドは、ディレクトリの実際のサイズを一覧表示しません (なぜですか?)。したがって、du を使用します。

ディレクトリ サイズの確認

du -sh directory_name    #Gives you the summarized(-s) size of the directory in human readable(-h) format
du -bsh *                #Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format

-h を含む 上記のコマンドのいずれかのオプション (例:ls -lh * または du -sh ) は、人間が読める形式 (kb) でサイズを示します。 、 mb ,gb , ...)

詳細については、man ls を参照してください。 と man du


du があります コマンド。

ディレクトリおよび/またはファイルのサイズ (人にわかりやすい方法で):

$ du -sh .bashrc /tmp

存在しない英単語 dush として覚えました .

--apparent-size コマンド ライン スイッチを使用すると、見かけのサイズを測定できます (ls 実際のディスク使用量ではなく)。


ls -s を使用 ファイルサイズをリストするか、または ls -sh を好む場合 人間が読めるサイズ。

ディレクトリには du を使用します 、そして再び du -h 人間が読めるサイズ。


Linux
  1. Linuxで最大のファイルとディレクトリを探す

  2. Linux ファイルとディレクトリの削除

  3. Linux でファイルとディレクトリを親フォルダーに移動するにはどうすればよいですか?

  1. findコマンドを使用してLinux上のファイルとディレクトリを検索します

  2. Linuxでファイルとディレクトリをアーカイブする方法[パート2]

  3. Linuxでファイルとディレクトリをアーカイブする方法[パート1]

  1. Linuxでファイルとディレクトリをコピーする方法

  2. Linux で空のディレクトリとファイルを見つけて削除する方法

  3. Linux ですべての空のファイルとディレクトリを再帰的に削除するにはどうすればよいですか?