Linux disk and directory information view

Source: Internet
Author: User
Tags readable disk usage

"Du: View directory or File size"
Du, English full name disk usage, which is used to calculate the size of a file or directory. If you do not specify any options, count the number of blocks occupied by recursively all subdirectories under the current directory, and finally display the number of blocks occupied by the current directory. But this result, not only the number is very large and we can not see the end, so add options to view is particularly important.

Syntax: du [option] File/dir

OPTION:

-a:all, displaying the disk size information in the current directory and its under recursive subdirectories;

-b:bytes, shown in byte;

-K: calculated in kilobytes;

-M: Calculate in MB;

-c:total, default properties, and finally do total;

-h:human-readable, in the way of human readable display, automatic selection of K, M and g units;

--si: 1000 for the system to calculate rather than 1024;

-l:count-links, calculate all the file size, repeat the hard link file (similar shortcuts but completely different, referencing the file physical index Inode, access to the link address or edit will directly affect the original file, move or delete the original file hard link is still valid, and soft links are similar to shortcuts);

-S: Only the total size of the directory, if not specified directory is the current directory;

-x:exclude, capital X, excluding specified file not calculated;

--exclude=pattern, excluding files that match the specified pattern are not counted;

--max-depth=n, only in the directory depth of N subdirectory for the total calculation, commonly used 1 is the current directory subdirectory;

Example:

Calculate current directory Size: du-sh

Calculates the current directory size: du-h-max-depth=1 or du-sh./*

View the./home directory and file size and sort from large to small: du-sh./home/* |SORT-NR

View file 2016-05.log file size in current directory: Du-h 2016-05.log

View logs directory size under current directory:

View all file sizes in the current directory starting with 2016, ending with. Log, and sorting: Du-h 2016*\.log |SORT-NR

"LS: View all directory Names"
LS, the English full Name list, which lists all the file information under the specified directory, and the default current directory if no directory is specified.

Syntax: LS [option] [File/dir]

OPTION:

-A: Lists all files, containing the hidden files at the beginning;

-D: Lists directory names without displaying their files;

-H: Displays the file size in an appropriate unit (not counting the directory size);

-L: List detailed information;

-R: Reverse sort;

-R: Recursively lists all subdirectory files;

-S: Display file size;

-S: sorted by file size;

-T: Sorting by file modification time;

Example:

List home files in the appropriate units: ls-lh/home/

Lists all directory names under the current directory: ls-d * * or Ls-l|grep "^d" or Ls-f|grep/$

Count the number of files in the current directory: Ls-l|grep "^-" |wc-l

"DF: View disk space remaining"
DF, English full name disk free, the rest of the space, if not specified file is the default overall statistics. Specifies that the file or directory displays the disk utilization of the mount point where the file resides.

Common options:-H, to display in the appropriate units

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.