Shell record-shell command (disk)

Source: Internet
Author: User
Tags readable disk usage
The function of the df command in inux is to check the disk space occupation of the file system of the Linux server. You can use this command to obtain information such as how much space is occupied by the hard disk and how much space is left.

1. Command format
df [options] [file]
Shell 2. Command function
Displays the free space of the specified disk file. If no file name is specified, the free space of all currently mounted file systems will be displayed. By default, the disk space will be displayed in units of 1KB unless the environment variable POSIXLY_CORRECT is specified, which will be displayed in units of 512 bytes.

3. Command parameters
Required parameters:

-a List of all file systems
-h display for easy reading
-H is equal to "-h", but the calculation formula, 1K = 1000, not 1K = 1024
-i display inode information
-k block is 1024 bytes
-l only show local file system
-m block is 1048576 bytes
--no-sync ignore sync command
-P output format is POSIX
--sync execute the sync command before getting the disk information
-T file system type
Choose parameters:

--block-size = <block size> specify block size
-t <file system type> Only display the disk information of the selected file system
-x <file system type> do not display the disk information of the selected file system
--help display help information
--version display version information
4. Use case Example 1: Display disk usage
command:

df
Example 2: Display disk usage in inode mode
command:

df -i
Example 3: Display the specified type of disk
command:

df -t ext4 / tmpfs
Example 4: List the usage of i-nodes of each file system
command:

df -ia
Example 5: List the type of file system
command:

df -T
Example 6: Display the current disk space and usage in a more readable way
Command execution and output:

[[email protected] ~] $ df -h
Description:

-h displays the current disk space and usage in a more readable manner;
The -h parameter on the -H root is the same, but when rooting, 1000 instead of 1024 is used for capacity conversion
-k display disk usage in units
-l shows the disk space usage of the local partition. If the server nfs has a remote server's disk, then after adding -l to df, the system displays the result after filtering the nsf drive
-i shows the usage of inode. Linux uses a pointer-like approach to manage disk space mapping. This is also a more critical application.
du command example
The du command in Linux is also used to view the space used. Unlike the df command, the Linux du command is used to view the space used by files and directory disks, so there are some differences from the df command.

1. Command format
du [options] [file]
Shell 2. Command function
Displays the disk space used by each file and directory.

3. Command parameters
-a or -all displays the size of individual files in the directory.
-b or -bytes displays the size of the directory or file in bytes.
-c or --total In addition to displaying the size of individual directories or files, it also displays the sum of all directories or files.
-k or --kilobytes output in KB (1024bytes).
-m or --megabytes output in MB.
-s or --summarize displays only totals and only lists the last summed value.
-h or --human-readable Use K, M, G as the unit to improve the readability of information.
-x or --one-file-xystem is based on the file system at the beginning of processing, and is skipped if it encounters a different file system directory.
-L <symbolic link> or --dereference <symbolic link> displays the source file size of the symbolic link specified in the option.
-S or --separate-dirs When displaying the size of an individual directory, it does not include the size of its subdirectories.
-X <file> or --exclude-from = <file> Specify the directory or file in <file>.
--exclude = <directory or file> Skip the specified directory or file.
-D or --dereference-args display the source file size of the specified symbolic link.
-H or --si is the same as the -h parameter, but K, M, and G are in 1000 units.
-l or --count-links Double-count the hardware link files.
4. Examples of use Example 1: Display the space occupied by a directory or file
command:

du
Example 2: Display the space occupied by the specified file
command:

du log3.log
Example 3: View the space occupied by the specified directory
command:

du / usr / local
Example 4: Display the space occupied by multiple files
command:

du file1 file2
Example 5: Only display the size of the sum
command:

du -s
Example 6: Easy-to-read format display
command:

du -h dir
Example 7: Both files and directories are displayed
Command execution and output:

du -ah project /
Example 8: Display the amount of disk space occupied by several files or directories, and also count their sum
command:

du -c log3.log log1.log text.txt Description:
After adding the -c option, du not only displays the size of the disk space occupied by the two directories, but also counts the sum of them in the last line
Example 9: Sort by space size
command:

du | sort -nr | more
Example 10: Output space used by each subdirectory under the current directory
command:

du -h --max-depth = 1
Shell Record-Shell Command (Disk)
Related Article

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.